public abstract class AbstractConnectionHandler extends 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 Class<?>[] |
connectionRetryExceptions
Exception types to retry connections on.
|
protected ConnectionHandler.ConnectionStrategy |
connectionStrategy
Ldap connection strategy.
|
protected 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(String dn,
Object credential)
Open a connection to an LDAP.
|
protected abstract void |
connectInternal(String authtype,
String dn,
Object credential,
Hashtable<String,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.
|
Class<?>[] |
getConnectionRetryExceptions()
This returns the exception types to retry connections on.
|
ConnectionHandler.ConnectionStrategy |
getConnectionStrategy()
Returns the connection strategy.
|
LdapConfig |
getLdapConfig()
Returns the ldap configuration.
|
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 String[] |
parseLdapUrl(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(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 LdapContext context
protected ConnectionHandler.ConnectionStrategy connectionStrategy
protected 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 ConnectionHandlerpublic void setConnectionStrategy(ConnectionHandler.ConnectionStrategy strategy)
setConnectionStrategy in interface ConnectionHandlerstrategy - for making connectionspublic Class<?>[] getConnectionRetryExceptions()
getConnectionRetryExceptions in interface ConnectionHandlerClass[]public void setConnectionRetryExceptions(Class<?>[] exceptions)
setConnectionRetryExceptions in interface ConnectionHandlerexceptions - Class[]public LdapConfig getLdapConfig()
getLdapConfig in interface ConnectionHandlerpublic void setLdapConfig(LdapConfig lc)
setLdapConfig in interface ConnectionHandlerlc - ldap configpublic LdapContext getLdapContext()
ConnectionHandler.connect(String,
Object) must be called prior to invoking this.getLdapContext in interface ConnectionHandlerpublic void connect(String dn, Object credential) throws NamingException
connect in interface ConnectionHandlerdn - to attempt bind withcredential - to attempt bind withNamingException - if an LDAP error occursprotected abstract void connectInternal(String authtype, String dn, Object credential, Hashtable<String,Object> env) throws NamingException
authtype - security mechanism to bind withdn - to bind ascredential - to bind with in conjunction with dnenv - to pass to the initial ldap contextNamingException - if a connection cannot be establishedpublic boolean isConnected()
isConnected in interface ConnectionHandlerpublic void close()
throws NamingException
close in interface ConnectionHandlerNamingException - if an LDAP error occurspublic abstract ConnectionHandler newInstance()
newInstance in interface ConnectionHandlerprotected String[] parseLdapUrl(String ldapUrl, ConnectionHandler.ConnectionStrategy strategy)
ldapUrl - to parsestrategy - of ordered array to returnCopyright © 2014. All rights reserved.