@Test public void beforeExecution() throws Exception { OAuth1RequestInterceptor interceptor = new OAuth1RequestInterceptor(new OAuth1Credentials("consumer_key", "consumer_secret", "access_token", "token_secret")); byte[] body = "status=Hello+there".getBytes(); MockHttpServletRequest request = new MockHttpServletRequest(HttpMethod.POST.name(), "/status/update"); request.setRemoteHost("api.someprovider.com"); request.setSecure(true); request.setContentType(MediaType.APPLICATION_FORM_URLENCODED.toString()); ClientHttpRequestExecution execution = new ClientHttpRequestExecution() { public ClientHttpResponse execute(HttpRequest request, byte[] body) throws IOException { String authorizationHeader = request.getHeaders().getFirst("Authorization"); Map<String, String> headerParameters = extractHeaderParameters(authorizationHeader); assertEquals("1.0", headerParameters.get("oauth_version")); assertTrue(headerParameters.containsKey("oauth_nonce")); assertEquals("HMAC-SHA1", headerParameters.get("oauth_signature_method")); assertEquals("consumer_key", headerParameters.get("oauth_consumer_key")); assertEquals("access_token", headerParameters.get("oauth_token")); assertTrue(headerParameters.containsKey("oauth_timestamp")); assertTrue(headerParameters.containsKey("oauth_signature")); assertEquals(MediaType.APPLICATION_FORM_URLENCODED, request.getHeaders().getContentType()); return null; } }; interceptor.intercept(new ServletServerHttpRequest(request), body, execution); }
public ClientHttpResponse intercept(final HttpRequest request, final byte[] body, ClientHttpRequestExecution execution) throws IOException { HttpRequest protectedResourceRequest = new HttpRequestDecorator(request); protectedResourceRequest.getHeaders().add("Authorization", getAuthorizationHeaderValue(request, body)); return execution.execute(protectedResourceRequest, body); }
OAuth1RequestInterceptor implements ClientHttpRequestInterceptor { public ClientHttpResponse intercept(final HttpRequest request, final byte[] body, ClientHttpRequestExecution execution) throws IOException { HttpRequest protectedResourceRequest = new HttpRequestDecorator(request); protectedResourceRequest.getHeaders().add("Authorization", getAuthorizationHeaderValue(request, body)); return execution.execute(protectedResourceRequest, body); } }
OAuth1RequestInterceptor implements ClientHttpRequestInterceptor { public ClientHttpResponse intercept(final HttpRequest request, final byte[] body, ClientHttpRequestExecution execution) throws IOException { HttpRequest protectedResourceRequest = new HttpRequestDecorator(request); protectedResourceRequest.getHeaders().add("Authorization", getAuthorizationHeaderValue(request, body)); return execution.execute(protectedResourceRequest, body); } OAuth1RequestInterceptor(OAuth1Credentials oauth1Credentials); }
OAuth1RequestInterceptor implements ClientHttpRequestInterceptor { public ClientHttpResponse intercept(final HttpRequest request, final byte[] body, ClientHttpRequestExecution execution) throws IOException { HttpRequest protectedResourceRequest = new HttpRequestDecorator(request); protectedResourceRequest.getHeaders().add("Authorization", getAuthorizationHeaderValue(request, body)); return execution.execute(protectedResourceRequest, body); } OAuth1RequestInterceptor(OAuth1Credentials oauth1Credentials); ClientHttpResponse intercept(final HttpRequest request, final byte[] body, ClientHttpRequestExecution execution); }
OAuth1RequestInterceptor implements ClientHttpRequestInterceptor { public ClientHttpResponse intercept(final HttpRequest request, final byte[] body, ClientHttpRequestExecution execution) throws IOException { HttpRequest protectedResourceRequest = new HttpRequestDecorator(request); protectedResourceRequest.getHeaders().add("Authorization", getAuthorizationHeaderValue(request, body)); return execution.execute(protectedResourceRequest, body); } OAuth1RequestInterceptor(OAuth1Credentials oauth1Credentials); ClientHttpResponse intercept(final HttpRequest request, final byte[] body, ClientHttpRequestExecution execution);  }