Package com.atlassian.security.random
Class DefaultSecureTokenGenerator
java.lang.Object
com.atlassian.security.random.DefaultSecureTokenGenerator
- All Implemented Interfaces:
SecureTokenGenerator
Implementation of
SecureTokenGenerator which uses the DefaultSecureRandomService
for random byte generation.-
Method Summary
Modifier and TypeMethodDescriptionGenerates a base64Stringrepresentation of 20 random bytes, produced byDefaultSecureRandomService.nextBytes(byte[]).Generates a hexadecimalStringrepresentation of 20 random bytes, produced byDefaultSecureRandomService.nextBytes(byte[]).static SecureTokenGenerator
-
Method Details
-
getInstance
- Returns:
- shared
DefaultSecureTokenGeneratorinstance.
-
generateToken
Generates a hexadecimalStringrepresentation of 20 random bytes, produced byDefaultSecureRandomService.nextBytes(byte[]). The generatedStringis 40 characters in length and is composed of characters in the range '0'-'9' and 'a'-'f'. The length (20 bytes / 160 bits) was selected as it is the same as the size of the internal state of the SHA1PRNG.- Specified by:
generateTokenin interfaceSecureTokenGenerator- Returns:
- returns a hexadecimal encoded representation of 20 random bytes.
- See Also:
-
generateNonce
Generates a base64Stringrepresentation of 20 random bytes, produced byDefaultSecureRandomService.nextBytes(byte[]). The length (20 bytes / 160 bits) was selected as it is the same as the size of the internal state of the SHA1PRNG.- Specified by:
generateNoncein interfaceSecureTokenGenerator- Returns:
- returns a base64 encoded representation of 20 random bytes.
-