/** * Attempts to parse the region name from an endpoint based on conventions * about the endpoint format. * * @param host the hostname to parse * @param serviceHint an optional hint about the service for the endpoint * @return the region parsed from the hostname, or * "us-east-1" if no region information * could be found. * @deprecated in favor of {@link #parseRegion(String, String)}. */ @Deprecated public static String parseRegionName(final String host, final String serviceHint) { String region = parseRegion(host, serviceHint); // If region is null, then endpoint is totally non-standard; // guess us-east-1 for lack of a better option. return region == null ? "us-east-1" : region; }
private String getSigningRegionForRequestURI(URI uri) { String regionName = awsClient.getSignerRegionOverride(); if (regionName == null) { regionName = AwsHostNameUtils.parseRegion(uri.getHost(), awsClient.getEndpointPrefix()); } return regionName; } }
@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); }
this.endpoint = uri; this.signerProvider = createSignerProvider(signer); this.signingRegion = AwsHostNameUtils.parseRegion(endpoint, getEndpointPrefix());
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration( endpoint, AwsHostNameUtils.parseRegion( endpoint, null
this.endpoint = uri; this.signerProvider = createSignerProvider(signer); this.signingRegion = AwsHostNameUtils.parseRegion(endpoint.toString(), getEndpointPrefix());
requestRegion = AwsHostNameUtils.parseRegion(requestEndpoint.getHost(), S3_SERVICE_NAME);
/** * Attempts to parse the region name from an endpoint based on conventions * about the endpoint format. * * @param host the hostname to parse * @param serviceHint an optional hint about the service for the endpoint * @return the region parsed from the hostname, or * "us-east-1" if no region information * could be found. * @deprecated in favor of {@link #parseRegion(String, String)}. */ @Deprecated public static String parseRegionName(final String host, final String serviceHint) { String region = parseRegion(host, serviceHint); // If region is null, then endpoint is totally non-standard; // guess us-east-1 for lack of a better option. return region == null ? "us-east-1" : region; }
private String getSigningRegionForRequestURI(URI uri) { String regionName = awsClient.getSignerRegionOverride(); if (regionName == null) { regionName = AwsHostNameUtils.parseRegion(uri.getHost(), awsClient.getEndpointPrefix()); } return regionName; } }
this.endpoint = uri; this.signerProvider = createSignerProvider(signer); this.signingRegion = AwsHostNameUtils.parseRegion(endpoint, getEndpointPrefix());
this.endpoint = uri; this.signerProvider = createSignerProvider(signer); this.signingRegion = AwsHostNameUtils.parseRegion(endpoint.toString(), getEndpointPrefix());
/** * Attempts to parse the region name from an endpoint based on conventions * about the endpoint format. * * @param host the hostname to parse * @param serviceHint an optional hint about the service for the endpoint * @return the region parsed from the hostname, or * "us-east-1" if no region information * could be found. * @deprecated in favor of {@link #parseRegion(String, String)}. */ @Deprecated public static String parseRegionName(final String host, final String serviceHint) { String region = parseRegion(host, serviceHint); // If region is null, then endpoint is totally non-standard; // guess us-east-1 for lack of a better option. return region == null ? "us-east-1" : region; }
@VisibleForTesting static AwsClientBuilder.EndpointConfiguration getEndpointConfiguration(final Optional<String> endpoint, final String signingRegion) { Preconditions.checkArgument(endpoint != null, "must provide an optional endpoint and not null"); Preconditions.checkArgument(!Strings.isNullOrEmpty(signingRegion), "must provide a signing region"); final String expectedServiceEndpoint = "https://" + Region.getRegion(Regions.fromName(signingRegion)).getServiceEndpoint(AmazonDynamoDB.ENDPOINT_PREFIX); if (endpoint.isPresent() && !Strings.isNullOrEmpty(endpoint.get())) { final String regionParsedFromEndpoint = AwsHostNameUtils.parseRegion(endpoint.get(), AmazonDynamoDB.ENDPOINT_PREFIX); Preconditions.checkArgument(regionParsedFromEndpoint == null || signingRegion.equals(regionParsedFromEndpoint)); return new AwsClientBuilder.EndpointConfiguration(endpoint.get(), signingRegion); } else { //Regions.fromName will throw IllegalArgumentException if signingRegion is not valid. return new AwsClientBuilder.EndpointConfiguration(expectedServiceEndpoint, signingRegion); } }
private String getSigningRegionForRequestURI(URI uri) { String regionName = awsClient.getSignerRegionOverride(); if (regionName == null) { regionName = AwsHostNameUtils.parseRegion(uri.getHost(), awsClient.getEndpointPrefix()); } return regionName; } }
@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); }
String clientRegion = null; if (!ServiceUtils.isS3USStandardEndpoint(endpoint)) { clientRegion = AwsHostNameUtils.parseRegion(host, AmazonS3Client.S3_SERVICE_NAME);
requestRegion = AwsHostNameUtils.parseRegion(requestEndpoint.getHost(), S3_SERVICE_NAME);