Class DnsValidationHandler
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final StringThe DNS domain label used for validation.(package private) final MpicDnsServiceThe MPIC service used to fetch DNS details.(package private) final RandomValueValidatorThe random value validator used to confirm that a DNS record contains the expected random value.(package private) final RequestTokenValidatorThe request token validator used to confirm that a DNS record contains a valid request token. -
Constructor Summary
ConstructorsConstructorDescriptionDnsValidationHandler(DcvContext dcvContext) Constructs a new DnsValidationHandler with the specified configuration. -
Method Summary
Modifier and TypeMethodDescription(package private) DnsValidationResponsebuildDnsValidationResponse(String domain, ChallengeValidationResponse challengeValidationResponse, MpicDnsDetails mpicDnsDetails, DnsType dnsType, ChallengeType challengeType) Builds a DNS validation response based on the provided parameters.private ChallengeValidationResponsegetChallengeValidationResponse(DnsValidationRequest request, MpicDnsDetails mpicDnsDetails) validate(DnsValidationRequest request) Validates the DNS records based on the provided request.private ChallengeValidationResponsevalidateRandomValue(List<String> recordValues, DnsValidationRequest request) Validates the DNS records against the supplied random value.private ChallengeValidationResponsevalidateRequestToken(List<String> recordValues, DnsValidationRequest request) Validates the DNS records for the presence of a valid request token.
-
Field Details
-
dnsDomainLabel
The DNS domain label used for validation. -
randomValueValidator
The random value validator used to confirm that a DNS record contains the expected random value. -
requestTokenValidator
The request token validator used to confirm that a DNS record contains a valid request token. -
mpicDnsService
The MPIC service used to fetch DNS details.
-
-
Constructor Details
-
DnsValidationHandler
Constructs a new DnsValidationHandler with the specified configuration.- Parameters:
dcvContext- context where we can find the necessary dependencies / configuration
-
-
Method Details
-
validate
Validates the DNS records based on the provided request.This method performs the DNS validation process based on the given DNS validation request. It fetches the DNS data using the DNS client, validates the DNS records against the provided challenge type, and builds a DNS validation response.
- Parameters:
request- the DNS validation request- Returns:
- the DNS validation response
-
getChallengeValidationResponse
private ChallengeValidationResponse getChallengeValidationResponse(DnsValidationRequest request, MpicDnsDetails mpicDnsDetails) -
validateRandomValue
private ChallengeValidationResponse validateRandomValue(List<String> recordValues, DnsValidationRequest request) Validates the DNS records against the supplied random value.This method validates the DNS records found against the random value provided in the DNS validation request. It iterates through the DNS record values and uses the RandomValueValidator to check if any of the record values match the random value. If a match is found, the ChallengeValidationResponse returned will contain the random value; otherwise, it will contain all the errors found while attempting validation.
- Parameters:
recordValues- the values of the DNS recordsrequest- the DNS validation request- Returns:
- the
RandomValueValidatorresponse
-
validateRequestToken
private ChallengeValidationResponse validateRequestToken(List<String> recordValues, DnsValidationRequest request) Validates the DNS records for the presence of a valid request token.This method iterates through the DNS record values and uses the
RequestTokenValidatorwith the supplied request token data to check if any of the record values contains a valid request token. If a valid request token is found, the ChallengeValidationResponse returned will contain that valid token; otherwise it will contain all the errors found while attempting validation.- Parameters:
recordValues- the values of the DNS recordsrequest- the DNS validation request- Returns:
- a
ChallengeValidationResponsecontaining the first valid request token found or all errors that occurred during the DNS lookups.
-
buildDnsValidationResponse
DnsValidationResponse buildDnsValidationResponse(String domain, ChallengeValidationResponse challengeValidationResponse, MpicDnsDetails mpicDnsDetails, DnsType dnsType, ChallengeType challengeType) Builds a DNS validation response based on the provided parameters.This method constructs a DnsValidationResponse object based on the challenge validator response, DNS data, DNS type, and challenge type. It places the challenge value in the correct place based on the challenge type and includes any errors encountered during the validation process.
- Parameters:
domain-challengeValidationResponse- the token validator responsempicDnsDetails- the DNS datadnsType- the DNS type (CNAME, TXT, or CAA)challengeType- the challenge type (RANDOM_VALUE or REQUEST_TOKEN)- Returns:
- the DNS validation response
-