QuerySigner implements AuthenticationFilter, RequestSigner { @VisibleForTesting public String createStringToSign(HttpRequest request, Multimap<String, String> decodedParams) { utils.logRequest(signatureLog, request, ">>"); ImmutableSortedSet.Builder<String> builder = ImmutableSortedSet.naturalOrder(); for (Map.Entry<String, String> entry : decodedParams.entries()) builder.add(entry.getKey() + "=" + Strings2.urlEncode(entry.getValue())); String stringToSign = Joiner.on('&').join(builder.build()).toLowerCase(); if (signatureWire.enabled()) signatureWire.output(stringToSign); return stringToSign; } @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 testCreateStringToSign() { QuerySigner filter = INJECTOR.getInstance(QuerySigner.class); assertEquals( filter.createStringToSign(HttpRequest.builder().method("GET") .endpoint("http: "apikey=apikey&command=listzones"); }
@Test void testCreateStringToSignWithBrackets() { QuerySigner filter = INJECTOR.getInstance(QuerySigner.class); assertEquals( filter.createStringToSign(HttpRequest.builder().method("GET") .endpoint("http: "apikey=apikey&command=deployvirtualmachine&iptonetworklist[0].ip=127.0.0.1&iptonetworklist[0].networkid=1"); }