Package org.ldaptive

Class ConnectionConfig


  • public class ConnectionConfig
    extends AbstractConfig
    Contains all the configuration data needed to control connections.
    • Field Detail

      • ONE_RECONNECT_ATTEMPT

        public static final Predicate<RetryMetadata> ONE_RECONNECT_ATTEMPT
        Predicate that attempts a single reconnect.
      • INFINITE_RECONNECT_ATTEMPTS

        public static final Predicate<RetryMetadata> INFINITE_RECONNECT_ATTEMPTS
        Predicate that attempts to reconnect forever, waiting for 5 seconds after the first attempt.
      • INFINITE_RECONNECT_ATTEMPTS_WITH_BACKOFF

        public static final Predicate<RetryMetadata> INFINITE_RECONNECT_ATTEMPTS_WITH_BACKOFF
        Predicate that attempts to reconnect forever, backing off in 5 second intervals after the first attempt.
      • ldapUrl

        private String ldapUrl
        URL to the LDAP(s).
      • connectTimeout

        private Duration connectTimeout
        Duration of time that connects will block.
      • startTLSTimeout

        private Duration startTLSTimeout
        Duration of time to wait for startTLS responses.
      • responseTimeout

        private Duration responseTimeout
        Duration of time to wait for responses.
      • reconnectTimeout

        private Duration reconnectTimeout
        Duration of time that operations will block on reconnects, should generally be longer than connectTimeout.
      • autoReconnect

        private boolean autoReconnect
        Whether to automatically reconnect to the server when a connection is lost. Default is true.
      • autoReconnectCondition

        private Predicate<RetryMetadata> autoReconnectCondition
        Condition used to determine whether another reconnect attempt should be made. Default makes a single attempt only if the connection was previously opened.
      • autoReplay

        private boolean autoReplay
        Whether pending operations should be replayed after a reconnect. Default is false.
      • sslConfig

        private SslConfig sslConfig
        Configuration for SSL and startTLS connections.
      • useStartTLS

        private boolean useStartTLS
        Connect to LDAP using startTLS.
      • transportOptions

        private final Map<String,​Object> transportOptions
        Transport options.
    • Constructor Detail

      • ConnectionConfig

        public ConnectionConfig()
        Default constructor.
      • ConnectionConfig

        public ConnectionConfig​(String url)
        Creates a new connection config.
        Parameters:
        url - to connect to
    • Method Detail

      • getLdapUrl

        public String getLdapUrl()
        Returns the ldap url.
        Returns:
        ldap url
      • setLdapUrl

        public void setLdapUrl​(String url)
        Sets the ldap url.
        Parameters:
        url - of the ldap
      • getConnectTimeout

        public Duration getConnectTimeout()
        Returns the connect timeout.
        Returns:
        timeout
      • setConnectTimeout

        public void setConnectTimeout​(Duration time)
        Sets the maximum amount of time that connects will block.
        Parameters:
        time - timeout for connects
      • getStartTLSTimeout

        public Duration getStartTLSTimeout()
        Returns the startTLS timeout.
        Returns:
        timeout
      • setStartTLSTimeout

        public void setStartTLSTimeout​(Duration time)
        Sets the maximum amount of time that startTLS operations will wait for a response.
        Parameters:
        time - timeout for responses
      • getResponseTimeout

        public Duration getResponseTimeout()
        Returns the response timeout.
        Returns:
        timeout
      • setResponseTimeout

        public void setResponseTimeout​(Duration time)
        Sets the maximum amount of time that operations will wait for a response.
        Parameters:
        time - timeout for responses
      • getReconnectTimeout

        public Duration getReconnectTimeout()
        Returns the reconnect timeout.
        Returns:
        timeout
      • setReconnectTimeout

        public void setReconnectTimeout​(Duration time)
        Sets the maximum amount of time that operations will block waiting for a reconnect.
        Parameters:
        time - timeout for reconnects
      • getAutoReconnect

        public boolean getAutoReconnect()
        Returns whether connections will attempt to reconnect.
        Returns:
        whether to automatically reconnect when a connection is lost
      • setAutoReconnect

        public void setAutoReconnect​(boolean b)
        Sets whether connections will attempt to reconnect when unexpectedly closed.
        Parameters:
        b - whether to automatically reconnect when a connection is lost
      • getAutoReconnectCondition

        public Predicate<RetryMetadata> getAutoReconnectCondition()
        Returns the auto reconnect condition.
        Returns:
        auto reconnect condition
      • setAutoReconnectCondition

        public void setAutoReconnectCondition​(Predicate<RetryMetadata> predicate)
        Sets the auto reconnect condition.
        Parameters:
        predicate - to determine whether to attempt a reconnect
      • getAutoReplay

        public boolean getAutoReplay()
        Returns whether operations should be replayed after a reconnect.
        Returns:
        whether to auto replay
      • setAutoReplay

        public void setAutoReplay​(boolean b)
        Sets whether operations will be replayed after a reconnect.
        Parameters:
        b - whether to replay operations
      • getSslConfig

        public SslConfig getSslConfig()
        Returns the ssl config.
        Returns:
        ssl config
      • setSslConfig

        public void setSslConfig​(SslConfig config)
        Sets the ssl config.
        Parameters:
        config - ssl config
      • getUseStartTLS

        public boolean getUseStartTLS()
        Returns whether startTLS will be used for connections.
        Returns:
        whether startTLS will be used
      • setUseStartTLS

        public void setUseStartTLS​(boolean b)
        Sets whether startTLS will be used for connections.
        Parameters:
        b - whether startTLS will be used
      • getConnectionInitializers

        public ConnectionInitializer[] getConnectionInitializers()
        Returns the connection initializers.
        Returns:
        connection initializers
      • setConnectionInitializers

        public void setConnectionInitializers​(ConnectionInitializer... initializers)
        Sets the connection initializers.
        Parameters:
        initializers - connection initializers
      • getConnectionStrategy

        public ConnectionStrategy getConnectionStrategy()
        Returns the connection strategy.
        Returns:
        strategy for making connections
      • setConnectionStrategy

        public void setConnectionStrategy​(ConnectionStrategy strategy)
        Sets the connection strategy.
        Parameters:
        strategy - for making new connections
      • getConnectionValidator

        public ConnectionValidator getConnectionValidator()
        Returns the connection validator.
        Returns:
        connection validator
      • setConnectionValidator

        public void setConnectionValidator​(ConnectionValidator validator)
        Sets the connection validator.
        Parameters:
        validator - for validating connections
      • getTransportOptions

        public Map<String,​?> getTransportOptions()
        Returns transport options.
        Returns:
        transport options
      • setTransportOptions

        public void setTransportOptions​(Map<String,​?> options)
        Sets transport options.
        Parameters:
        options - to set
      • getTransportOption

        public Object getTransportOption​(String id)
        Returns a transport option.
        Parameters:
        id - transport option id
        Returns:
        transport option
      • setTransportOption

        public void setTransportOption​(String id,
                                       Object value)
        Sets a transport option.
        Parameters:
        id - of the transport option
        value - of the transport option
      • copy

        public static ConnectionConfig copy​(ConnectionConfig config)
        Returns a new connection config initialized with the supplied config.
        Parameters:
        config - connection config to read properties from
        Returns:
        connection config