@Test void testFilter() throws IOException, NoSuchAlgorithmException, InvalidKeyException { HttpRequest request = newRequest(inputHeaders().build()); request = filter.filter(request); assertEquals(request.getFirstHeaderOrNull(AtmosHeaders.SIGNATURE), EXPECTED_SIGNATURE); }
@Override public HttpRequest filter(HttpRequest request) throws HttpException { Builder<String, String> builder = ImmutableMap.builder(); builder.put(AtmosHeaders.UID, creds.get().identity); String date = timeStampProvider.get(); builder.put(HttpHeaders.DATE, date); if (request.getHeaders().containsKey(AtmosHeaders.DATE)) builder.put(AtmosHeaders.DATE, date); request = request.toBuilder().replaceHeaders(Multimaps.forMap(builder.build())).build(); String signature = calculateSignature(createStringToSign(request)); request = request.toBuilder().replaceHeader(AtmosHeaders.SIGNATURE, signature).build(); utils.logRequest(signatureLog, request, "<<"); return request; }
SignRequest implements HttpRequestFilter { @Override public HttpRequest filter(HttpRequest request) throws HttpException { Builder<String, String> builder = ImmutableMap.builder(); builder.put(AtmosHeaders.UID, creds.get().identity); String date = timeStampProvider.get(); builder.put(HttpHeaders.DATE, date); if (request.getHeaders().containsKey(AtmosHeaders.DATE)) builder.put(AtmosHeaders.DATE, date); request = request.toBuilder().replaceHeaders(Multimaps.forMap(builder.build())).build(); String signature = calculateSignature(createStringToSign(request)); request = request.toBuilder().replaceHeader(AtmosHeaders.SIGNATURE, signature).build(); utils.logRequest(signatureLog, request, "<<"); return request; } }
SignRequest implements HttpRequestFilter { @Override public HttpRequest filter(HttpRequest request) throws HttpException { Builder<String, String> builder = ImmutableMap.builder(); builder.put(AtmosHeaders.UID, creds.get().identity); String date = timeStampProvider.get(); builder.put(HttpHeaders.DATE, date); if (request.getHeaders().containsKey(AtmosHeaders.DATE)) builder.put(AtmosHeaders.DATE, date); request = request.toBuilder().replaceHeaders(Multimaps.forMap(builder.build())).build(); String signature = calculateSignature(createStringToSign(request)); request = request.toBuilder().replaceHeader(AtmosHeaders.SIGNATURE, signature).build(); utils.logRequest(signatureLog, request, "<<"); return request; } @Inject  SignRequest(SignatureWire signatureWire, @org.jclouds.location.Provider Supplier<Credentials> creds,
         @TimeStamp Provider<String> timeStampProvider, Crypto crypto, HttpUtils utils); }
SignRequest implements HttpRequestFilter { @Override public HttpRequest filter(HttpRequest request) throws HttpException { Builder<String, String> builder = ImmutableMap.builder(); builder.put(AtmosHeaders.UID, creds.get().identity); String date = timeStampProvider.get(); builder.put(HttpHeaders.DATE, date); if (request.getHeaders().containsKey(AtmosHeaders.DATE)) builder.put(AtmosHeaders.DATE, date); request = request.toBuilder().replaceHeaders(Multimaps.forMap(builder.build())).build(); String signature = calculateSignature(createStringToSign(request)); request = request.toBuilder().replaceHeader(AtmosHeaders.SIGNATURE, signature).build(); utils.logRequest(signatureLog, request, "<<"); return request; } @Inject  SignRequest(SignatureWire signatureWire, @org.jclouds.location.Provider Supplier<Credentials> creds,
         @TimeStamp Provider<String> timeStampProvider, Crypto crypto, HttpUtils utils); @Override HttpRequest filter(HttpRequest request); String createStringToSign(HttpRequest request); String calculateSignature(String toSign); String signString(String toSign); }
SignRequest implements HttpRequestFilter { @Override public HttpRequest filter(HttpRequest request) throws HttpException { Builder<String, String> builder = ImmutableMap.builder(); builder.put(AtmosHeaders.UID, creds.get().identity); String date = timeStampProvider.get(); builder.put(HttpHeaders.DATE, date); if (request.getHeaders().containsKey(AtmosHeaders.DATE)) builder.put(AtmosHeaders.DATE, date); request = request.toBuilder().replaceHeaders(Multimaps.forMap(builder.build())).build(); String signature = calculateSignature(createStringToSign(request)); request = request.toBuilder().replaceHeader(AtmosHeaders.SIGNATURE, signature).build(); utils.logRequest(signatureLog, request, "<<"); return request; } @Inject  SignRequest(SignatureWire signatureWire, @org.jclouds.location.Provider Supplier<Credentials> creds,
         @TimeStamp Provider<String> timeStampProvider, Crypto crypto, HttpUtils utils); @Override HttpRequest filter(HttpRequest request); String createStringToSign(HttpRequest request); String calculateSignature(String toSign); String signString(String toSign);  }