Class BasicRequestTokenUtils

java.lang.Object
com.digicert.validation.challenges.BasicRequestTokenUtils

public class BasicRequestTokenUtils extends Object
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 Details

    • REQUEST_TOKEN_PAD_CHAR

      private static final String 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_RADIX
      The 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_LENGTH
      The minimum length of the non-timestamp portion of the request token.
      See Also:
    • securityProvider

      private final String 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 token
      salt - the salt used for generating the request token
      Returns:
      an `Optional` containing the generated token, or an empty `Optional` if generation fails
    • generateHash

      private Optional<String> generateHash(String hashingKey, String hashingValue, String salt)
      Generates a hash using the provided key, value, and salt.
      Parameters:
      hashingKey - the key used for generating the hash
      hashingValue - the value used for generating the hash
      salt - the salt used for generating the hash
      Returns:
      an `Optional` containing the generated hash, or an empty `Optional` if generation fails
    • padStart

      private static String padStart(String originalString)
      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

      private void validateInputs(BasicRequestTokenData basicRequestTokenData, String salt)