Package org.nuxeo.ecm.directory.ldap.dns
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 Summary
Fields Modifier and Type Field Description protected Map<String,List<DNSServiceEntry>>
cache
Create a cache to hold the at most 100 recent DNS lookups for a period of 10 minutes.protected DirContext
context
protected static DNSServiceResolver
instance
protected long
lastCacheUpdate
static Log
log
protected long
maxDelay
protected static String
SRV_RECORD
-
Fields inherited from interface org.nuxeo.ecm.directory.ldap.dns.DNSServiceResolver
DNS_CACHE_EXPIRY, LDAP_SERVICE_PREFIX
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DNSServiceResolverImpl()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DNSServiceResolver
getInstance()
protected List<DNSServiceEntry>
resolveDnsServiceRecord(String service, String domain)
Returns the host name and port that a server providing the specified service can be reached at.List<DNSServiceEntry>
resolveLDAPDomainServers(String domain)
Returns a list of LDAP servers for the specified domain by performing an SRV DNS lookup on _ldap._tcp.${domain}.List<DNSServiceEntry>
resolveLDAPDomainServers(String domain, String prefix)
Returns a list of LDAP servers for the specified domain by performing an SRV DNS lookup using a custom DNS service prefix.
-
-
-
Field Detail
-
instance
protected static DNSServiceResolver instance
-
SRV_RECORD
protected static final String SRV_RECORD
- See Also:
- Constant Field Values
-
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 Detail
-
DNSServiceResolverImpl
protected DNSServiceResolverImpl()
-
-
Method Detail
-
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 interfaceDNSServiceResolver
- 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 interfaceDNSServiceResolver
prefix
- custom SRV prefix such as "_gc._tcp"- Returns:
- the list of SRV dns entries
- Throws:
NamingException
-
-