in src/main/java/com/amazonaws/neptune/auth/NeptuneRequestMetadataSigV4Signer.java [113:162]
protected SdkHttpFullRequest toSignableRequest(final RequestMetadata request)
throws NeptuneSigV4SignerException {
// make sure the request is not null and contains the minimal required set of information
checkNotNull(request, "The request must not be null");
checkNotNull(request.getFullUri(), "The request URI must not be null");
checkNotNull(request.getMethod(), "The request method must not be null");
final URI fullUri = URI.create(request.getFullUri());
checkNotNull(fullUri.getAuthority(), "Authority must not be null");
checkNotNull(fullUri.getScheme(), "Scheme must not be null");
String hostName = "";
final Map<String, List<String>> headersInternal = new HashMap<>();
final Map<String, String> headers = request.getHeaders();
for (Map.Entry<String,String> header : headers.entrySet()) {
// Skip adding the Host header as the signing process will add one.
if (!header.getKey().equalsIgnoreCase(HOST)) {
headersInternal.put(header.getKey(), Arrays.asList(header.getValue()));
} else {
hostName = header.getValue();
}
}
// convert the parameters to the internal API format
final String queryStr = fullUri.getRawQuery();
final Map<String, List<String>> parametersInternal = extractParametersFromQueryString(queryStr);
// carry over the entity (or an empty entity, if no entity is provided)
final InputStream content;
final byte[] bytes;
if (request.getContent().isPresent()) {
bytes = request.getContent().get();
} else {
bytes = "".getBytes(StandardCharsets.UTF_8);
}
content = new ByteArrayInputStream(bytes);
final URI endpointUri = URI.create(fullUri.getScheme() + "://" + fullUri.getAuthority());
final String resourcePath = fullUri.getPath();
return convertToSignableRequest(
request.getMethod(),
endpointUri,
resourcePath,
headersInternal,
parametersInternal,
content);
}