@Test(threadPoolSize = 3, dataProvider = "dataProvider", timeOut = 10000) void testIdempotent(HttpRequest request) { request = filter.filter(request); String signature = request.getFirstHeaderOrNull(HttpHeaders.AUTHORIZATION); String date = request.getFirstHeaderOrNull(HttpHeaders.DATE); int iterations = 1; while (request.getFirstHeaderOrNull(HttpHeaders.DATE).equals(date)) { date = request.getFirstHeaderOrNull(HttpHeaders.DATE); request = filter.filter(request); if (request.getFirstHeaderOrNull(HttpHeaders.DATE).equals(date)) assert signature.equals(request.getFirstHeaderOrNull(HttpHeaders.AUTHORIZATION)) : String.format( "sig: %s != %s on attempt %s", signature, request.getFirstHeaderOrNull(HttpHeaders.AUTHORIZATION), iterations); else iterations++; } System.out.printf("%s: %d iterations before the timestamp updated %n", Thread.currentThread().getName(), iterations); }
public HttpRequest filter(HttpRequest request) throws HttpException { request = replaceDateHeader(request); Credentials current = creds.get(); if (current instanceof SessionCredentials) { request = replaceSecurityTokenHeader(request, SessionCredentials.class.cast(current)); } String signature = calculateSignature(createStringToSign(request)); request = replaceAuthorizationHeader(request, signature); utils.logRequest(signatureLog, request, "<<"); return request; }
RequestAuthorizeSignatureV2 implements RequestAuthorizeSignature, RequestSigner { public HttpRequest filter(HttpRequest request) throws HttpException { request = replaceDateHeader(request); Credentials current = creds.get(); if (current instanceof SessionCredentials) { request = replaceSecurityTokenHeader(request, SessionCredentials.class.cast(current)); } String signature = calculateSignature(createStringToSign(request)); request = replaceAuthorizationHeader(request, signature); utils.logRequest(signatureLog, request, "<<"); return request; } }
RequestAuthorizeSignatureV2 implements RequestAuthorizeSignature, RequestSigner { public HttpRequest filter(HttpRequest request) throws HttpException { request = replaceDateHeader(request); Credentials current = creds.get(); if (current instanceof SessionCredentials) { request = replaceSecurityTokenHeader(request, SessionCredentials.class.cast(current)); } String signature = calculateSignature(createStringToSign(request)); request = replaceAuthorizationHeader(request, signature); utils.logRequest(signatureLog, request, "<<"); return request; } @Inject  RequestAuthorizeSignatureV2(SignatureWire signatureWire, @Named(PROPERTY_AUTH_TAG) String authTag,
         @Named(PROPERTY_S3_VIRTUAL_HOST_BUCKETS) boolean isVhostStyle,
         @Named(PROPERTY_S3_SERVICE_PATH) String servicePath, @Named(PROPERTY_HEADER_TAG) String headerTag,
         @org.jclouds.location.Provider Supplier<Credentials> creds,
         @TimeStamp Provider<String> timeStampProvider, Crypto crypto, HttpUtils utils,
         DateService dateService); }
RequestAuthorizeSignatureV2 implements RequestAuthorizeSignature, RequestSigner { public HttpRequest filter(HttpRequest request) throws HttpException { request = replaceDateHeader(request); Credentials current = creds.get(); if (current instanceof SessionCredentials) { request = replaceSecurityTokenHeader(request, SessionCredentials.class.cast(current)); } String signature = calculateSignature(createStringToSign(request)); request = replaceAuthorizationHeader(request, signature); utils.logRequest(signatureLog, request, "<<"); return request; } @Inject  RequestAuthorizeSignatureV2(SignatureWire signatureWire, @Named(PROPERTY_AUTH_TAG) String authTag,
         @Named(PROPERTY_S3_VIRTUAL_HOST_BUCKETS) boolean isVhostStyle,
         @Named(PROPERTY_S3_SERVICE_PATH) String servicePath, @Named(PROPERTY_HEADER_TAG) String headerTag,
         @org.jclouds.location.Provider Supplier<Credentials> creds,
         @TimeStamp Provider<String> timeStampProvider, Crypto crypto, HttpUtils utils,
         DateService dateService); HttpRequest filter(HttpRequest request); String createStringToSign(HttpRequest request); String sign(String toSign); @Override HttpRequest signForTemporaryAccess(HttpRequest request, long timeInSeconds); }
RequestAuthorizeSignatureV2 implements RequestAuthorizeSignature, RequestSigner { public HttpRequest filter(HttpRequest request) throws HttpException { request = replaceDateHeader(request); Credentials current = creds.get(); if (current instanceof SessionCredentials) { request = replaceSecurityTokenHeader(request, SessionCredentials.class.cast(current)); } String signature = calculateSignature(createStringToSign(request)); request = replaceAuthorizationHeader(request, signature); utils.logRequest(signatureLog, request, "<<"); return request; } @Inject  RequestAuthorizeSignatureV2(SignatureWire signatureWire, @Named(PROPERTY_AUTH_TAG) String authTag,
         @Named(PROPERTY_S3_VIRTUAL_HOST_BUCKETS) boolean isVhostStyle,
         @Named(PROPERTY_S3_SERVICE_PATH) String servicePath, @Named(PROPERTY_HEADER_TAG) String headerTag,
         @org.jclouds.location.Provider Supplier<Credentials> creds,
         @TimeStamp Provider<String> timeStampProvider, Crypto crypto, HttpUtils utils,
         DateService dateService); HttpRequest filter(HttpRequest request); String createStringToSign(HttpRequest request); String sign(String toSign); @Override HttpRequest signForTemporaryAccess(HttpRequest request, long timeInSeconds);  }