Class BasicRequestTokenUtils
java.lang.Object
com.digicert.validation.challenges.BasicRequestTokenUtils
Utility class for generating request tokens.
The `RequestTokenUtils` class provides utility methods for generating secure request tokens. The class leverages the BouncyCastle library cryptographic algorithms to generate secure tokens.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
The radix used for encoding the request token.private static final int
The minimum length of the non-timestamp portion of the request token.private static final String
The character used to pad the request token to ensure it meets the minimum length requirement.private final String
The security provider used for cryptographic operations while generating the request token. -
Constructor Summary
ConstructorsConstructorDescriptionConstructor that initializes the security provider. -
Method Summary
Modifier and TypeMethodDescriptiongenerateHash
(String hashingKey, String hashingValue, String salt) Generates a hash using the provided key, value, and salt.generateRequestToken
(BasicRequestTokenData basicRequestTokenData, String salt) Generates a request token using the provided key, value, and salt.private static String
Pads the given string with the specified character up to the specified length.private void
validateInputs
(BasicRequestTokenData basicRequestTokenData, String salt)
-
Field Details
-
REQUEST_TOKEN_PAD_CHAR
The character used to pad the request token to ensure it meets the minimum length requirement.- See Also:
-
REQUEST_TOKEN_CHARSET_RADIX
private static final int REQUEST_TOKEN_CHARSET_RADIXThe radix used for encoding the request token.This constant specifies the base (radix) used for encoding the request token. A radix of 36 is chosen to represent the token in a compact alphanumeric format, which includes digits (0-9) and letters (a-z).
- See Also:
-
REQUEST_TOKEN_MIN_LENGTH
private static final int REQUEST_TOKEN_MIN_LENGTHThe minimum length of the non-timestamp portion of the request token.- See Also:
-
securityProvider
The security provider used for cryptographic operations while generating the request token.
-
-
Constructor Details
-
BasicRequestTokenUtils
public BasicRequestTokenUtils()Constructor that initializes the security provider.
-
-
Method Details
-
generateRequestToken
public Optional<String> generateRequestToken(BasicRequestTokenData basicRequestTokenData, String salt) Generates a request token using the provided key, value, and salt.This method generates a secure request token and ensures it meets length requirements.
- Parameters:
basicRequestTokenData
- the object containing the hashing key and value used for generating the request tokensalt
- the salt used for generating the request token- Returns:
- an `Optional` containing the generated token, or an empty `Optional` if generation fails
-
generateHash
Generates a hash using the provided key, value, and salt.- Parameters:
hashingKey
- the key used for generating the hashhashingValue
- the value used for generating the hashsalt
- the salt used for generating the hash- Returns:
- an `Optional` containing the generated hash, or an empty `Optional` if generation fails
-
padStart
Pads the given string with the specified character up to the specified length.- Parameters:
originalString
- the original string to pad- Returns:
- the padded string
-
validateInputs
-