LDAP-18: Deprecated the userName property in AbstractContextSource and changed it to the more correct userDn.
This commit is contained in:
@@ -14,6 +14,9 @@ Changes in version 1.2 (xx.yy.2007)
|
||||
-------------------------------------------
|
||||
* Moved the core classes into the package ldap.core.
|
||||
|
||||
* Deprecated the userName property in AbstractContextSource and changed
|
||||
it to the more correct userDn.
|
||||
|
||||
* Upgraded ApacheDS to 1.0.0.
|
||||
|
||||
Changes in version 1.1.2 (1.12.2006)
|
||||
|
||||
@@ -26,12 +26,12 @@
|
||||
|
||||
<para>Authenticated contexts are created for both read-only and
|
||||
read-write operations by default. You specify
|
||||
<literal>userName</literal> and <literal>password</literal> of the LDAP
|
||||
<literal>userDn</literal> and <literal>password</literal> of the LDAP
|
||||
user to be used for authentication on the
|
||||
<literal>ContextSource</literal>.</para>
|
||||
|
||||
<para><note>
|
||||
<para>The <literal>userName</literal> needs to be the full
|
||||
<para>The <literal>userDn</literal> needs to be the full
|
||||
Distinguished Name (DN) of the user.</para>
|
||||
</note></para>
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
executing LDAP operations for that user. The default behaviour can be
|
||||
modified by supplying a custom <literal>AuthenticationSource</literal>
|
||||
implementation to the <literal>ContextSource</literal> on startup,
|
||||
instead of explicitly specifying the <literal>userName</literal> and
|
||||
instead of explicitly specifying the <literal>userDn</literal> and
|
||||
<literal>password</literal>. The
|
||||
<literal>AuthenticationSource</literal> will be queried by the
|
||||
<literal>ContextSource</literal> for principal and credentials each
|
||||
@@ -84,7 +84,7 @@
|
||||
</example>
|
||||
|
||||
<note>
|
||||
<para>We don't specify any <literal>userName</literal> or
|
||||
<para>We don't specify any <literal>userDn</literal> or
|
||||
<literal>password</literal> to our <literal>ContextSource</literal>
|
||||
when using an <literal>AuthenticationSource</literal> - these
|
||||
properties are needed only when the default behaviour is
|
||||
|
||||
@@ -184,7 +184,7 @@ public class PersonDaoImpl implements PersonDao {
|
||||
<bean id="contextSource" class="org.springframework.ldap.support.LdapContextSource">
|
||||
<property name="url" value="ldap://localhost:389" />
|
||||
<property name="base" value="dc=example,dc=com" />
|
||||
<property name="userName" value="cn=Manager" />
|
||||
<property name="userDn" value="cn=Manager" />
|
||||
<property name="password" value="secret" />
|
||||
</bean>
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
urls=ldap://127.0.0.1
|
||||
userName=cn=manager,dc=jayway,dc=se
|
||||
userDn=cn=manager,dc=jayway,dc=se
|
||||
password=secret
|
||||
base=dc=jayway,dc=se
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
<bean id="contextSource" class="org.springframework.ldap.support.LdapContextSource" >
|
||||
<property name="urls" value="${urls}" />
|
||||
<property name="userName" value="${userName}" />
|
||||
<property name="userDn" value="${userDn}" />
|
||||
<property name="password" value="${password}" />
|
||||
<property name="base" value="${base}" />
|
||||
<property name="dirObjectFactory" value="org.springframework.ldap.support.DefaultDirObjectFactory" />
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
simple
|
||||
</prop>
|
||||
<prop key="java.naming.security.principal">
|
||||
${userName}
|
||||
${userDn}
|
||||
</prop>
|
||||
<prop key="java.naming.security.credentials">
|
||||
${password}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
urls=ldap://127.0.0.1:3900
|
||||
userName=uid=admin,ou=system
|
||||
userDn=uid=admin,ou=system
|
||||
password=secret
|
||||
base=dc=jayway,dc=se
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
|
||||
<bean id="contextSource2" class="org.springframework.ldap.support.LdapContextSource" >
|
||||
<property name="urls" value="ldap://127.0.0.1:389,ldap://127.0.0.2:389" />
|
||||
<property name="userName" value="cn=dummy" />
|
||||
<property name="userDn" value="cn=dummy" />
|
||||
<property name="password" value="dummy" />
|
||||
</bean>
|
||||
</beans>
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
<bean id="initialDirContextFactory"
|
||||
class="org.acegisecurity.ldap.DefaultInitialDirContextFactory">
|
||||
<constructor-arg value="${urls}/${base}" />
|
||||
<property name="managerDn" value="${userName}" />
|
||||
<property name="managerDn" value="${userDn}" />
|
||||
<property name="managerPassword" value="${password}" />
|
||||
</bean>
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
<bean id="contextSource" class="org.springframework.ldap.support.LdapContextSource" >
|
||||
<property name="urls" value="${urls}" />
|
||||
<property name="userName" value="${userName}" />
|
||||
<property name="userDn" value="${userDn}" />
|
||||
<property name="password" value="${password}" />
|
||||
<property name="dirObjectFactory" value="org.springframework.ldap.support.DefaultDirObjectFactory" />
|
||||
</bean>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
<bean id="contextSource" class="org.springframework.ldap.support.LdapContextSource" >
|
||||
<property name="urls" value="${urls}" />
|
||||
<property name="userName" value="${userName}" />
|
||||
<property name="userDn" value="${userDn}" />
|
||||
<property name="password" value="${password}" />
|
||||
<property name="base" value="${base}" />
|
||||
<property name="dirObjectFactory" value="org.springframework.ldap.support.DefaultDirObjectFactory" />
|
||||
|
||||
@@ -27,14 +27,14 @@ public interface AuthenticationSource {
|
||||
/**
|
||||
* Get the principal to use when creating an authenticated context.
|
||||
*
|
||||
* @return the principal (userName).
|
||||
* @return the principal (userDn).
|
||||
*/
|
||||
public String getPrincipal();
|
||||
|
||||
/**
|
||||
* Get the credentials to use when creating an authenticated context.
|
||||
*
|
||||
* @return the credentials (userName).
|
||||
* @return the credentials (password).
|
||||
*/
|
||||
public String getCredentials();
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ import org.springframework.ldap.core.ContextSource;
|
||||
* <p>
|
||||
* 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.
|
||||
* using the specified userDn and password.
|
||||
* <p>
|
||||
* <b>Note:</b> When using implementations of this class outside of a Spring
|
||||
* Context it is necessary to call {@link #afterPropertiesSet()} when all
|
||||
@@ -73,7 +73,7 @@ public abstract class AbstractContextSource implements ContextSource,
|
||||
|
||||
private DistinguishedName base;
|
||||
|
||||
protected String userName = "";
|
||||
protected String userDn = "";
|
||||
|
||||
protected String password = "";
|
||||
|
||||
@@ -123,7 +123,7 @@ public abstract class AbstractContextSource implements ContextSource,
|
||||
env
|
||||
.put(Context.SECURITY_PRINCIPAL, authenticationSource
|
||||
.getPrincipal());
|
||||
log.debug("Principal: '" + userName + "'");
|
||||
log.debug("Principal: '" + userDn + "'");
|
||||
env.put(Context.SECURITY_CREDENTIALS, authenticationSource
|
||||
.getCredentials());
|
||||
}
|
||||
@@ -250,9 +250,9 @@ public abstract class AbstractContextSource implements ContextSource,
|
||||
if (authenticationSource == null) {
|
||||
log.debug("AuthenticationSource not set - "
|
||||
+ "using default implementation");
|
||||
if (StringUtils.isBlank(userName)) {
|
||||
if (StringUtils.isBlank(userDn)) {
|
||||
log
|
||||
.warn("Property 'userName' not set - "
|
||||
.warn("Property 'userDn' not set - "
|
||||
+ "anonymous context will be used for read-write operations");
|
||||
} else if (StringUtils.isBlank(password)) {
|
||||
log.warn("Property 'password' not set - "
|
||||
@@ -304,13 +304,24 @@ public abstract class AbstractContextSource implements ContextSource,
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the user name (principal) to use for getting authenticated contexts.
|
||||
* Set the user distinguished name (principal) to use for getting authenticated contexts.
|
||||
*
|
||||
* @param userDn
|
||||
* the user distinguished name.
|
||||
*/
|
||||
public void setUserDn(String userDn) {
|
||||
this.userDn = userDn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the user distinguished name (principal) to use for getting authenticated contexts.
|
||||
*
|
||||
* @param userName
|
||||
* the user name.
|
||||
* the user distinguished name.
|
||||
* @deprecated Use {@link #setUserDn(String)} instead.
|
||||
*/
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
setUserDn(userName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -444,7 +455,7 @@ public abstract class AbstractContextSource implements ContextSource,
|
||||
class SimpleAuthenticationSource implements AuthenticationSource {
|
||||
|
||||
public String getPrincipal() {
|
||||
return userName;
|
||||
return userDn;
|
||||
}
|
||||
|
||||
public String getCredentials() {
|
||||
|
||||
@@ -76,7 +76,7 @@ public class LdapContextSourceTest extends TestCase {
|
||||
tested.setBase("dc=example,dc=se");
|
||||
tested.setUrl("ldap://ldap.example.com:389");
|
||||
tested.setPooled(true);
|
||||
tested.setUserName("cn=Some User");
|
||||
tested.setUserDn("cn=Some User");
|
||||
tested.setPassword("secret");
|
||||
tested.afterPropertiesSet();
|
||||
Hashtable env = tested.getAnonymousEnv();
|
||||
@@ -103,7 +103,7 @@ public class LdapContextSourceTest extends TestCase {
|
||||
tested.setBase("dc=example,dc=se");
|
||||
tested.setUrl("ldap://ldap.example.com:389");
|
||||
tested.setPooled(true);
|
||||
tested.setUserName("cn=Some User");
|
||||
tested.setUserDn("cn=Some User");
|
||||
tested.setPassword("secret");
|
||||
tested.afterPropertiesSet();
|
||||
|
||||
@@ -158,7 +158,7 @@ public class LdapContextSourceTest extends TestCase {
|
||||
tested.setBase("dc=example,dc=se");
|
||||
tested.setUrl("ldap://ldap.example.com:389");
|
||||
tested.setPooled(true);
|
||||
tested.setUserName("cn=Some User");
|
||||
tested.setUserDn("cn=Some User");
|
||||
tested.setPassword("secret");
|
||||
tested.setCacheEnvironmentProperties(false);
|
||||
tested.afterPropertiesSet();
|
||||
|
||||
Reference in New Issue
Block a user