org.glassfish.jersey.oauth1.signature
Class OAuth1Signature

java.lang.Object
  extended by org.glassfish.jersey.oauth1.signature.OAuth1Signature

public class OAuth1Signature
extends Object

Injectable class used for processing an OAuth signature (signing or verifying).

Example of usage:

 // inject the OAuth1Signature
 @Inject
 OAuth1Signature oAuthSignature;
 ...

 // wrap an existing request with some concrete implementation
 OAuth1Request request = new ConcreteOAuthRequestImplementation();

 // establish the parameters that will be used to sign the request
 OAuth1Parameters params = new OAuth1Parameters().consumerKey("dpf43f3p2l4k3l03").
  token("nnch734d00sl2jdk").signatureMethod(HmaSha1Method.NAME).
  timestamp().nonce().version();

 // establish the secrets that will be used to sign the request
 OAuth1Secrets secrets = new OAuth1Secrets().consumerSecret("kd94hf93k423kf44").
  tokenSecret("pfkkdhi9sl3r4s00");

 // generate the digital signature and set in the request
 oAuthSignature.sign(request, params, secrets);
 

Author:
Hubert A. Le Van Gong , Paul C. Bryan

Constructor Summary
OAuth1Signature(org.glassfish.hk2.api.ServiceLocator serviceLocator)
          Create a new instance of the OAuth signature configured with injected ServiceLocator.
 
Method Summary
 String generate(OAuth1Request request, OAuth1Parameters params, OAuth1Secrets secrets)
          Generates and returns an OAuth signature for the given request, parameters and secrets.
 void sign(OAuth1Request request, OAuth1Parameters params, OAuth1Secrets secrets)
          Generates an OAuth signature for the given request, parameters and secrets, and stores it as a signature parameter, and writes the OAuth parameters to the request as an Authorization header.
 boolean verify(OAuth1Request request, OAuth1Parameters params, OAuth1Secrets secrets)
          Verifies the OAuth signature for a given request, parameters and secrets.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OAuth1Signature

@Inject
public OAuth1Signature(org.glassfish.hk2.api.ServiceLocator serviceLocator)
Create a new instance of the OAuth signature configured with injected ServiceLocator.

Parameters:
serviceLocator - Service locator (injected by HK2)/
Method Detail

generate

public String generate(OAuth1Request request,
                       OAuth1Parameters params,
                       OAuth1Secrets secrets)
                throws OAuth1SignatureException
Generates and returns an OAuth signature for the given request, parameters and secrets.

Parameters:
request - the request to generate signature for.
params - the OAuth authorization parameters.
secrets - the secrets used to generate the OAuth signature.
Returns:
the OAuth digital signature.
Throws:
OAuth1SignatureException - if an error occurred generating the signature.

sign

public void sign(OAuth1Request request,
                 OAuth1Parameters params,
                 OAuth1Secrets secrets)
          throws OAuth1SignatureException
Generates an OAuth signature for the given request, parameters and secrets, and stores it as a signature parameter, and writes the OAuth parameters to the request as an Authorization header.

Parameters:
request - the request to generate signature for and write header to.
params - the OAuth authorization parameters.
secrets - the secrets used to generate the OAuth signature.
Throws:
OAuth1SignatureException - if an error occurred generating the signature.

verify

public boolean verify(OAuth1Request request,
                      OAuth1Parameters params,
                      OAuth1Secrets secrets)
               throws OAuth1SignatureException
Verifies the OAuth signature for a given request, parameters and secrets.

Parameters:
request - the request to verify the signature from.
params - the OAuth authorization parameters
secrets - the secrets used to verify the OAuth signature.
Returns:
true if the signature is verified.
Throws:
OAuth1SignatureException - if an error occurred generating the signature.


Copyright © 2007-2013, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.