Class AbstractConnectionHandler

  • All Implemented Interfaces:
    ConnectionHandler
    Direct Known Subclasses:
    DefaultConnectionHandler

    public abstract class AbstractConnectionHandler
    extends java.lang.Object
    implements ConnectionHandler
    AbstractConnectionHandler provides a basic implementation for other connection handlers to inherit.
    Version:
    $Revision: 2397 $
    Author:
    Middleware Services
    • Field Detail

      • logger

        protected final org.apache.commons.logging.Log logger
        Log for this class.
      • config

        protected LdapConfig config
        Ldap configuration.
      • context

        protected javax.naming.ldap.LdapContext context
        Ldap context.
      • connectionRetryExceptions

        protected java.lang.Class<?>[] connectionRetryExceptions
        Exception types to retry connections on.
    • Constructor Detail

      • AbstractConnectionHandler

        public AbstractConnectionHandler()
    • Method Detail

      • getConnectionCount

        protected edu.vt.middleware.ldap.handler.AbstractConnectionHandler.ConnectionCount getConnectionCount()
        Returns the connection count.
        Returns:
        connection count
      • setConnectionCount

        protected void setConnectionCount​(edu.vt.middleware.ldap.handler.AbstractConnectionHandler.ConnectionCount cc)
        Sets the connection count.
        Parameters:
        cc - connection count
      • getConnectionRetryExceptions

        public java.lang.Class<?>[] getConnectionRetryExceptions()
        This returns the exception types to retry connections on.
        Specified by:
        getConnectionRetryExceptions in interface ConnectionHandler
        Returns:
        Class[]
      • setConnectionRetryExceptions

        public void setConnectionRetryExceptions​(java.lang.Class<?>[] exceptions)
        This sets the exception types to retry connections on.
        Specified by:
        setConnectionRetryExceptions in interface ConnectionHandler
        Parameters:
        exceptions - Class[]
      • connect

        public void connect​(java.lang.String dn,
                            java.lang.Object credential)
                     throws javax.naming.NamingException
        Open a connection to an LDAP.
        Specified by:
        connect in interface ConnectionHandler
        Parameters:
        dn - to attempt bind with
        credential - to attempt bind with
        Throws:
        javax.naming.NamingException - if an LDAP error occurs
      • connectInternal

        protected abstract 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.
        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
      • isConnected

        public boolean isConnected()
        Returns whether the underlying context has been established.
        Specified by:
        isConnected in interface ConnectionHandler
        Returns:
        whether a connection has been made
      • close

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

        public abstract ConnectionHandler newInstance()
        Returns a separate instance of this connection handler with the same underlying ldap configuration.
        Specified by:
        newInstance in interface ConnectionHandler
        Returns:
        connection handler
      • parseLdapUrl

        protected java.lang.String[] parseLdapUrl​(java.lang.String ldapUrl,
                                                  ConnectionHandler.ConnectionStrategy strategy)
        Parses the supplied ldap url and splits it into separate URLs if it is space delimited.
        Parameters:
        ldapUrl - to parse
        strategy - of ordered array to return
        Returns:
        array of ldap URLs