HttpSignatureRequestInterceptor implements HttpRequestInterceptor { @Override public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException { if (!authEnabled) { return; } final long start = System.nanoTime(); final Header authorization = authScheme.authenticate( this.credentials, request, context); final long end = System.nanoTime(); request.setHeader(authorization); request.setHeader("x-http-signing-time-ns", String.valueOf(end - start)); } HttpSignatureRequestInterceptor(final HttpSignatureAuthScheme authScheme,
                                           final Credentials credentials,
                                           final boolean authEnabled); @Override void process(final HttpRequest request, final HttpContext context);  }
@Test public void signBenchmark() throws IOException, HttpException { Header[] headers = new Header[] { new BasicHeader("Content-Type", "application/json; type=directory"), new BasicHeader("x-request-id", "bb3ca512-c637-43c8-926b-2990caf64aee"), new BasicHeader("accept-version", "~1.0"), new BasicHeader("Accept", "application/json, */*"), new BasicHeader("Content-Length", "0"), new BasicHeader("Host", "us-east.manta.joyent.com:443"), new BasicHeader("Connection", "Keep-Alive"), new BasicHeader("User-Agent", "Java-Manta-SDK/3.0.0-SNAPSHOT (Java/1.8.0_76/Oracle Corporation)"), new BasicHeader("Accept-Encoding", "gzip,deflate"), }; HttpContext context = new BasicHttpContext(); for (int i = 0; i < 5; i++) { HttpRequest request = new HttpPut("https: request.setHeaders(headers); interceptor.process(request, context); String signTime = request.getFirstHeader("x-http-signing-time-ns").getValue(); System.out.printf("Time to sign: %s\n", signTime); } }