public abstract class OAuthSignatureMethod extends Object
Static methods of this class implement a registry of signature methods. It's pre-populated with the standard OAuth algorithms. Appliations can replace them or add new ones.
Constructor and Description |
---|
OAuthSignatureMethod() |
Modifier and Type | Method and Description |
---|---|
static String |
base64Encode(byte[] b) |
static byte[] |
decodeBase64(String s) |
static boolean |
equals(byte[] a,
byte[] b)
Determine whether the given arrays contain the same sequence of bytes.
|
static boolean |
equals(String x,
String y)
Determine whether the given strings contain the same sequence of
characters.
|
static String |
getBaseString(OAuthMessage message) |
protected String |
getConsumerSecret() |
protected String |
getSignature(OAuthMessage message) |
protected abstract String |
getSignature(String baseString)
Compute the signature for the given base string.
|
String |
getTokenSecret() |
protected void |
initialize(String name,
OAuthAccessor accessor) |
protected abstract boolean |
isValid(String signature,
String baseString)
Decide whether the signature is valid.
|
static OAuthSignatureMethod |
newMethod(String name,
OAuthAccessor accessor)
The factory for signature methods.
|
static OAuthSignatureMethod |
newSigner(OAuthMessage message,
OAuthAccessor accessor) |
protected static String |
normalizeParameters(Collection<? extends Map.Entry<String,String>> parameters) |
protected static String |
normalizeUrl(String url) |
static void |
registerMethodClass(String name,
Class<?> clazz)
Subsequently, newMethod(name) will attempt to instantiate the given class,
with no constructor parameters.
|
protected void |
setConsumerSecret(String consumerSecret) |
void |
setTokenSecret(String tokenSecret) |
void |
sign(OAuthMessage message)
Add a signature to the message.
|
static void |
unregisterMethod(String name)
Subsequently, newMethod(name) will fail.
|
void |
validate(OAuthMessage message)
Check whether the message has a valid signature.
|
public static final String _ACCESSOR
public static String base64Encode(byte[] b)
public static byte[] decodeBase64(String s)
public static boolean equals(byte[] a, byte[] b)
public static boolean equals(String x, String y)
public static String getBaseString(OAuthMessage message) throws IOException, URISyntaxException
IOException
URISyntaxException
public static OAuthSignatureMethod newMethod(String name, OAuthAccessor accessor) throws OAuthException
OAuthException
public static OAuthSignatureMethod newSigner(OAuthMessage message, OAuthAccessor accessor) throws IOException, OAuthException
IOException
OAuthException
protected static String normalizeParameters(Collection<? extends Map.Entry<String,String>> parameters) throws IOException
IOException
protected static String normalizeUrl(String url) throws URISyntaxException
URISyntaxException
public static void registerMethodClass(String name, Class<?> clazz)
public static void unregisterMethod(String name)
protected String getConsumerSecret()
protected String getSignature(OAuthMessage message) throws OAuthException, IOException, URISyntaxException
protected abstract String getSignature(String baseString) throws OAuthException
OAuthException
public String getTokenSecret()
protected void initialize(String name, OAuthAccessor accessor) throws OAuthException
OAuthException
protected abstract boolean isValid(String signature, String baseString) throws OAuthException
OAuthException
protected void setConsumerSecret(String consumerSecret)
public void setTokenSecret(String tokenSecret)
public void sign(OAuthMessage message) throws OAuthException, IOException, URISyntaxException
public void validate(OAuthMessage message) throws IOException, OAuthException, URISyntaxException
URISyntaxException
OAuthProblemException
- the signature is invalidIOException
OAuthException
Copyright © 2008–2017 Province of British Columbia. All rights reserved.