@Override
 public void apply(final RequestTemplate template) {
   final OAuthRequest request = buildAuthenticationRequest(template);
   OAuthService service = buildAuthenticationService();
   service.signRequest(credentials.accessToken(), request);
   template.header("Authorization", extractAuthenticationHeader(request));
 }
  @Test
  public void testSecretCorrectlySigns() {

    LocalDateTime dateTime =
        LocalDateTime.from(DateTimeFormatter.ISO_DATE_TIME.parse("2014-06-03T17:48:47.774453"));

    CoinkiteSigningRequestInterceptor coinkiteSigningRequestInterceptor =
        new CoinkiteSigningRequestInterceptor();
    coinkiteSigningRequestInterceptor.setDateTime(dateTime);

    RequestTemplate template = new RequestTemplate().method("GET").append("/example/endpoint");

    coinkiteSigningRequestInterceptor.apply(template);

    Collection<String> collection = template.headers().get(Constants.X_CK_TIMESTAMP);
    assertEquals(collection.iterator().next(), "2014-06-03T17:48:47.774453");
    collection = template.headers().get(Constants.X_CK_SIGN);
    assertEquals(
        "042341c271b14aaad1c898d35c9ca0bc8552e1cb4d6683f28edd57e3e86ed76c",
        collection.iterator().next());
  }
 private OAuthRequest buildAuthenticationRequest(final RequestTemplate template) {
   final String url = TwitterApiBuilder.HOST + template.url();
   return new OAuthRequest(Verb.valueOf(template.method()), url + template.queryLine());
 }
 public void setHeader(RequestTemplate request, String name, String value) {
   if (value != null && !request.headers().containsKey(name) && this.accessor.isTracing()) {
     request.header(name, value);
   }
 }