Package tigase.form
Class SignatureCalculator
java.lang.Object
tigase.form.SignatureCalculator
-
Field Summary
-
Constructor Summary
ConstructorDescriptionSignatureCalculator
(String oauthConsumerKey, String oauthConsumerSecret) SignatureCalculator
(String oauthToken, String oauthTokenSecret, String oauthConsumerKey, String oauthConsumerSecret) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addEmptyFields
(Form form) calculateSignature
(JID to, Form form) Calculate signature of given form.protected static String
protected byte[]
h
(byte[] data) protected static byte[]
boolean
isMethodSupported
(String fOauthSignatureMethod) protected SecretKey
key
(byte[] key) protected String
void
setOauthConsumerKey
(String oauthConsumerKey) void
setOauthConsumerSecret
(String oauthConsumerSecret) void
setOauthToken
(String oauthToken) void
setOauthTokenSecret
(String oauthTokenSecret) void
Sign given Form.void
Sign given form with current time.
-
Field Details
-
SUPPORTED_TYPE
- See Also:
-
-
Constructor Details
-
SignatureCalculator
public SignatureCalculator() -
SignatureCalculator
-
SignatureCalculator
-
-
Method Details
-
escape
-
hmac
protected static byte[] hmac(SecretKey key, byte[] data) throws NoSuchAlgorithmException, InvalidKeyException -
addEmptyFields
-
calculateSignature
public String calculateSignature(JID to, Form form) throws InvalidKeyException, NoSuchAlgorithmException Calculate signature of given form. Form will not be changed.- Parameters:
to
- the full destination address, including resource, if any.form
- form to sign.- Returns:
- Signature of form.
- Throws:
InvalidKeyException
NoSuchAlgorithmException
-
getOauthConsumerKey
- Returns:
- the oauthConsumerKey
-
setOauthConsumerKey
- Parameters:
oauthConsumerKey
- the oauthConsumerKey to set
-
getOauthConsumerSecret
- Returns:
- the oauthConsumerSecret
-
setOauthConsumerSecret
- Parameters:
oauthConsumerSecret
- the oauthConsumerSecret to set
-
getOauthToken
- Returns:
- the oauthToken
-
setOauthToken
- Parameters:
oauthToken
- the oauthToken to set
-
getOauthTokenSecret
- Returns:
- the oauthTokenSecret
-
setOauthTokenSecret
- Parameters:
oauthTokenSecret
- the oauthTokenSecret to set
-
isMethodSupported
-
sign
Sign given form with current time. Signature will be added to form.- Parameters:
to
- the full destination address, including resource, if any.form
- form to sign.- Throws:
InvalidKeyException
NoSuchAlgorithmException
-
sign
public void sign(JID to, String nonce, long timestamp, Form form) throws InvalidKeyException, NoSuchAlgorithmException Sign given Form. Signature will be added to form.- Parameters:
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.- Throws:
InvalidKeyException
NoSuchAlgorithmException
-
h
- Throws:
NoSuchAlgorithmException
-
key
-
randomString
-