Package org.ldaptive
Class DnsSrvConnectionStrategy
java.lang.Object
org.ldaptive.AbstractFreezable
org.ldaptive.AbstractConnectionStrategy
org.ldaptive.DnsSrvConnectionStrategy
- All Implemented Interfaces:
Iterable<LdapURL>,ConnectionStrategy,Freezable
DNS SRV connection strategy. Queries a DNS server for SRV records and uses those records to construct a list of URLs.
A time to live can be set to control how often the DNS server is consulted. See http://www.ietf.org/rfc/rfc2782.txt.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.ldaptive.AbstractConnectionStrategy
AbstractConnectionStrategy.DefaultLdapURLIterator -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final DurationDefault time to live for DNS results.private final DNSContextFactoryDNS context factory to override initialization parameters.private Map<SRVDNSResolver,String> Resolver(s) for SRV DNS records.private InstantSRV records expiration time.private StringLDAP URL string used to initialize this strategy.private final DurationTime to live for SRV records.private final booleanConnect to LDAP using LDAPS.Fields inherited from class org.ldaptive.AbstractConnectionStrategy
ldapURLSet, logger -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.Creates a new DNS SRV connection strategy.Creates a new DNS SRV connection strategy.DnsSrvConnectionStrategy(DNSContextFactory factory, Duration ttl) Creates a new DNS SRV connection strategy.DnsSrvConnectionStrategy(DNSContextFactory factory, Duration ttl, boolean ssl) Creates a new DNS SRV connection strategy. -
Method Summary
Modifier and TypeMethodDescriptioniterator()Returns a list of URLs retrieved from DNS SRV records.Create a deep copy of this strategy.protected String[]parseDnsUrl(String url) Parses a DNS URL of the form dns://hostname/domain?protected String[]Parses the supplied URL.voidpopulate(String urls, LdapURLSet urlSet) Populates aLdapURLSetfrom the URL string provided at configuration time.readSrvRecords(String urls) Parses the supplied DNS URL string and reads SRV records from DNS.InvokeDNSResolver.resolve(String)for each resolver until results are found.Methods inherited from class org.ldaptive.AbstractConnectionStrategy
failure, getActivateCondition, getRetryCondition, initialize, isInitialized, setRetryCondition, success, toStringMethods inherited from class org.ldaptive.AbstractFreezable
assertMutable, freeze, freeze, freeze, isFrozenMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
DEFAULT_TTL
Default time to live for DNS results. -
dnsContextFactory
DNS context factory to override initialization parameters. -
srvTtl
Time to live for SRV records. -
useSSL
private final boolean useSSLConnect to LDAP using LDAPS. -
ldapUrls
LDAP URL string used to initialize this strategy. -
dnsResolvers
Resolver(s) for SRV DNS records. -
expirationTime
SRV records expiration time.
-
-
Constructor Details
-
DnsSrvConnectionStrategy
public DnsSrvConnectionStrategy()Default constructor. -
DnsSrvConnectionStrategy
Creates a new DNS SRV connection strategy.- Parameters:
ttl- time to live for SRV records
-
DnsSrvConnectionStrategy
Creates a new DNS SRV connection strategy.- Parameters:
factory- DNS context factory
-
DnsSrvConnectionStrategy
Creates a new DNS SRV connection strategy.- Parameters:
factory- DNS context factoryttl- time to live for SRV records
-
DnsSrvConnectionStrategy
Creates a new DNS SRV connection strategy.- Parameters:
factory- DNS context factoryttl- time to live for SRV recordsssl- whether SRV records should produce LDAPS URLs
-
-
Method Details
-
populate
Description copied from interface:ConnectionStrategyPopulates aLdapURLSetfrom the URL string provided at configuration time.- Specified by:
populatein interfaceConnectionStrategy- Overrides:
populatein classAbstractConnectionStrategy- Parameters:
urls- Space-delimited string of URLs describing the LDAP hosts to connect to. The URLs in the string are commonlyldap://orldaps://URLs that directly describe the hosts to connect to, but may also describe a resource from which to obtain LDAP connection URLs as is the case forDnsSrvConnectionStrategythat use URLs with the schemedns:.urlSet- LDAP URL set to populate.
-
readSrvRecords
Parses the supplied DNS URL string and reads SRV records from DNS.- Parameters:
urls- to parse- Returns:
- Set of DNS SRV records ordered first by priority and then by weight.
-
parseUrl
Parses the supplied URL. If the URL has an ldap scheme, it is inspected for a baseDN which will be used as the domain. Otherwise, the URL is assumed to have a dns scheme.- Parameters:
url- to parse- Returns:
- array containing the DNS URL and the record name in that order
-
parseDnsUrl
Parses a DNS URL of the form dns://hostname/domain?record. Where record is the DNS record to retrieve.- Parameters:
url- to parse- Returns:
- array containing the DNS URL and the record name in that order
-
iterator
Returns a list of URLs retrieved from DNS SRV records.- Returns:
- list of URLs to attempt connections to
-
retrieveDNSRecords
InvokeDNSResolver.resolve(String)for each resolver until results are found.- Returns:
- set of LDAP URLs
-
newInstance
Description copied from interface:ConnectionStrategyCreate a deep copy of this strategy.- Returns:
- new instance of this connection strategy
-