protected Signer createSigner(final Request<?> request,
                                  final String bucketName,
                                  final String key,
                                  final boolean isAdditionalHeadRequestToFindRegion) {

        // Instead of using request.getEndpoint() for this parameter, we use endpoint which is because
        // in accelerate mode, the endpoint in request is regionless. We need the client-wide endpoint
        // to fetch the region information and pick the correct signer.
        URI uri = clientOptions.isAccelerateModeEnabled() ? endpoint : request.getEndpoint();
        final Signer signer = getSignerByURI(uri);

        if (!isSignerOverridden()) {

            if ((signer instanceof AWSS3V4Signer) && bucketRegionShouldBeCached(request)) {

                String region = bucketRegionCache.get(bucketName);
                if (region != null) {
                     // If cache contains the region for the bucket, create an endpoint for the region and
                     // update the request with that endpoint.
                     request.addHandlerContext(HandlerContextKey.SIGNING_REGION, region);
                     resolveRequestEndpoint(request, bucketName, key, RuntimeHttpUtils.toUri(RegionUtils.getRegion(region).getServiceEndpoint(S3_SERVICE_NAME), clientConfiguration));
                     return updateSigV4SignerWithRegion((AWSS3V4Signer) signer, region);
                } else if (request.getOriginalRequest() instanceof GeneratePresignedUrlRequest) {
                    String signerRegion = getSignerRegion();
                    if (signerRegion == null) {
                        return createSigV2Signer(request, bucketName, key);
                    }
                    return updateSigV4SignerWithRegion((AWSS3V4Signer) signer, signerRegion);
                } else if (isAdditionalHeadRequestToFindRegion) {
                    return updateSigV4SignerWithRegion((AWSS3V4Signer) signer, "us-east-1");
                }
            }

            String regionOverride = getSignerRegionOverride();
            if (regionOverride != null) {
                return updateSigV4SignerWithRegion(new AWSS3V4Signer(), regionOverride);
            }
        }

        if (signer instanceof S3Signer) {
            // The old S3Signer needs a method and path passed to its
            // constructor; if that's what we should use, getSigner()
            // will return a dummy instance and we need to create a
            // new one with the appropriate values for this request.
            return createSigV2Signer(request, bucketName, key);
        }

        return signer;
    }
protected Signer createSigner ( final Request < ? > request , final String bucketName , final String key , final boolean isAdditionalHeadRequestToFindRegion ) { URI uri = clientOptions . isAccelerateModeEnabled ( ) ? endpoint : request . getEndpoint ( ) ; final Signer signer = getSignerByURI ( uri ) ; if ( ! isSignerOverridden ( ) ) { if ( ( signer instanceof AWSS3V4Signer ) && bucketRegionShouldBeCached ( request ) ) { String region = bucketRegionCache . get ( bucketName ) ; if ( region != null ) { request . addHandlerContext ( HandlerContextKey . SIGNING_REGION , region ) ; resolveRequestEndpoint ( request , bucketName , key , RuntimeHttpUtils . toUri ( RegionUtils . getRegion ( region ) . getServiceEndpoint ( S3_SERVICE_NAME ) , clientConfiguration ) ) ; return updateSigV4SignerWithRegion ( ( AWSS3V4Signer ) signer , region ) ; } else if ( request . getOriginalRequest ( ) instanceof GeneratePresignedUrlRequest ) { String signerRegion = getSignerRegion ( ) ; if ( signerRegion == null ) { return createSigV2Signer ( request , bucketName , key ) ; } return updateSigV4SignerWithRegion ( ( AWSS3V4Signer ) signer , signerRegion ) ; } else if ( isAdditionalHeadRequestToFindRegion ) { return updateSigV4SignerWithRegion ( ( AWSS3V4Signer ) signer , "us-east-1" ) ; } } String regionOverride = getSignerRegionOverride ( ) ; if ( regionOverride != null ) { return updateSigV4SignerWithRegion ( new AWSS3V4Signer ( ) , regionOverride ) ; } } if ( signer instanceof S3Signer ) { return createSigV2Signer ( request , bucketName , key ) ; } return signer ; }
Returns a "complete" S3 specific signer, taking into the S3 bucket, key,
and the current S3 client configuration into account.