public class DefaultSpringSecurityContextSource extends LdapContextSource
From Spring Security 3.0, Spring LDAP 1.3 is used and the ContextSource interface provides support for binding with a username and password. As a result, Spring LDAP ContextSource implementations such as LdapContextSource may be used directly with Spring Security.
Spring LDAP 1.3 doesn't have JVM-level LDAP connection pooling enabled by default. This
class sets the pooled property to true, but customizes the
DirContextAuthenticationStrategy
used to disable pooling when the DN
doesn't match the userDn property. This prevents pooling for calls to
AbstractContextSource.getContext(String, String)
to authenticate as specific users.
Modifier and Type | Field and Description |
---|---|
protected org.apache.commons.logging.Log |
logger |
password, SUN_LDAP_POOLING_FLAG, userDn
Constructor and Description |
---|
DefaultSpringSecurityContextSource(List<String> urls,
String baseDn)
Create and initialize an instance which will connect of the LDAP Spring Security
Context Source.
|
DefaultSpringSecurityContextSource(String providerUrl)
Create and initialize an instance which will connect to the supplied LDAP URL.
|
getDirContextInstance
afterPropertiesSet, assembleProviderUrlString, createContext, getAnonymousEnv, getAuthenticatedEnv, getAuthenticationSource, getBaseLdapName, getBaseLdapPath, getBaseLdapPathAsString, getContext, getContextFactory, getDirObjectFactory, getPassword, getReadOnlyContext, getReadWriteContext, getUrls, getUserDn, isAnonymousReadOnly, isPooled, setAnonymousReadOnly, setAuthenticationSource, setAuthenticationStrategy, setBase, setBaseEnvironmentProperties, setCacheEnvironmentProperties, setContextFactory, setDirObjectFactory, setPassword, setPooled, setReferral, setupAuthenticatedEnvironment, setUrl, setUrls, setUserDn
public DefaultSpringSecurityContextSource(String providerUrl)
DefaultSpringSecurityContextSource(List, String)
constructor.providerUrl
- an LDAP URL of the form
ldap://localhost:389/base_dn
public DefaultSpringSecurityContextSource(List<String> urls, String baseDn)
urls
- A list of string values which are LDAP server URLs. An example would be
ldap://ldap.company.com:389
. LDAPS URLs (SSL-secured) may be used as
well, given that Spring Security is able to connect to the server. Note that these
URLs must not include the base DN!baseDn
- The common Base DN for all provided servers, e.g.
dc=company,dc=com.