OAuthParameters params = new OAuthParameters().signatureMethod("HMAC-SHA1"). consumerKey("consumerKey").version("1.1"); OAuthSecrets secrets = new OAuthSecrets().consumerSecret("secretKey"); OAuthClientFilter filter = new OAuthClientFilter(client().getProviders(), params, secrets); WebResource webResource = resource(); webResource.addFilter(filter); String responseMsg = webResource.path("oauth").get(String.class);
@Path("oauth") public class OAuthService { @GET @Produces("text/html") public String secretService(@Context HttpContext httpContext) { OAuthServerRequest request = new OAuthServerRequest(httpContext.getRequest()); OAuthParameters params = new OAuthParameters(); params.readRequest(request); OAuthSecrets secrets = new OAuthSecrets().consumerSecret("secretKey"); try { if(!OAuthSignature.verify(request, params, secrets)) return "false"; } catch (OAuthSignatureException ose) { return "false"; } return "OK"; } }
private void postConstruct() { OAuthHmacSigner signer = new OAuthHmacSigner(); signer.clientSharedSecret = sharedSecret; signer.tokenSharedSecret = tokenSharedSecret; authorizer = new OAuthParameters(); authorizer.consumerKey = consumerKey; authorizer.signer = signer; authorizer.token = token; }
private void postConstruct() { OAuthHmacSigner signer = new OAuthHmacSigner(); signer.clientSharedSecret = sharedSecret; signer.tokenSharedSecret = tokenSharedSecret; authorizer = new OAuthParameters(); authorizer.consumerKey = consumerKey; authorizer.signer = signer; authorizer.token = token; }
public class OAuthAuthenticationFilter implements ContainerRequestFilter { @Override public ContainerRequest filter(ContainerRequest containerRequest) { // Read the OAuth parameters from the request OAuthServerRequest request = new OAuthServerRequest(containerRequest); OAuthParameters params = new OAuthParameters(); params.readRequest(request); // Set the secret(s), against which we will verify the request OAuthSecrets secrets = new OAuthSecrets(); // ... secret setting code ... // Check that the timestamp has not expired String timestampStr = params.getTimestamp(); // ... timestamp checking code ... // Verify the signature try { if(!OAuthSignature.verify(request, params, secrets)) { throw new WebApplicationException(401); } } catch (OAuthSignatureException e) { throw new WebApplicationException(e, 401); } // Return the request return containerRequest; } }
OAuthSecrets secrets = new OAuthSecrets() .consumerSecret(consumerSecret); OAuthParameters authParams = new OAuthParameters() .consumerKey(consumerKey).signatureMethod(HMAC_SHA1.NAME) .version(AuthenticationConstants.OAUTH_VERSION_10A)
OAuthParameters oauthParameters = new OAuthParameters(); signer.tokenSharedSecret = accessTokenResponse.tokenSecret; oauthParameters.signer = signer;
OAuthHmacSigner signer = new OAuthHmacSigner(); HttpTransport httpTransport = new NetHttpTransport(); OAuthParameters oauthParameters = new OAuthParameters(); final ArrayMap<String, Object> customKeys = new ArrayMap<String, Object>();
Providers providers = this.client.getProviders(); OAuthSecrets secrets = new OAuthSecrets().consumerSecret(oAuthConsumerSecret); OAuthParameters params = new OAuthParameters().consumerKey(oAuthConsumerKey).signatureMethod("HMAC-SHA1"); OAuthClientFilter filter = new OAuthClientFilter(providers,params,secrets);
OAuthParameters oauthParameters; try { oauthParameters = new OAuthParameters(); oauthParameters.consumerKey = clientId; oauthParameters.signer =