Class EmailValidator

java.lang.Object
com.digicert.validation.methods.email.EmailValidator

public class EmailValidator extends Object
The EmailValidator class is responsible for preparing and validating email addresses for DCV (Domain Control Validation). This class handles the preparation of email addresses by fetching or constructing them based on the specified email source. It also validates the random values associated with these email addresses to ensure they meet the required entropy and expiration criteria. Sending emails and using emails to validate domain control is beyond the scope of this library.

This class implements Validation for the following methods:

  • Field Details

    • emailDnsTxtProvider

      private EmailProvider emailDnsTxtProvider
      The DNS TXT provider for email.

      This provider is responsible for fetching email addresses from DNS TXT records. It is used when the email source is specified as DNS_TXT. The DNS TXT records contain text information associated with a domain, which can include email addresses used for domain validation.

    • emailConstructedProvider

      private EmailProvider emailConstructedProvider
      The constructed email provider.

      This provider constructs email addresses based on predefined patterns or rules. It is used when the email source is specified as CONSTRUCTED.

    • emailWhoIsProvider

      private EmailProvider emailWhoIsProvider
      The WhoIs email provider.

      This provider fetches email addresses from WHOIS data. It is used when the email source is specified as WHOIS.

    • randomValueGenerator

      private final RandomValueGenerator randomValueGenerator
      Utility class for generating random values.

      This utility is used to generate random strings that are appended to email addresses to ensure uniqueness. The random values are required by the Baseline Requirements (BRs) to be unique for each email address used in domain validation.

    • randomValueVerifier

      private final RandomValueVerifier randomValueVerifier
      Utility class for random value verification.

      This utility is used to verify the entropy and expiration of random values associated with email addresses. It ensures that the random values meet the required security standards and have not expired before they are used for domain validation.

    • domainNameUtils

      private final DomainNameUtils domainNameUtils
      Utility class for domain name operations.

      This utility provides methods for validating and manipulating domain names. It ensures that domain names are in the correct format and meet the necessary criteria before they are used in email preparation and validation processes.

  • Constructor Details

    • EmailValidator

      public EmailValidator(DcvContext dcvContext)
      Constructor for EmailValidator.

      This constructor initializes the EmailValidator with the necessary dependencies and configuration provided by the DcvContext. It sets up the email providers and utility classes required for email preparation and validation.

      Parameters:
      dcvContext - context where we can find the needed dependencies and configuration
    • EmailValidator

      EmailValidator(EmailProvider emailDnsTxtProvider, EmailProvider emailConstructedProvider, EmailProvider emailWhoIsProvider)
      Unit Testing Constructor for EmailValidator.

      This constructor is used for unit testing purposes. It allows the injection of mock or test implementations of the email providers, enabling isolated testing of the EmailValidator class without relying on the actual DcvContext.

      Parameters:
      emailDnsTxtProvider - The DNS TXT provider
      emailConstructedProvider - The constructed email provider
      emailWhoIsProvider - The WhoIs email provider
  • Method Details

    • prepare

      public EmailPreparationResponse prepare(EmailPreparation emailPreparation) throws DcvException
      This will attempt to fetch or build email addresses for the domain based on EmailPreparation.emailSource().

      This method prepares email addresses by fetching them from the specified email source or constructing them based on the email source. It validates the domain name and ensures that each email address has a unique random value as required by the Baseline Requirements (BRs). The prepared email addresses and their associated random values are returned in the EmailPreparationResponse.

      Parameters:
      emailPreparation - The email preparation request
      Returns:
      The email preparation response
      Throws:
      DcvException - If an error occurs during email preparation
    • validate

      Performs validation on the values in EmailValidationRequest. This does not verify validity of email addresses, send emails or acknowledge any email-based interaction by end-users.

      This method validates the random values associated with email addresses to ensure they meet the required entropy and expiration criteria. It does not verify the validity of the email addresses themselves, nor does it handle sending emails or acknowledging email-based interactions. The method checks the entropy level of the random value and verifies that it has not expired before returning the domain validation evidence.

      Parameters:
      request - The email validation verification request
      Returns:
      The domain validation evidence
      Throws:
      DcvException - If entropy level is insufficient. If the random value has expired.
    • verifyEmailValidationRequest

      private void verifyEmailValidationRequest(EmailValidationRequest request) throws DcvException
      Throws:
      DcvException
    • findEmailGenerator

      private EmailProvider findEmailGenerator(EmailSource emailSource)
      Finds the appropriate email provider based on the email source.

      This method selects the appropriate email provider based on the specified email source. It uses a switch statement to handle different email sources and returns the corresponding email provider.

      Parameters:
      emailSource - The email source
      Returns:
      The email provider