public class SignatureCalculator extends Object
Modifier and Type | Field and Description |
---|---|
static String |
SUPPORTED_TYPE |
Constructor and Description |
---|
SignatureCalculator() |
SignatureCalculator(String oauthConsumerKey,
String oauthConsumerSecret) |
SignatureCalculator(String oauthToken,
String oauthTokenSecret,
String oauthConsumerKey,
String oauthConsumerSecret) |
Modifier and Type | Method and Description |
---|---|
void |
addEmptyFields(Form form) |
String |
calculateSignature(JID to,
Form form)
Calculate signature of given form.
|
protected static String |
escape(String s) |
String |
getOauthConsumerKey() |
String |
getOauthConsumerSecret() |
String |
getOauthToken() |
String |
getOauthTokenSecret() |
protected byte[] |
h(byte[] data) |
protected static byte[] |
hmac(SecretKey key,
byte[] data) |
boolean |
isMethodSupported(String fOauthSignatureMethod) |
protected SecretKey |
key(byte[] key) |
protected String |
randomString() |
void |
setOauthConsumerKey(String oauthConsumerKey) |
void |
setOauthConsumerSecret(String oauthConsumerSecret) |
void |
setOauthToken(String oauthToken) |
void |
setOauthTokenSecret(String oauthTokenSecret) |
void |
sign(JID to,
Form form)
Sign given form with current time.
|
void |
sign(JID to,
String nonce,
long timestamp,
Form form)
Sign given Form.
|
public static final String SUPPORTED_TYPE
protected static byte[] hmac(SecretKey key, byte[] data) throws NoSuchAlgorithmException, InvalidKeyException
public void addEmptyFields(Form form)
public String calculateSignature(JID to, Form form) throws InvalidKeyException, NoSuchAlgorithmException
to
- the full destination address, including resource, if any.form
- form to sign.InvalidKeyException
NoSuchAlgorithmException
public String getOauthConsumerKey()
public String getOauthConsumerSecret()
public String getOauthToken()
public String getOauthTokenSecret()
protected byte[] h(byte[] data) throws NoSuchAlgorithmException
NoSuchAlgorithmException
public boolean isMethodSupported(String fOauthSignatureMethod)
protected SecretKey key(byte[] key)
protected String randomString()
public void setOauthConsumerKey(String oauthConsumerKey)
oauthConsumerKey
- the oauthConsumerKey to setpublic void setOauthConsumerSecret(String oauthConsumerSecret)
oauthConsumerSecret
- the oauthConsumerSecret to setpublic void setOauthToken(String oauthToken)
oauthToken
- the oauthToken to setpublic void setOauthTokenSecret(String oauthTokenSecret)
oauthTokenSecret
- the oauthTokenSecret to setpublic void sign(JID to, Form form) throws InvalidKeyException, NoSuchAlgorithmException
to
- the full destination address, including resource, if any.form
- form to sign.InvalidKeyException
NoSuchAlgorithmException
public void sign(JID to, String nonce, long timestamp, Form form) throws InvalidKeyException, NoSuchAlgorithmException
to
- the full destination address, including resource, if any.nonce
- A nonce value that the client has to set. Can be a random
alphanumerical string.timestamp
- Number of seconds since 1st of January 1970, 00:00:00 GMT. The
client has to set this at the time of signature.form
- form to sign.InvalidKeyException
NoSuchAlgorithmException
Copyright © 2017 "Tigase, Inc.". All rights reserved.