edu.vt.middleware.ldap.handler
public abstract class AbstractConnectionHandler extends java.lang.Object implements ConnectionHandler
AbstractConnectionHandler
provides a basic implementation for
other connection handlers to inherit.ConnectionHandler.ConnectionStrategy
Modifier and Type | Field and Description |
---|---|
protected LdapConfig |
config
Ldap configuration.
|
protected java.lang.Class<?>[] |
connectionRetryExceptions
Exception types to retry connections on.
|
protected ConnectionHandler.ConnectionStrategy |
connectionStrategy
Ldap connection strategy.
|
protected javax.naming.ldap.LdapContext |
context
Ldap context.
|
protected org.apache.commons.logging.Log |
logger
Log for this class.
|
Constructor and Description |
---|
AbstractConnectionHandler() |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close a connection to an LDAP.
|
void |
connect(java.lang.String dn,
java.lang.Object credential)
Open a connection to an LDAP.
|
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)
Create the initial ldap context and prepare the connection for use.
|
protected edu.vt.middleware.ldap.handler.AbstractConnectionHandler.ConnectionCount |
getConnectionCount()
Returns the connection count.
|
java.lang.Class<?>[] |
getConnectionRetryExceptions()
This returns the exception types to retry connections on.
|
ConnectionHandler.ConnectionStrategy |
getConnectionStrategy()
Returns the connection strategy.
|
LdapConfig |
getLdapConfig()
Returns the ldap configuration.
|
javax.naming.ldap.LdapContext |
getLdapContext()
Returns an ldap context to use for ldap operations.
|
boolean |
isConnected()
Returns whether the underlying context has been established.
|
abstract ConnectionHandler |
newInstance()
Returns a separate instance of this connection handler with the same
underlying ldap configuration.
|
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.
|
protected void |
setConnectionCount(edu.vt.middleware.ldap.handler.AbstractConnectionHandler.ConnectionCount cc)
Sets the connection count.
|
void |
setConnectionRetryExceptions(java.lang.Class<?>[] exceptions)
This sets the exception types to retry connections on.
|
void |
setConnectionStrategy(ConnectionHandler.ConnectionStrategy strategy)
Sets the connection strategy.
|
void |
setLdapConfig(LdapConfig lc)
Sets the ldap configuration.
|
protected final org.apache.commons.logging.Log logger
protected LdapConfig config
protected javax.naming.ldap.LdapContext context
protected ConnectionHandler.ConnectionStrategy connectionStrategy
protected java.lang.Class<?>[] connectionRetryExceptions
protected edu.vt.middleware.ldap.handler.AbstractConnectionHandler.ConnectionCount getConnectionCount()
protected void setConnectionCount(edu.vt.middleware.ldap.handler.AbstractConnectionHandler.ConnectionCount cc)
cc
- connection countpublic ConnectionHandler.ConnectionStrategy getConnectionStrategy()
getConnectionStrategy
in interface ConnectionHandler
public void setConnectionStrategy(ConnectionHandler.ConnectionStrategy strategy)
setConnectionStrategy
in interface ConnectionHandler
strategy
- for making connectionspublic java.lang.Class<?>[] getConnectionRetryExceptions()
getConnectionRetryExceptions
in interface ConnectionHandler
Class[]
public void setConnectionRetryExceptions(java.lang.Class<?>[] exceptions)
setConnectionRetryExceptions
in interface ConnectionHandler
exceptions
- Class[]
public LdapConfig getLdapConfig()
getLdapConfig
in interface ConnectionHandler
public void setLdapConfig(LdapConfig lc)
setLdapConfig
in interface ConnectionHandler
lc
- ldap configpublic javax.naming.ldap.LdapContext getLdapContext()
ConnectionHandler.connect(String,
Object)
must be called prior to invoking this.getLdapContext
in interface ConnectionHandler
public void connect(java.lang.String dn, java.lang.Object credential) throws javax.naming.NamingException
connect
in interface ConnectionHandler
dn
- to attempt bind withcredential
- to attempt bind withjavax.naming.NamingException
- if an LDAP error occursprotected 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
authtype
- security mechanism to bind withdn
- to bind ascredential
- to bind with in conjunction with dnenv
- to pass to the initial ldap contextjavax.naming.NamingException
- if a connection cannot be establishedpublic boolean isConnected()
isConnected
in interface ConnectionHandler
public void close() throws javax.naming.NamingException
close
in interface ConnectionHandler
javax.naming.NamingException
- if an LDAP error occurspublic abstract ConnectionHandler newInstance()
newInstance
in interface ConnectionHandler
protected java.lang.String[] parseLdapUrl(java.lang.String ldapUrl, ConnectionHandler.ConnectionStrategy strategy)
ldapUrl
- to parsestrategy
- of ordered array to returnCopyright © 2014. All Rights Reserved.