SignatureCalculator

public class SignatureCalculator

Fields

SUPPORTED_TYPE

public static final String SUPPORTED_TYPE

Constructors

SignatureCalculator

public SignatureCalculator()

SignatureCalculator

public SignatureCalculator(String oauthConsumerKey, String oauthConsumerSecret)

SignatureCalculator

public SignatureCalculator(String oauthToken, String oauthTokenSecret, String oauthConsumerKey, String oauthConsumerSecret)

Methods

addEmptyFields

public void addEmptyFields(Form form)

calculateSignature

public String calculateSignature(JID to, Form form)

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.

escape

protected static String escape(String s)

getOauthConsumerKey

public String getOauthConsumerKey()
Returns:the oauthConsumerKey

getOauthConsumerSecret

public String getOauthConsumerSecret()
Returns:the oauthConsumerSecret

getOauthToken

public String getOauthToken()
Returns:the oauthToken

getOauthTokenSecret

public String getOauthTokenSecret()
Returns:the oauthTokenSecret

h

protected byte[] h(byte[] data)

hmac

protected static byte[] hmac(SecretKey key, byte[] data)

isMethodSupported

public boolean isMethodSupported(String fOauthSignatureMethod)

key

protected SecretKey key(byte[] key)

randomString

protected String randomString()

setOauthConsumerKey

public void setOauthConsumerKey(String oauthConsumerKey)
Parameters:
  • oauthConsumerKey – the oauthConsumerKey to set

setOauthConsumerSecret

public void setOauthConsumerSecret(String oauthConsumerSecret)
Parameters:
  • oauthConsumerSecret – the oauthConsumerSecret to set

setOauthToken

public void setOauthToken(String oauthToken)
Parameters:
  • oauthToken – the oauthToken to set

setOauthTokenSecret

public void setOauthTokenSecret(String oauthTokenSecret)
Parameters:
  • oauthTokenSecret – the oauthTokenSecret to set

sign

public void sign(JID to, Form form)

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.

sign

public void sign(JID to, String nonce, long timestamp, Form form)

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.