Package org.ldaptive

Class 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 Detail

      • DEFAULT_TTL

        protected static final Duration DEFAULT_TTL
        Default time to live for DNS results.
      • dnsTtl

        private final Duration dnsTtl
        Time to live for DNS records.
      • 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
      • 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 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 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.