Class DnsValidationHandler
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final DnsClient
The DNS client used to fetch DNS data.(package private) final String
The DNS domain label used for validation.(package private) final RandomValueValidator
The random value validator used to confirm that a DNS record contains the expected random value.(package private) final RequestTokenValidator
The 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) DnsValidationResponse
buildDnsValidationResponse
(ChallengeValidationResponse challengeValidationResponse, DnsData dnsData, DnsType dnsType, ChallengeType challengeType) Builds a DNS validation response based on the provided parameters.(package private) String
getDnsRecordStringValue
(org.xbill.DNS.Record dnsRecord, DnsType type) Retrieves the string value of a DNS record based on its type.validate
(DnsValidationRequest request) Validates the DNS records based on the provided request.private ChallengeValidationResponse
validateRandomValue
(List<String> recordValues, DnsValidationRequest request) Validates the DNS records against the supplied random value.private ChallengeValidationResponse
validateRequestToken
(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. -
dnsClient
The DNS client used to fetch DNS data.
-
-
Constructor Details
-
DnsValidationHandler
Constructs a new DnsValidationHandler with the specified configuration.- Parameters:
dcvContext
- context where we can find the needed 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
-
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
RandomValueValidator
response
-
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
RequestTokenValidator
with 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
ChallengeValidationResponse
containing the first valid request token found or all errors that occurred during the DNS lookups.
-
buildDnsValidationResponse
DnsValidationResponse buildDnsValidationResponse(ChallengeValidationResponse challengeValidationResponse, DnsData dnsData, 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:
challengeValidationResponse
- the token validator responsednsData
- the DNS datadnsType
- the DNS type (CNAME, TXT, or CAA)challengeType
- the challenge type (RANDOM_VALUE or REQUEST_TOKEN)- Returns:
- the DNS validation response
-
getDnsRecordStringValue
Retrieves the string value of a DNS record based on its type.This method extracts the string value from a DNS record based on the specified DNS type. It supports different types of DNS records, such as CNAME, TXT, and CAA, and returns the corresponding string representation of the record value.
- Parameters:
dnsRecord
- the DNS recordtype
- the type of DNS record- Returns:
- the string value of the DNS record
-