Следующие инструкции по обновлению версии AWS SDK приведены здесь. Раньше мы использовали DefaultRequest, но похоже, что он больше недоступен. Аналогично, defaultRequest использовался для подписи заголовков с помощью Aws4Signer, который также устарел. Интересно, знает ли кто-нибудь им замену.
На данный момент это мой код:
public String getBase64EncodedRequestHeaders(String url) throws URISyntaxException, JsonProcessingException {
// Create the HTTP request to be signed - previously used DefaultRequest
SdkHttpRequest httpRequest =
SdkHttpRequest.builder()
.uri(new URI(endpoint))
.method(SdkHttpMethod.POST)
.putHeader("X-Vault-AWS-IAM-Server-ID", new URI(url).getHost())
.putHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8")
.build();
final AwsV4HttpSigner aws4Signer = AwsV4HttpSigner.create();
// Previously used Aws4Signer
SignedRequest signedRequest =
aws4Signer.sign(r -> r.identity(credentials)
.request(httpRequest)
.payload((ContentStreamProvider) new ByteArrayInputStream(requestBody.getBytes()))
.putProperty(AwsV4HttpSigner.SERVICE_SIGNING_NAME, "sts")
.putProperty(AwsV4HttpSigner.REGION_NAME, region));
final Map newMap = signedRequest
.request().headers() // i dont think this is the signed version
.entrySet()
.stream()
.collect(Collectors.toMap(Map.Entry::getKey, entry -> Collections.singletonList(entry.getValue()))); // mapping does not work out of the box
return Base64.getEncoder().encodeToString(new ObjectMapper().writeValueAsBytes(newMap));
}
Подробнее здесь: https://stackoverflow.com/questions/786 ... aws4signer