Package tigase.form
Class SignatureCalculator
java.lang.Object
tigase.form.SignatureCalculator
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSignatureCalculator(String oauthConsumerKey, String oauthConsumerSecret) SignatureCalculator(String oauthToken, String oauthTokenSecret, String oauthConsumerKey, String oauthConsumerSecret) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEmptyFields(Form form) calculateSignature(JID to, Form form) Calculate signature of given form.protected static Stringprotected byte[]h(byte[] data) protected static byte[]booleanisMethodSupported(String fOauthSignatureMethod) protected SecretKeykey(byte[] key) protected StringvoidsetOauthConsumerKey(String oauthConsumerKey) voidsetOauthConsumerSecret(String oauthConsumerSecret) voidsetOauthToken(String oauthToken) voidsetOauthTokenSecret(String oauthTokenSecret) voidSign given Form.voidSign 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:
InvalidKeyExceptionNoSuchAlgorithmException
-
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:
InvalidKeyExceptionNoSuchAlgorithmException
-
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:
InvalidKeyExceptionNoSuchAlgorithmException
-
h
- Throws:
NoSuchAlgorithmException
-
key
-
randomString
-