Class ClientTokenGenerator
java.lang.Object
io.getlime.security.powerauth.crypto.client.token.ClientTokenGenerator
Class that simplifies working with tokens on the client side.
- Author:
- Petr Dvorak, petr@wultra.com
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]computeTokenDigest(byte[] nonce, byte[] timestamp, String version, byte[] tokenSecret) Compute the digest of provided token information using given token secret.byte[]Generate random token nonce, 16 random bytes.byte[]Helper method to get current timestamp for the purpose of token timestamping, encoded as bytes (from string representation).
-
Constructor Details
-
ClientTokenGenerator
public ClientTokenGenerator()
-
-
Method Details
-
generateTokenNonce
Generate random token nonce, 16 random bytes.- Returns:
- Random token nonce.
- Throws:
CryptoProviderException- In case key cryptography provider is incorrectly initialized.
-
generateTokenTimestamp
public byte[] generateTokenTimestamp()Helper method to get current timestamp for the purpose of token timestamping, encoded as bytes (from string representation).- Returns:
- Current timestamp in milliseconds.
-
computeTokenDigest
public byte[] computeTokenDigest(byte[] nonce, byte[] timestamp, String version, byte[] tokenSecret) throws GenericCryptoException, CryptoProviderException Compute the digest of provided token information using given token secret.- Parameters:
nonce- Token nonce, 16 random bytes.timestamp- Token timestamp, Unix timestamp format encoded as bytes (from string representation).version- Protocol version.tokenSecret- Token secret, 16 random bytes.- Returns:
- Token digest computed using provided data bytes with given token secret.
- Throws:
GenericCryptoException- In case digest computation fails.CryptoProviderException- In case cryptography provider is incorrectly initialized.
-