Class CustomDnsResolver

java.lang.Object
org.apache.hc.client5.http.SystemDefaultDnsResolver
com.digicert.validation.client.file.CustomDnsResolver
All Implemented Interfaces:
org.apache.hc.client5.http.DnsResolver

public class CustomDnsResolver extends org.apache.hc.client5.http.SystemDefaultDnsResolver
CustomDnsResolver is an implementation of the DnsResolver interface that utilizes a DnsClient to perform DNS queries. It specifically processes A records and converts them into InetAddress objects.

According to the BR's, DNS resolution must be conducted by DNS servers managed by the CA. This library facilitates this requirement by using the DNS servers specified in the DCV configuration.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final DnsClient
    The DnsClient used to resolve DNS queries.

    Fields inherited from class org.apache.hc.client5.http.SystemDefaultDnsResolver

    INSTANCE
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a CustomDnsResolver with the specified DcvContext.
  • Method Summary

    Modifier and Type
    Method
    Description
    Resolves the given host name to an array of InetAddress objects using the DnsClient.

    Methods inherited from class org.apache.hc.client5.http.SystemDefaultDnsResolver

    resolveCanonicalHostname

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • dnsClient

      private final DnsClient dnsClient
      The DnsClient used to resolve DNS queries.
  • Constructor Details

    • CustomDnsResolver

      public CustomDnsResolver(DcvContext dcvContext)
      Constructs a CustomDnsResolver with the specified DcvContext. The Context is used to retrieve the DnsClient dependency needed to perform DNS queries.
      Parameters:
      dcvContext - context where we can find the needed dependencies / configuration
  • Method Details

    • resolve

      public InetAddress[] resolve(String host) throws UnknownHostException
      Resolves the given host name to an array of InetAddress objects using the DnsClient.

      This method overrides the resolve method of the SystemDefaultDnsResolver to provide custom DNS resolution logic. It uses the DnsClient to perform the A record DNS lookup. The A records are then converted to InetAddress objects, which are returned as the result. If the DNS lookup fails or an error occurs, an UnknownHostException is thrown with a detailed error message.

      Specified by:
      resolve in interface org.apache.hc.client5.http.DnsResolver
      Overrides:
      resolve in class org.apache.hc.client5.http.SystemDefaultDnsResolver
      Parameters:
      host - The host name to resolve.
      Returns:
      An array of InetAddress objects for the given host name.
      Throws:
      UnknownHostException - If the host name cannot be resolved.