Spring Security Framework

org.springframework.security.ldap
Class DefaultInitialDirContextFactory

java.lang.Object
  extended by org.springframework.security.ldap.DefaultInitialDirContextFactory
All Implemented Interfaces:
MessageSourceAware, org.springframework.ldap.core.ContextSource, org.springframework.ldap.core.support.BaseLdapPathContextSource, org.springframework.ldap.core.support.BaseLdapPathSource, InitialDirContextFactory, SpringSecurityContextSource

Deprecated. use DefaultSpringSecurityContextSource instead.

public class DefaultInitialDirContextFactory
extends Object
implements InitialDirContextFactory, SpringSecurityContextSource, MessageSourceAware

Encapsulates the information for connecting to an LDAP server and provides an access point for obtaining DirContext references.

The directory location is configured using by setting the constructor argument providerUrl. This should be in the form ldap://monkeymachine.co.uk:389/dc=springframework,dc=org. The Sun JNDI provider also supports lists of space-separated URLs, each of which will be tried in turn until a connection is obtained.

To obtain an initial context, the client calls the newInitialDirContext method. There are two signatures - one with no arguments and one which allows binding with a specific username and password.

The no-args version will bind anonymously unless a manager login has been configured using the properties managerDn and managerPassword, in which case it will bind as the manager user.

Connection pooling is enabled by default for anonymous or manager connections, but not when binding as a specific user.

Version:
$Id$
Author:
Robert Sanders, Luke Taylor
See Also:
The Java tutorial's guide to LDAP connection pooling

Field Summary
protected  MessageSourceAccessor messages
          Deprecated.  
 
Constructor Summary
DefaultInitialDirContextFactory(String providerUrl)
          Deprecated. Create and initialize an instance to the LDAP url provided
 
Method Summary
 org.springframework.ldap.core.DistinguishedName getBaseLdapPath()
          Deprecated.  
 String getBaseLdapPathAsString()
          Deprecated.  
protected  Hashtable getEnvironment()
          Deprecated. Sets up the environment parameters for creating a new context.
 DirContext getReadOnlyContext()
          Deprecated. Spring LDAP ContextSource method
 DirContext getReadWriteContext()
          Deprecated. Spring LDAP ContextSource method
 DirContext getReadWriteContext(String userDn, Object credentials)
          Deprecated. Obtains a context using the supplied distinguished name and credentials.
 String getRootDn()
          Deprecated. Returns the root DN of the configured provider URL.
 DirContext newInitialDirContext()
          Deprecated. Connects anonymously unless a manager user has been specified, in which case it will bind as the manager.
 DirContext newInitialDirContext(String username, String password)
          Deprecated. Provides an initial context by binding as a specific user.
 void setAuthenticationType(String authenticationType)
          Deprecated.  
 void setDirObjectFactory(String dirObjectFactory)
          Deprecated.  
 void setExtraEnvVars(Map extraEnvVars)
          Deprecated. Sets any custom environment variables which will be added to the those returned by the getEnvironment method.
 void setInitialContextFactory(String initialContextFactory)
          Deprecated.  
 void setManagerDn(String managerDn)
          Deprecated. Sets the directory user to authenticate as when obtaining a context using the newInitialDirContext() method.
 void setManagerPassword(String managerPassword)
          Deprecated. Sets the password which will be used in combination with the manager DN.
 void setMessageSource(MessageSource messageSource)
          Deprecated.  
 void setUseConnectionPool(boolean useConnectionPool)
          Deprecated. Connection pooling is enabled by default for anonymous or "manager" connections when using the default Sun provider.
 void setUseLdapContext(boolean useLdapContext)
          Deprecated.  
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

messages

protected MessageSourceAccessor messages
Deprecated. 
Constructor Detail

DefaultInitialDirContextFactory

public DefaultInitialDirContextFactory(String providerUrl)
Deprecated. 
Create and initialize an instance to the LDAP url provided

Parameters:
providerUrl - a String of the form ldap://localhost:389/base_dn
Method Detail

getEnvironment

protected Hashtable getEnvironment()
Deprecated. 
Sets up the environment parameters for creating a new context.

Returns:
the Hashtable describing the base DirContext that will be created, minus the username/password if any.

getRootDn

public String getRootDn()
Deprecated. 
Returns the root DN of the configured provider URL. For example, if the URL is ldap://monkeymachine.co.uk:389/dc=springframework,dc=org the value will be dc=springframework,dc=org.

Specified by:
getRootDn in interface InitialDirContextFactory
Returns:
the root DN calculated from the path of the LDAP url.

newInitialDirContext

public DirContext newInitialDirContext()
Deprecated. 
Connects anonymously unless a manager user has been specified, in which case it will bind as the manager.

Specified by:
newInitialDirContext in interface InitialDirContextFactory
Returns:
the resulting context object.

newInitialDirContext

public DirContext newInitialDirContext(String username,
                                       String password)
Deprecated. 
Description copied from interface: InitialDirContextFactory
Provides an initial context by binding as a specific user.

Specified by:
newInitialDirContext in interface InitialDirContextFactory
Parameters:
username - the user to authenticate as when obtaining the context.
password - the user's password.
Returns:
An initial context for the LDAP directory

getReadOnlyContext

public DirContext getReadOnlyContext()
                              throws DataAccessException
Deprecated. 
Spring LDAP ContextSource method

Specified by:
getReadOnlyContext in interface org.springframework.ldap.core.ContextSource
Throws:
DataAccessException

getReadWriteContext

public DirContext getReadWriteContext()
                               throws DataAccessException
Deprecated. 
Spring LDAP ContextSource method

Specified by:
getReadWriteContext in interface org.springframework.ldap.core.ContextSource
Throws:
DataAccessException

setAuthenticationType

public void setAuthenticationType(String authenticationType)
Deprecated. 

setExtraEnvVars

public void setExtraEnvVars(Map extraEnvVars)
Deprecated. 
Sets any custom environment variables which will be added to the those returned by the getEnvironment method.

Parameters:
extraEnvVars - extra environment variables to be added at config time.

setInitialContextFactory

public void setInitialContextFactory(String initialContextFactory)
Deprecated. 

setManagerDn

public void setManagerDn(String managerDn)
Deprecated. 
Sets the directory user to authenticate as when obtaining a context using the newInitialDirContext() method. If no name is supplied then the context will be obtained anonymously.

Parameters:
managerDn - The name of the "manager" user for default authentication.

setManagerPassword

public void setManagerPassword(String managerPassword)
Deprecated. 
Sets the password which will be used in combination with the manager DN.

Parameters:
managerPassword - The "manager" user's password.

setMessageSource

public void setMessageSource(MessageSource messageSource)
Deprecated. 
Specified by:
setMessageSource in interface MessageSourceAware

setUseConnectionPool

public void setUseConnectionPool(boolean useConnectionPool)
Deprecated. 
Connection pooling is enabled by default for anonymous or "manager" connections when using the default Sun provider. To disable all connection pooling, set this property to false.

Parameters:
useConnectionPool - whether to pool connections for non-specific users.

setUseLdapContext

public void setUseLdapContext(boolean useLdapContext)
Deprecated. 

setDirObjectFactory

public void setDirObjectFactory(String dirObjectFactory)
Deprecated. 

getReadWriteContext

public DirContext getReadWriteContext(String userDn,
                                      Object credentials)
Deprecated. 
Description copied from interface: SpringSecurityContextSource
Obtains a context using the supplied distinguished name and credentials.

Specified by:
getReadWriteContext in interface SpringSecurityContextSource
Parameters:
userDn - the distinguished name of the user to authenticate as
credentials - the user's password
Returns:
a context authenticated as the supplied user

getBaseLdapPath

public org.springframework.ldap.core.DistinguishedName getBaseLdapPath()
Deprecated. 
Specified by:
getBaseLdapPath in interface org.springframework.ldap.core.support.BaseLdapPathSource

getBaseLdapPathAsString

public String getBaseLdapPathAsString()
Deprecated. 
Specified by:
getBaseLdapPathAsString in interface org.springframework.ldap.core.support.BaseLdapPathSource

Spring Security Framework

Copyright © 2004-2010 SpringSource, Inc. All Rights Reserved.