Class DNSServiceResolverImpl

java.lang.Object
org.nuxeo.ecm.directory.ldap.dns.DNSServiceResolverImpl
All Implemented Interfaces:
DNSServiceResolver

public class DNSServiceResolverImpl extends Object implements DNSServiceResolver
Utility class to perform DNS lookups for services.
  • Field Details

    • instance

      protected static DNSServiceResolver instance
    • SRV_RECORD

      protected static final String SRV_RECORD
      See Also:
    • cache

      protected Map<String,List<DNSServiceEntry>> cache
      Create a cache to hold the at most 100 recent DNS lookups for a period of 10 minutes.
    • lastCacheUpdate

      protected long lastCacheUpdate
    • maxDelay

      protected final long maxDelay
    • context

      protected final DirContext context
  • Constructor Details

    • DNSServiceResolverImpl

      protected DNSServiceResolverImpl()
  • Method Details

    • getInstance

      public static DNSServiceResolver getInstance()
    • resolveDnsServiceRecord

      protected List<DNSServiceEntry> resolveDnsServiceRecord(String service, String domain) throws NamingException
      Returns the host name and port that a server providing the specified service can be reached at. A DNS lookup for a SRV record in the form "_service.example.com" is attempted.

      As an example, a lookup for "example.com" for the service _gc._tcp may return "dc01.example.com:3268".

      Parameters:
      service - the service.
      domain - the domain.
      Returns:
      a List of DNSServiceEntrys, which encompasses the hostname and port that the server can be reached at for the specified domain.
      Throws:
      NamingException - if the DNS server is unreachable
    • resolveLDAPDomainServers

      public List<DNSServiceEntry> resolveLDAPDomainServers(String domain) throws NamingException
      Description copied from interface: DNSServiceResolver
      Returns a list of LDAP servers for the specified domain by performing an SRV DNS lookup on _ldap._tcp.${domain}.
      Specified by:
      resolveLDAPDomainServers in interface DNSServiceResolver
      Returns:
      the list of SRV dns entries
      Throws:
      NamingException
    • resolveLDAPDomainServers

      public List<DNSServiceEntry> resolveLDAPDomainServers(String domain, String prefix) throws NamingException
      Description copied from interface: DNSServiceResolver
      Returns a list of LDAP servers for the specified domain by performing an SRV DNS lookup using a custom DNS service prefix.
      Specified by:
      resolveLDAPDomainServers in interface DNSServiceResolver
      prefix - custom SRV prefix such as "_gc._tcp"
      Returns:
      the list of SRV dns entries
      Throws:
      NamingException