@Test public void testPercentEncodeKeyValues() { String keyValue = "\u3b05\u000c\u375b"; ConsumerKey consumer = new ConsumerKey(keyValue, "secret"); RequestToken reqToken = new RequestToken(keyValue, "secret"); OAuthSignatureCalculator calc = new OAuthSignatureCalculator(consumer, reqToken); RequestBuilder reqBuilder = new RequestBuilder() .setUrl("https: Request req = reqBuilder.build(); calc.calculateAndAddSignature(req, reqBuilder); }
@Override public void calculateAndAddSignature(Request request, RequestBuilderBase<?> requestBuilder) { try { String authorization = INSTANCES.get().computeAuthorizationHeader( consumerAuth, userAuth, request.getUri(), request.getMethod(), request.getFormParams(), request.getQueryParams()); requestBuilder.setHeader(HttpHeaderNames.AUTHORIZATION, authorization); } catch (InvalidKeyException e) { throw new IllegalArgumentException("Failed to compute a valid key from consumer and user secrets", e); } }
OAuthSignatureCalculator implements SignatureCalculator { @Override public void calculateAndAddSignature(Request request, RequestBuilderBase<?> requestBuilder) { try { String authorization = INSTANCES.get().computeAuthorizationHeader( consumerAuth, userAuth, request.getUri(), request.getMethod(), request.getFormParams(), request.getQueryParams()); requestBuilder.setHeader(HttpHeaderNames.AUTHORIZATION, authorization); } catch (InvalidKeyException e) { throw new IllegalArgumentException("Failed to compute a valid key from consumer and user secrets", e); } } }
OAuthSignatureCalculator implements SignatureCalculator { @Override public void calculateAndAddSignature(Request request, RequestBuilderBase<?> requestBuilder) { try { String authorization = INSTANCES.get().computeAuthorizationHeader( consumerAuth, userAuth, request.getUri(), request.getMethod(), request.getFormParams(), request.getQueryParams()); requestBuilder.setHeader(HttpHeaderNames.AUTHORIZATION, authorization); } catch (InvalidKeyException e) { throw new IllegalArgumentException("Failed to compute a valid key from consumer and user secrets", e); } } OAuthSignatureCalculator(ConsumerKey consumerAuth, RequestToken userAuth); }
OAuthSignatureCalculator implements SignatureCalculator { @Override public void calculateAndAddSignature(Request request, RequestBuilderBase<?> requestBuilder) { try { String authorization = INSTANCES.get().computeAuthorizationHeader( consumerAuth, userAuth, request.getUri(), request.getMethod(), request.getFormParams(), request.getQueryParams()); requestBuilder.setHeader(HttpHeaderNames.AUTHORIZATION, authorization); } catch (InvalidKeyException e) { throw new IllegalArgumentException("Failed to compute a valid key from consumer and user secrets", e); } } OAuthSignatureCalculator(ConsumerKey consumerAuth, RequestToken userAuth); @Override void calculateAndAddSignature(Request request, RequestBuilderBase<?> requestBuilder); }
OAuthSignatureCalculator implements SignatureCalculator { @Override public void calculateAndAddSignature(Request request, RequestBuilderBase<?> requestBuilder) { try { String authorization = INSTANCES.get().computeAuthorizationHeader( consumerAuth, userAuth, request.getUri(), request.getMethod(), request.getFormParams(), request.getQueryParams()); requestBuilder.setHeader(HttpHeaderNames.AUTHORIZATION, authorization); } catch (InvalidKeyException e) { throw new IllegalArgumentException("Failed to compute a valid key from consumer and user secrets", e); } } OAuthSignatureCalculator(ConsumerKey consumerAuth, RequestToken userAuth); @Override void calculateAndAddSignature(Request request, RequestBuilderBase<?> requestBuilder);  }