Class EmailValidator
This class implements Validation for the following methods:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DomainNameUtils
Utility class for domain name operations.private EmailProvider
The constructed email provider.private EmailProvider
The DNS TXT provider for email.private EmailProvider
The WhoIs email provider.private final RandomValueGenerator
Utility class for generating random values.private final RandomValueVerifier
Utility class for random value verification. -
Constructor Summary
ConstructorsConstructorDescriptionEmailValidator
(DcvContext dcvContext) Constructor for EmailValidator.EmailValidator
(EmailProvider emailDnsTxtProvider, EmailProvider emailConstructedProvider, EmailProvider emailWhoIsProvider) Unit Testing Constructor for EmailValidator. -
Method Summary
Modifier and TypeMethodDescriptionprivate EmailProvider
findEmailGenerator
(EmailSource emailSource) Finds the appropriate email provider based on the email source.prepare
(EmailPreparation emailPreparation) This will attempt to fetch or build email addresses for the domain based onEmailPreparation.emailSource()
.validate
(EmailValidationRequest request) Performs validation on the values inEmailValidationRequest
.private void
-
Field Details
-
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
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
The WhoIs email provider.This provider fetches email addresses from WHOIS data. It is used when the email source is specified as WHOIS.
-
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
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
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
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 provideremailConstructedProvider
- The constructed email provideremailWhoIsProvider
- The WhoIs email provider
-
-
Method Details
-
prepare
This will attempt to fetch or build email addresses for the domain based onEmailPreparation.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 inEmailValidationRequest
. 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
- Throws:
DcvException
-
findEmailGenerator
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
-