Class BasicRandomValueGenerator

java.lang.Object
com.digicert.validation.random.BasicRandomValueGenerator
All Implemented Interfaces:
RandomValueGenerator

public class BasicRandomValueGenerator extends Object implements RandomValueGenerator
A basic implementation of the RandomValueGenerator interface that generates random alphanumeric strings. This class uses a secure random number generator to produce random strings composed of alphanumeric characters. It is designed to provide a simple and effective way to generate random values for various purposes, such as tokens, passwords, or other unique identifiers. The generated strings are of a fixed length and are created using a specified character set.
  • Field Details

    • ALPHANUMERIC_CHARSET

      private static final String ALPHANUMERIC_CHARSET
      The charset used for generating random strings.

      This string contains all the alphanumeric characters (digits 0-9, lowercase letters a-z, and uppercase letters A-Z). It serves as the pool of characters from which the random string will be generated.

      See Also:
  • Constructor Details

    • BasicRandomValueGenerator

      public BasicRandomValueGenerator()
      Default constructor for BasicRandomValueGenerator.
  • Method Details

    • getCharset

      public String getCharset()
      Returns the charset used for generating random strings.
      Specified by:
      getCharset in interface RandomValueGenerator
      Returns:
      A string representing the alphanumeric charset.
    • generateRandomString

      public String generateRandomString()
      Generates a random alphanumeric string of length 32.

      This method creates a random string composed of characters from the alphanumeric charset. The length of the generated string is fixed at 32 characters.

      Specified by:
      generateRandomString in interface RandomValueGenerator
      Returns:
      A randomly generated alphanumeric string.
    • generateString

      private String generateString(String charset, int length)
      Generates a random string of the specified length using the given charset.

      This method takes a charset and a length as parameters and produces a random string of the specified length. It uses a secure random number generator to select characters from the charset and build the string.

      Parameters:
      charset - The charset to use for generating the random string.
      length - The length of the random string to generate.
      Returns:
      A randomly generated string.