Class DcvContext

java.lang.Object
com.digicert.validation.DcvContext

public class DcvContext extends Object
The DcvContext provides dependency injection, allowing for easier testing of the various pieces of the library. It initializes and holds references to various classes used throughout the application. It is possible to have multiple contexts side by side with different configuration.
  • Field Details

    • dcvConfiguration

      private final DcvConfiguration dcvConfiguration
      The DCV Configuration used by the context.
    • instances

      private final HashMap<Class<?>,Object> instances
      A map of instances that have been created by the context.
    • lazyLoadImplementations

      private final Map<Class<?>,Class<?>> lazyLoadImplementations
      This map is used for basic implementations of interfaces to only load if no custom implementation is provided.

      When the BasicRequestTokenValidator class is instantiated, it also instantiates a BasicRequestTokenUtils instance. That utils class requires a BouncyCastleProvider to be added as a security provider. By lazily loading the validator, users of this library can avoid adding the BouncyCastleProvider as a security provider if they provide their own implementation of the RequestTokenValidator interface.

  • Constructor Details

    • DcvContext

      public DcvContext()
      Default constructor that initializes the context with a default DCV Configuration.
    • DcvContext

      public DcvContext(DcvConfiguration dcvConfiguration)
      Constructor that initializes the context with the provided DCV Configuration.
      Parameters:
      dcvConfiguration - the DCV Configuration to use
  • Method Details

    • get

      public <T> T get(Class<T> classType)
      Retrieves an instance of the specified class. If an instance already exists, it returns the cached instance. If the class is found in the DCV Configuration, it caches and returns it. Otherwise, it instantiates the class, caches it, and returns it.
      Type Parameters:
      T - the type of the class
      Parameters:
      classType - the class to retrieve or instantiate
      Returns:
      an instance of the specified class
      Throws:
      RuntimeException - if the class cannot be instantiated