QuerySigner implements AuthenticationFilter, RequestSigner { public HttpRequest filter(HttpRequest request) throws HttpException { checkNotNull(request, "request must be present"); Multimap<String, String> decodedParams = queryParser().apply(request.getEndpoint().getRawQuery()); addSigningParams(decodedParams); String stringToSign = createStringToSign(request, decodedParams); String signature = sign(stringToSign); addSignature(decodedParams, signature); request = request.toBuilder().endpoint(uriBuilder(request.getEndpoint()).query(decodedParams).build()).build(); utils.logRequest(signatureLog, request, "<<"); return request; } @Inject  QuerySigner(SignatureWire signatureWire, @Provider Supplier<Credentials> creds, Crypto crypto, HttpUtils utils); HttpRequest filter(HttpRequest request); @VisibleForTesting String sign(String toSign); @VisibleForTesting String createStringToSign(HttpRequest request, Multimap<String, String> decodedParams); String createStringToSign(HttpRequest input);  }
@Test void testFilter() { QuerySigner filter = INJECTOR.getInstance(QuerySigner.class); assertEquals( filter.filter( HttpRequest.builder().method("GET") .endpoint("http: .getRequestLine(), "GET http: }
@Test void testFilterTwice() { QuerySigner filter = INJECTOR.getInstance(QuerySigner.class); HttpRequest request = HttpRequest.builder().method("GET") .endpoint("http: for (int i = 0; i < 2; i++) { request = filter.filter(request); assertEquals( request.getRequestLine(), "GET http: } }