Package net.oauth.signature
Class OAuthSignatureMethod
- java.lang.Object
-
- net.oauth.signature.OAuthSignatureMethod
-
-
Constructor Summary
Constructors Constructor Description OAuthSignatureMethod()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static Stringbase64Encode(byte[] b)static byte[]decodeBase64(String s)static StringgetBaseString(OAuthMessage message)protected StringgetConsumerSecret()protected abstract StringgetSignature(String baseString)Compute the signature for the given base string.protected StringgetSignature(OAuthMessage message)StringgetTokenSecret()protected voidinitialize(String name, OAuthAccessor accessor)protected abstract booleanisValid(String signature, String baseString)Decide whether the signature is valid.static OAuthSignatureMethodnewMethod(String name, OAuthAccessor accessor)The factory for signature methods.static OAuthSignatureMethodnewSigner(OAuthMessage message, OAuthAccessor accessor)protected static StringnormalizeParameters(Collection<? extends Map.Entry> parameters)protected static StringnormalizeUrl(String url)static voidregisterMethodClass(String name, Class<?> clazz)Subsequently, newMethod(name) will attempt to instantiate the given class, with no constructor parameters.protected voidsetConsumerSecret(String consumerSecret)voidsetTokenSecret(String tokenSecret)voidsign(OAuthMessage message)Add a signature to the message.voidvalidate(OAuthMessage message)Check whether the message has a valid signature.
-
-
-
Field Detail
-
_ACCESSOR
public static final String _ACCESSOR
- See Also:
- Constant Field Values
-
-
Method Detail
-
sign
public void sign(OAuthMessage message) throws OAuthException, IOException, URISyntaxException
Add a signature to the message.
-
validate
public void validate(OAuthMessage message) throws IOException, OAuthException, URISyntaxException
Check whether the message has a valid signature.- Throws:
URISyntaxExceptionOAuthProblemException- the signature is invalidIOExceptionOAuthException
-
getSignature
protected String getSignature(OAuthMessage message) throws OAuthException, IOException, URISyntaxException
-
initialize
protected void initialize(String name, OAuthAccessor accessor) throws OAuthException
- Throws:
OAuthException
-
getSignature
protected abstract String getSignature(String baseString) throws OAuthException
Compute the signature for the given base string.- Throws:
OAuthException
-
isValid
protected abstract boolean isValid(String signature, String baseString) throws OAuthException
Decide whether the signature is valid.- Throws:
OAuthException
-
getConsumerSecret
protected String getConsumerSecret()
-
setConsumerSecret
protected void setConsumerSecret(String consumerSecret)
-
getTokenSecret
public String getTokenSecret()
-
setTokenSecret
public void setTokenSecret(String tokenSecret)
-
getBaseString
public static String getBaseString(OAuthMessage message) throws IOException, URISyntaxException
- Throws:
IOExceptionURISyntaxException
-
normalizeUrl
protected static String normalizeUrl(String url) throws URISyntaxException
- Throws:
URISyntaxException
-
normalizeParameters
protected static String normalizeParameters(Collection<? extends Map.Entry> parameters) throws IOException
- Throws:
IOException
-
decodeBase64
public static byte[] decodeBase64(String s)
-
base64Encode
public static String base64Encode(byte[] b)
-
newSigner
public static OAuthSignatureMethod newSigner(OAuthMessage message, OAuthAccessor accessor) throws IOException, OAuthException
- Throws:
IOExceptionOAuthException
-
newMethod
public static OAuthSignatureMethod newMethod(String name, OAuthAccessor accessor) throws OAuthException
The factory for signature methods.- Throws:
OAuthException
-
-