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> 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 void sign(OAuthMessage message) throws OAuthException, IOException, URISyntaxException
public void validate(OAuthMessage message) throws IOException, OAuthException, URISyntaxException
URISyntaxException
OAuthProblemException
- the signature is invalidIOException
OAuthException
protected String getSignature(OAuthMessage message) throws OAuthException, IOException, URISyntaxException
protected void initialize(String name, OAuthAccessor accessor) throws OAuthException
OAuthException
protected abstract String getSignature(String baseString) throws OAuthException
OAuthException
protected abstract boolean isValid(String signature, String baseString) throws OAuthException
OAuthException
protected String getConsumerSecret()
protected void setConsumerSecret(String consumerSecret)
public String getTokenSecret()
public void setTokenSecret(String tokenSecret)
public static String getBaseString(OAuthMessage message) throws IOException, URISyntaxException
IOException
URISyntaxException
protected static String normalizeUrl(String url) throws URISyntaxException
URISyntaxException
protected static String normalizeParameters(Collection<? extends Map.Entry> parameters) throws IOException
IOException
public static boolean equals(String x, String y)
public static boolean equals(byte[] a, byte[] b)
public static byte[] decodeBase64(String s)
public static String base64Encode(byte[] b)
public static OAuthSignatureMethod newSigner(OAuthMessage message, OAuthAccessor accessor) throws IOException, OAuthException
IOException
OAuthException
public static OAuthSignatureMethod newMethod(String name, OAuthAccessor accessor) throws OAuthException
OAuthException
public static void registerMethodClass(String name, Class clazz)
public static void unregisterMethod(String name)
Copyright © 2023. All rights reserved.