@Override
    public void beforeRequest(Request<?> request) {
        if (!requestClassToPreSign.isInstance(request.getOriginalRequest())) return;

        if (request.getParameters().containsKey(PARAM_PRESIGNED_URL)) return;

        PresignableRequest presignableRequest = adaptRequest(requestClassToPreSign.cast(
                request.getOriginalRequest()));

        String sourceRegion = presignableRequest.getSourceRegion();
        if (sourceRegion == null) return;

        String destinationRegion = AwsHostNameUtils.parseRegion(request.getEndpoint().getHost(),
                SERVICE_NAME);

        Request<?> requestToPresign = presignableRequest.marshall();
        requestToPresign.getParameters().remove(PARAM_SOURCE_REGION);
        requestToPresign.getParameters().put(PARAM_DESTINATION_REGION, Arrays.asList(destinationRegion));
        requestToPresign.setEndpoint(createEndpoint(sourceRegion, SERVICE_NAME));
        requestToPresign.setHttpMethod(HttpMethodName.GET);

        AWSCredentials credentials = request.getHandlerContext(HandlerContextKey.AWS_CREDENTIALS);

        requestToPresign = presignRequest(requestToPresign, credentials, sourceRegion);

        final String presignedUrl = generateUrl(requestToPresign);

        presignableRequest.setPreSignedUrl(presignedUrl);

        request.addParameter(PARAM_PRESIGNED_URL, presignedUrl);
        // Remove the unmodeled params to stop them getting onto the wire
        request.getParameters().remove(PARAM_SOURCE_REGION);
    }
Abstract pre-sign handler that follows the pre-signing scheme outlined in the 'RDS Presigned URL for Cross-Region Copying' SEP.

@param <T> The request type.
aws-java-sdk-neptune/src/main/java/com/amazonaws/services/neptune/PresignRequestHandler.java