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.
  • Field Details

    • 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 Details

    • 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
    • DnsResolverConnectionStrategy

      public DnsResolverConnectionStrategy(Function<List<LdapURL>,Iterator<LdapURL>> function, Duration ttl)
      Creates a new DNS resolver connection strategy.
      Parameters:
      function - that produces a custom iterator
      ttl - time to live for DNS records
  • Method Details

    • 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
    • iterator

      public Iterator<LdapURL> iterator()
    • populate

      public void populate(String urls, LdapURLSet urlSet)
      Description copied from interface: ConnectionStrategy
      Populates a LdapURLSet from the URL string provided at configuration time.
      Specified by:
      populate in interface ConnectionStrategy
      Overrides:
      populate in class AbstractConnectionStrategy
      Parameters:
      urls - Space-delimited string of URLs describing the LDAP hosts to connect to. The URLs in the string are commonly ldap:// or ldaps:// 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 for DnsSrvConnectionStrategy that use URLs with the scheme dns:.
      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