|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.springframework.ldap.support.AbstractContextSource
public abstract class AbstractContextSource
Abstract implementation of the ContextSource interface. By default, returns
an authenticated DirContext implementation for both read-only and read-write
operations. To have an anonymous environment created for read-only
operations, set the anonymousReadOnly property to true.
Implementing classes need to implement
getDirContextInstance(Hashtable) to create a DirContext instance of
the desired type.
If an AuthenticationSource is set, this will be used for getting user name and password for each new connection, otherwise a default one will be created using the specified userName and password.
Note: When using implementations of this class outside of a Spring
Context it is necessary to call afterPropertiesSet() when all
properties are set, in order to finish up initialization.
LdapTemplate,
DefaultDirObjectFactory,
LdapContextSource,
DirContextSource| Field Summary | |
|---|---|
protected java.lang.String |
password
|
static java.lang.String |
SUN_LDAP_POOLING_FLAG
|
protected java.lang.String |
userName
|
| Constructor Summary | |
|---|---|
AbstractContextSource()
|
|
| Method Summary | |
|---|---|
void |
afterPropertiesSet()
Checks that all necessary data is set and that there is no compatibility issues, after which the instance is initialized. |
protected java.lang.String |
assembleProviderUrlString(java.lang.String[] ldapUrls)
Assemble a valid url String from all registered urls to add as PROVIDER_URL to the environment. |
protected java.util.Hashtable |
getAnonymousEnv()
|
protected java.util.Hashtable |
getAuthenticatedEnv()
|
protected abstract javax.naming.directory.DirContext |
getDirContextInstance(java.util.Hashtable environment)
Implement in subclass to create a DirContext of the desired type (e.g. |
NamingExceptionTranslator |
getExceptionTranslator()
Get the NamingExceptionTranslator used by this instance. |
javax.naming.directory.DirContext |
getReadOnlyContext()
Gets a read-only DirContext. |
javax.naming.directory.DirContext |
getReadWriteContext()
Gets a read-write DirContext. |
protected java.lang.String[] |
getUrls()
|
void |
setAnonymousReadOnly(boolean anonymousReadOnly)
Set whether an anonymous environment should be used for read-only operations. |
void |
setAuthenticationSource(AuthenticationSource authenticationProvider)
|
void |
setBase(java.lang.String base)
Set the base suffix from which all operations should origin. |
void |
setBaseEnvironmentProperties(java.util.Map baseEnvironmentProperties)
If any custom environment properties are needed, these can be set using this method. |
void |
setCacheEnvironmentProperties(boolean cacheEnvironmentProperties)
Set whether environment properties should be cached between requsts for anonymous environment. |
void |
setContextFactory(java.lang.Class contextFactory)
Set the context factory. |
void |
setDirObjectFactory(java.lang.Class dirObjectFactory)
Set the DirObjectFactory to use. |
void |
setExceptionTranslator(NamingExceptionTranslator exceptionTranslator)
Set the NamingExceptionTranslator to be used by this instance. |
void |
setPassword(java.lang.String password)
Set the password (credentials) to use for getting authenticated contexts. |
void |
setPooled(boolean pooled)
Set whether the pooling flag should be set. |
protected void |
setupAuthenticatedEnvironment(java.util.Hashtable env)
Default implementation of setting the environment up to be authenticated. |
void |
setUrl(java.lang.String url)
Set the url of the LDAP server. |
void |
setUrls(java.lang.String[] urls)
Set the urls of the LDAP servers. |
void |
setUserName(java.lang.String userName)
Set the user name (principal) to use for getting authenticated contexts. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.lang.String userName
protected java.lang.String password
public static final java.lang.String SUN_LDAP_POOLING_FLAG
| Constructor Detail |
|---|
public AbstractContextSource()
| Method Detail |
|---|
public javax.naming.directory.DirContext getReadOnlyContext()
ContextSource
getReadOnlyContext in interface ContextSourcepublic javax.naming.directory.DirContext getReadWriteContext()
ContextSource
getReadWriteContext in interface ContextSourceprotected void setupAuthenticatedEnvironment(java.util.Hashtable env)
env - the environment to modify.protected java.lang.String assembleProviderUrlString(java.lang.String[] ldapUrls)
ldapUrls - all individual url Strings.
public void setBase(java.lang.String base)
base - the base suffix.public void setContextFactory(java.lang.Class contextFactory)
contextFactory - the context factory used when creating Contexts.public void setDirObjectFactory(java.lang.Class dirObjectFactory)
DefaultDirObjectFactory. The specified class needs to be an
implementation of javax.naming.spi.DirObjectFactory. Note: Setting
this value to null may have cause connection leaks when using
ContextMapper methods in LdapTemplate.
dirObjectFactory - the DirObjectFactory to be used. Null means that no
DirObjectFactory will be used.
public void afterPropertiesSet()
throws java.lang.Exception
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanjava.lang.Exceptionpublic void setPassword(java.lang.String password)
password - the password.public void setUserName(java.lang.String userName)
userName - the user name.public void setUrls(java.lang.String[] urls)
urls - the urls of all servers.public void setUrl(java.lang.String url)
url - the url of the LDAP server.public void setPooled(boolean pooled)
pooled - whether Contexts should be pooled.public void setBaseEnvironmentProperties(java.util.Map baseEnvironmentProperties)
baseEnvironmentProperties - protected java.util.Hashtable getAnonymousEnv()
protected java.util.Hashtable getAuthenticatedEnv()
public void setAuthenticationSource(AuthenticationSource authenticationProvider)
public void setCacheEnvironmentProperties(boolean cacheEnvironmentProperties)
cacheEnvironmentProperties - true causes that the anonymous environment properties should
be cached, false causes the Hashmap to be rebuilt for each
request.public void setAnonymousReadOnly(boolean anonymousReadOnly)
false.
anonymousReadOnly - true if and anonymous environment should be
used for read-only operations, false otherwise.public void setExceptionTranslator(NamingExceptionTranslator exceptionTranslator)
DefaultNamingExceptionTranslator will be used.
exceptionTranslator - the NamingExceptionTranslator to use.public NamingExceptionTranslator getExceptionTranslator()
protected abstract javax.naming.directory.DirContext getDirContextInstance(java.util.Hashtable environment)
throws javax.naming.NamingException
environment - the environment to use when creating the instance.
javax.naming.NamingException - if one is encountered when creating the instance.protected java.lang.String[] getUrls()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||