Package org.ldaptive
Class DnsResolverConnectionStrategy
- java.lang.Object
-
- org.ldaptive.AbstractConnectionStrategy
-
- org.ldaptive.DnsResolverConnectionStrategy
-
- All Implemented Interfaces:
Iterable<LdapURL>
,ConnectionStrategy
public class DnsResolverConnectionStrategy extends AbstractConnectionStrategy
Connection strategy that tries all IP addresses resolved from DNS. The order of IP addressees returned can be controlled via the java.net.preferIPv4Stack or java.net.preferIPv6Addresses system property flags. This strategy operates in an active/passive fashion.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.ldaptive.AbstractConnectionStrategy
AbstractConnectionStrategy.DefaultLdapURLIterator
-
-
Field Summary
Fields Modifier and Type Field Description protected static Duration
DEFAULT_TTL
Default time to live for DNS results.private Duration
dnsTtl
Time to live for DNS records.private Instant
expirationTime
DNS expiration time.private Function<List<LdapURL>,Iterator<LdapURL>>
iterFunction
Custom iterator function.private String
ldapUrls
LDAP URL string used to initialize this strategy.private Function<String,InetAddress[]>
resolverFunction
Name resolver function.-
Fields inherited from class org.ldaptive.AbstractConnectionStrategy
ldapURLSet, logger
-
-
Constructor Summary
Constructors Constructor Description DnsResolverConnectionStrategy()
Default constructor.DnsResolverConnectionStrategy(Duration ttl)
Creates a new DNS resolver connection strategy.DnsResolverConnectionStrategy(Function<List<LdapURL>,Iterator<LdapURL>> function)
Creates a new DNS connection strategy.DnsResolverConnectionStrategy(Function<List<LdapURL>,Iterator<LdapURL>> function, Duration ttl)
Creates a new DNS resolver connection strategy.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Function<String,InetAddress[]>
getResolverFunction()
Returns the name resolution function.Iterator<LdapURL>
iterator()
DnsResolverConnectionStrategy
newInstance()
Create a deep copy of this strategy.void
populate(String urls, LdapURLSet urlSet)
Populates aLdapURLSet
from the URL string provided at configuration time.void
setResolverFunction(Function<String,InetAddress[]> func)
Sets the function used to resolve names.-
Methods inherited from class org.ldaptive.AbstractConnectionStrategy
failure, getActivateCondition, getRetryCondition, initialize, isInitialized, setRetryCondition, success, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
DEFAULT_TTL
protected static final Duration DEFAULT_TTL
Default time to live for DNS results.
-
iterFunction
private final Function<List<LdapURL>,Iterator<LdapURL>> iterFunction
Custom iterator function.
-
dnsTtl
private final Duration dnsTtl
Time to live for DNS records.
-
resolverFunction
private Function<String,InetAddress[]> resolverFunction
Name resolver function.
-
ldapUrls
private String ldapUrls
LDAP URL string used to initialize this strategy.
-
expirationTime
private Instant expirationTime
DNS expiration time.
-
-
Constructor Detail
-
DnsResolverConnectionStrategy
public DnsResolverConnectionStrategy()
Default constructor.
-
DnsResolverConnectionStrategy
public DnsResolverConnectionStrategy(Duration ttl)
Creates a new DNS resolver connection strategy.- Parameters:
ttl
- time to live for DNS records
-
DnsResolverConnectionStrategy
public DnsResolverConnectionStrategy(Function<List<LdapURL>,Iterator<LdapURL>> function)
Creates a new DNS connection strategy.- Parameters:
function
- that produces a custom iterator
-
-
Method Detail
-
getResolverFunction
public Function<String,InetAddress[]> getResolverFunction()
Returns the name resolution function.- Returns:
- name resolution function
-
setResolverFunction
public void setResolverFunction(Function<String,InetAddress[]> func)
Sets the function used to resolve names.- Parameters:
func
- to set
-
populate
public void populate(String urls, LdapURLSet urlSet)
Description copied from interface:ConnectionStrategy
Populates aLdapURLSet
from the URL string provided at configuration time.- Specified by:
populate
in interfaceConnectionStrategy
- Overrides:
populate
in 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 forDnsSrvConnectionStrategy
that use URLs with the schemedns:
.urlSet
- LDAP URL set to populate.
-
newInstance
public DnsResolverConnectionStrategy newInstance()
Description copied from interface:ConnectionStrategy
Create a deep copy of this strategy.- Returns:
- new instance of this connection strategy
-
-