public CompletionStage evaluateChallenge()

in src/main/java/software/aws/mcs/auth/SigV4AuthProvider.java [197:220]


        public CompletionStage<ByteBuffer> evaluateChallenge(ByteBuffer challenge) {
            try {
                byte[] nonce = extractNonce(challenge);

                Instant requestTimestamp = Instant.now();
                AwsCredentials credentials = credentialsProvider.resolveCredentials();

                String signature = generateSignature(nonce, requestTimestamp, credentials);

                String response =
                    String.format("signature=%s,access_key=%s,amzdate=%s",
                                  signature,
                                  credentials.accessKeyId(),
                                  timestampFormatter.format(requestTimestamp));

                if (credentials instanceof AwsSessionCredentials) {
                    response = response + ",session_token=" + ((AwsSessionCredentials)credentials).sessionToken();
                }

                return CompletableFuture.completedFuture(ByteBuffer.wrap(response.getBytes(StandardCharsets.UTF_8)));
            } catch (UnsupportedEncodingException e) {
                throw new RuntimeException("This platform does not support the UTF-8encoding", e);
            }
        }