com.sun.jersey.oauth.signature
Class OAuthSignature

java.lang.Object
  extended by com.sun.jersey.oauth.signature.OAuthSignature

public class OAuthSignature
extends Object

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

Example of usage:

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

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

 // establish the secrets that will be used to sign the request
 OAuthSecrets secrets = new OAuthSecrets().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
OAuthSignature()
           
 
Method Summary
static String generate(OAuthRequest request, OAuthParameters params, OAuthSecrets secrets)
          Generates and returns an OAuth signature for the given request, parameters and secrets.
static void sign(OAuthRequest request, OAuthParameters params, OAuthSecrets 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.
static boolean verify(OAuthRequest request, OAuthParameters params, OAuthSecrets 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

OAuthSignature

public OAuthSignature()
Method Detail

generate

public static String generate(OAuthRequest request,
                              OAuthParameters params,
                              OAuthSecrets secrets)
                       throws OAuthSignatureException
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:
OAuthSignatureException - if an error occurred generating the signature.

sign

public static void sign(OAuthRequest request,
                        OAuthParameters params,
                        OAuthSecrets secrets)
                 throws OAuthSignatureException
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:
OAuthSignatureException - if an error occurred generating the signature.

verify

public static boolean verify(OAuthRequest request,
                             OAuthParameters params,
                             OAuthSecrets secrets)
                      throws OAuthSignatureException
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:
OAuthSignatureException - if an error occurred generating the signature.


Copyright © 2013 Oracle Corporation. All Rights Reserved.