Class DnsValidationHandler

java.lang.Object
com.digicert.validation.methods.dns.validate.DnsValidationHandler

public class DnsValidationHandler extends Object
Handles DNS validation processes.
  • Field Details

    • dnsDomainLabel

      final String dnsDomainLabel
      The DNS domain label used for validation.
    • randomValueValidator

      final RandomValueValidator randomValueValidator
      The random value validator used to confirm that a DNS record contains the expected random value.
    • requestTokenValidator

      final RequestTokenValidator requestTokenValidator
      The request token validator used to confirm that a DNS record contains a valid request token.
    • dnsClient

      final DnsClient dnsClient
      The DNS client used to fetch DNS data.
  • Constructor Details

    • DnsValidationHandler

      public DnsValidationHandler(DcvContext dcvContext)
      Constructs a new DnsValidationHandler with the specified configuration.
      Parameters:
      dcvContext - context where we can find the needed dependencies / configuration
  • Method Details

    • validate

      public DnsValidationResponse validate(DnsValidationRequest request)
      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 records
      request - 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 records
      request - 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 response
      dnsData - the DNS data
      dnsType - the DNS type (CNAME, TXT, or CAA)
      challengeType - the challenge type (RANDOM_VALUE or REQUEST_TOKEN)
      Returns:
      the DNS validation response
    • getDnsRecordStringValue

      String getDnsRecordStringValue(org.xbill.DNS.Record dnsRecord, DnsType type)
      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 record
      type - the type of DNS record
      Returns:
      the string value of the DNS record