Class TlsConnectionHandler

  • All Implemented Interfaces:
    ConnectionHandler

    public class TlsConnectionHandler
    extends DefaultConnectionHandler
    TlsConnectionHandler creates a new LdapContext using environment properties obtained from LdapConfig.getEnvironment() and then invokes the startTLS extended operation on the context. SSLSocketFactory and HostnameVerifier properties are used from the LdapContext.
    Version:
    $Revision: 1616 $
    Author:
    Middleware Services
    • Constructor Detail

      • TlsConnectionHandler

        public TlsConnectionHandler()
        Default constructor.
      • TlsConnectionHandler

        public TlsConnectionHandler​(LdapConfig lc)
        Creates a new TlsConnectionHandler with the supplied ldap config.
        Parameters:
        lc - ldap config
      • TlsConnectionHandler

        public TlsConnectionHandler​(TlsConnectionHandler ch)
        Copy constructor for TlsConnectionHandler.
        Parameters:
        ch - to copy properties from
    • Method Detail

      • getStopTlsOnClose

        public boolean getStopTlsOnClose()
        Returns whether to call StartTlsResponse.close() when close() is called.
        Returns:
        stop TLS on close
      • setStopTlsOnClose

        public void setStopTlsOnClose​(boolean b)
        Sets whether to call StartTlsResponse.close() when close() is called.
        Parameters:
        b - stop TLS on close
      • connectInternal

        protected void connectInternal​(java.lang.String authtype,
                                       java.lang.String dn,
                                       java.lang.Object credential,
                                       java.util.Hashtable<java.lang.String,​java.lang.Object> env)
                                throws javax.naming.NamingException
        Create the initial ldap context and prepare the connection for use.
        Overrides:
        connectInternal in class DefaultConnectionHandler
        Parameters:
        authtype - security mechanism to bind with
        dn - to bind as
        credential - to bind with in conjunction with dn
        env - to pass to the initial ldap context
        Throws:
        javax.naming.NamingException - if a connection cannot be established
      • close

        public void close()
                   throws javax.naming.NamingException
        Close a connection to an LDAP.
        Specified by:
        close in interface ConnectionHandler
        Overrides:
        close in class AbstractConnectionHandler
        Throws:
        javax.naming.NamingException - if an LDAP error occurs
      • startTls

        public javax.naming.ldap.StartTlsResponse startTls​(javax.naming.ldap.LdapContext ctx)
                                                    throws javax.naming.NamingException
        This will attempt to StartTLS with the supplied LdapContext.
        Parameters:
        ctx - LdapContext
        Returns:
        StartTlsResponse
        Throws:
        javax.naming.NamingException - if an error occurs while requesting an extended operation
      • stopTls

        public void stopTls​(javax.naming.ldap.StartTlsResponse tls)
                     throws javax.naming.NamingException
        This will attempt to StopTLS with the supplied StartTlsResponse.
        Parameters:
        tls - StartTlsResponse
        Throws:
        javax.naming.NamingException - if an error occurs while closing the TLS connection