JndiLdapContextFactory
implementation. This implementation will be removed
prior to Shiro 2.0@Deprecated public class DefaultLdapContextFactory extends Object implements LdapContextFactory
Default implementation of LdapContextFactory
that can be configured or extended to
customize the way LdapContext
objects are retrieved.
This implementation of LdapContextFactory
is used by the AbstractLdapRealm
if a
factory is not explictly configured.
Connection pooling is enabled by default on this factory, but can be disabled using the
usePooling
property.
Modifier and Type | Field and Description |
---|---|
protected String |
authentication
Deprecated.
|
protected String |
contextFactoryClassName
Deprecated.
|
protected String |
principalSuffix
Deprecated.
|
protected String |
referral
Deprecated.
|
protected String |
searchBase
Deprecated.
|
protected static String |
SUN_CONNECTION_POOLING_PROPERTY
Deprecated.
The Sun LDAP property used to enable connection pooling.
|
protected String |
systemPassword
Deprecated.
|
protected String |
systemUsername
Deprecated.
|
protected String |
url
Deprecated.
|
Constructor and Description |
---|
DefaultLdapContextFactory()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
protected LdapContext |
createLdapContext(Hashtable env)
Deprecated.
Creates and returns a new
InitialLdapContext instance. |
LdapContext |
getLdapContext(Object principal,
Object credentials)
Deprecated.
Creates (or retrieves from a pool) an
LdapContext connection bound using the specified principal and
credentials. |
LdapContext |
getLdapContext(String username,
String password)
Deprecated.
the
getLdapContext(Object, Object) method should be used in all cases to ensure more than
String principals and credentials can be used. Shiro no longer calls this method - it will be
removed before the 2.0 release. |
LdapContext |
getSystemLdapContext()
Deprecated.
Creates (or retrieves from a pool) a
LdapContext connection bound using the system account, or
anonymously if no system account is configured. |
void |
setAdditionalEnvironment(Map<String,String> additionalEnvironment)
Deprecated.
These entries are added to the environment map before initializing the LDAP context.
|
void |
setAuthentication(String authentication)
Deprecated.
Sets the type of LDAP authentication to perform when connecting to the LDAP server.
|
void |
setContextFactoryClassName(String contextFactoryClassName)
Deprecated.
The context factory to use.
|
void |
setPrincipalSuffix(String principalSuffix)
Deprecated.
A suffix appended to the username.
|
void |
setReferral(String referral)
Deprecated.
Sets the LDAP referral property.
|
void |
setSearchBase(String searchBase)
Deprecated.
this attribute existed, but was never used in Shiro 1.x. It will be removed prior to Shiro 2.0.
|
void |
setSystemPassword(String systemPassword)
Deprecated.
The system password that will be used when connecting to the LDAP server to retrieve authorization
information about a user.
|
void |
setSystemUsername(String systemUsername)
Deprecated.
The system username that will be used when connecting to the LDAP server to retrieve authorization
information about a user.
|
void |
setUrl(String url)
Deprecated.
The LDAP url to connect to.
|
void |
setUsePooling(boolean usePooling)
Deprecated.
Determines whether or not LdapContext pooling is enabled for connections made using the system
user account.
|
protected static final String SUN_CONNECTION_POOLING_PROPERTY
protected String authentication
protected String principalSuffix
protected String searchBase
protected String contextFactoryClassName
protected String systemUsername
protected String systemPassword
public DefaultLdapContextFactory()
public void setAuthentication(String authentication)
authentication
- the type of LDAP authentication to perform.public void setPrincipalSuffix(String principalSuffix)
principalSuffix
- the suffix.@Deprecated public void setSearchBase(String searchBase)
searchBase
- the search base.public void setContextFactoryClassName(String contextFactoryClassName)
contextFactoryClassName
- the context factory that should be used.public void setUrl(String url)
url
- the LDAP url.public void setReferral(String referral)
referral
- the referral property.public void setSystemUsername(String systemUsername)
systemUsername
- the username to use when logging into the LDAP server for authorization.public void setSystemPassword(String systemPassword)
systemPassword
- the password to use when logging into the LDAP server for authorization.public void setUsePooling(boolean usePooling)
usePooling
- true to enable pooling, or false to disable it.public void setAdditionalEnvironment(Map<String,String> additionalEnvironment)
additionalEnvironment
- additional environment entries to be configured on the LDAP context.public LdapContext getSystemLdapContext() throws NamingException
LdapContextFactory
LdapContext
connection bound using the system account, or
anonymously if no system account is configured.getSystemLdapContext
in interface LdapContextFactory
LdapContext
bound by the system account, or bound anonymously if no system account
is configured.NamingException
- if there is an error creating the context.@Deprecated public LdapContext getLdapContext(String username, String password) throws NamingException
getLdapContext(Object, Object)
method should be used in all cases to ensure more than
String principals and credentials can be used. Shiro no longer calls this method - it will be
removed before the 2.0 release.getLdapContext(Object, Object)
instead. This will be removed before Apache Shiro 2.0.getLdapContext
in interface LdapContextFactory
username
- the username to use when creating the connection.password
- the password to use when creating the connection.LdapContext
bound using the given username and password.NamingException
- if there is an error creating the context.public LdapContext getLdapContext(Object principal, Object credentials) throws NamingException
LdapContextFactory
LdapContext
connection bound using the specified principal and
credentials. The format of the principal and credentials are whatever is supported by the underlying
LDAP InitialContextFactory
implementation. The default Sun
(now Oracle) implementation supports
anonymous, simple, and
SASL-based mechanisms.
This method was added in Shiro 1.1 to address the fact that principals and credentials can be more than just
String
user DNs and passwords for connecting to LDAP. For example, the credentials can be an
X.509
certificate.getLdapContext
in interface LdapContextFactory
principal
- the principal to use when acquiring a connection to the LDAP directorycredentials
- the credentials (password, X.509 certificate, etc) to use when acquiring a connection to the
LDAP directoryLdapContext
connection bound using the specified principal and credentials.NamingException
- if unable to acquire a connection.protected LdapContext createLdapContext(Hashtable env) throws NamingException
InitialLdapContext
instance. This method exists primarily
to support testing where a mock LdapContext can be returned instead of actually creating a connection, but
subclasses are free to provide a different implementation if necessary.env
- the JNDI environment settings used to create the LDAP connectionNamingException
- if a problem occurs creating the connectionCopyright © 2004–2019 The Apache Software Foundation. All rights reserved.