Made sure integration tests for article sample automatically start in-process LDAP server.
DirContextAdapter#setDn() now throws IllegalStateException if setDn is called on an instance in update mode (this was previously silently ignored) Fixed problem in LdapTreeBuilder caused by the new behaviour of DN in DirContextAdapter (i.e. that the actual DN instance of the DirContextAdapter is no longer returned by getDn()).
This commit is contained in:
@@ -24,6 +24,14 @@ Changes in version 1.3.0 (Nov 2008)
|
||||
* Made sure DirContextOperations#addAttributeValue(String, Object) does not add any duplicate
|
||||
values per default; added alternate method: DirContextOperations#addAttributeValue(String, Object, boolean)
|
||||
to enable behavior other than the default (i.e. allowing duplicates).
|
||||
|
||||
* Made sure that DirContextAdapter#setDn() throws exception if in update mode
|
||||
(The value is not set anyway, and this was previously silently ignored).
|
||||
|
||||
* Made sure article sample tests are possible to run without running web
|
||||
application (i.e. tests automatically start internal LDAP server) (LDAP-143).
|
||||
|
||||
* Added spring-tx as required dependency (the DataAccessExceptions require this).
|
||||
|
||||
Changes in version 1.3.0.RC1 (Oct 2008)
|
||||
-------------------------------------------
|
||||
@@ -42,7 +50,7 @@ Changes in version 1.3.0.RC1 (Oct 2008)
|
||||
|
||||
* The hard dependency on LDAP Booster Pack has now been completely removed,
|
||||
preventing NoClassDefFoundErrors when using Paged Results without that
|
||||
library on the classpath. (LDAP-110, LDAP-118)
|
||||
library on the classpath. (LDAP-110, LDAP-118)
|
||||
|
||||
* The dreaded problem with '\' in Distinguished Names is now resolved.
|
||||
(LDAP-50, LDAP-109)
|
||||
|
||||
@@ -68,6 +68,10 @@
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-beans</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-tx</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
|
||||
@@ -1262,6 +1262,11 @@ public class DirContextAdapter implements DirContextOperations {
|
||||
if (!updateMode) {
|
||||
this.dn = new DistinguishedName(dn.toString());
|
||||
}
|
||||
else {
|
||||
throw new IllegalStateException(
|
||||
"Not possible to call setDn() on a DirContextAdapter in update mode");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,11 +8,14 @@
|
||||
<property name="location" value="classpath:/config/ldap.properties" />
|
||||
</bean>
|
||||
|
||||
<bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource" >
|
||||
<property name="urls" value="${urls}" />
|
||||
<property name="userDn" value="${userDn}" />
|
||||
<bean id="contextSource"
|
||||
class="org.springframework.ldap.test.TestContextSourceFactoryBean">
|
||||
<property name="defaultPartitionSuffix" value="dc=jayway,dc=se" />
|
||||
<property name="defaultPartitionName" value="jayway" />
|
||||
<property name="principal" value="${userDn}" />
|
||||
<property name="password" value="${password}" />
|
||||
<property name="base" value="${base}" />
|
||||
<property name="ldifFile" value="/setup_data.ldif" />
|
||||
<property name="port" value="3901" />
|
||||
</bean>
|
||||
|
||||
<bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
|
||||
@@ -26,7 +29,7 @@
|
||||
|
||||
<bean id="traditionalPersonDao"
|
||||
class="org.springframework.ldap.samples.article.dao.TraditionalPersonDaoImpl">
|
||||
<property name="url" value="ldap://localhost:3900" />
|
||||
<property name="url" value="ldap://localhost:3901" />
|
||||
<property name="base" value="dc=jayway,dc=se" />
|
||||
<property name="userDn" value="${userDn}" />
|
||||
<property name="password" value="${password}" />
|
||||
|
||||
35
samples/article/src/test/resources/setup_data.ldif
Normal file
35
samples/article/src/test/resources/setup_data.ldif
Normal file
@@ -0,0 +1,35 @@
|
||||
dn: c=Sweden,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: country
|
||||
c: Sweden
|
||||
description: The country of Sweden
|
||||
|
||||
dn: ou=company1,c=Sweden,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: organizationalUnit
|
||||
ou: company1
|
||||
description: First company in Sweden
|
||||
|
||||
dn: cn=Some Person,ou=company1,c=Sweden,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: person
|
||||
objectclass: organizationalPerson
|
||||
objectclass: inetOrgPerson
|
||||
uid: some.person
|
||||
userPassword: password
|
||||
cn: Some Person
|
||||
sn: Person
|
||||
description: Sweden, Company1, Some Person
|
||||
telephoneNumber: +46 555-123456
|
||||
|
||||
dn: cn=Some Person2,ou=company1,c=Sweden,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: person
|
||||
objectclass: organizationalPerson
|
||||
objectclass: inetOrgPerson
|
||||
uid: some.person2
|
||||
userPassword: password
|
||||
cn: Some Person2
|
||||
sn: Person2
|
||||
description: Sweden, Company1, Some Person2
|
||||
telephoneNumber: +46 555-654321
|
||||
@@ -14,22 +14,24 @@ public class LdapTreeBuilder {
|
||||
}
|
||||
|
||||
public LdapTree getLdapTree(DistinguishedName root) {
|
||||
DirContextOperations context = ldapTemplate.lookupContext(root.toString());
|
||||
DirContextOperations context = ldapTemplate.lookupContext(root
|
||||
.toString());
|
||||
return getLdapTree(context);
|
||||
}
|
||||
|
||||
private LdapTree getLdapTree(final DirContextOperations rootContext) {
|
||||
final LdapTree ldapTree = new LdapTree(rootContext);
|
||||
ldapTemplate.listBindings(rootContext.getDn(), new AbstractContextMapper() {
|
||||
@Override
|
||||
protected Object doMapFromContext(DirContextOperations ctx) {
|
||||
DistinguishedName dn = (DistinguishedName) ctx.getDn();
|
||||
dn.prepend((DistinguishedName) rootContext.getDn());
|
||||
|
||||
ldapTree.addSubTree(getLdapTree(ctx));
|
||||
return null;
|
||||
}
|
||||
});
|
||||
ldapTemplate.listBindings(rootContext.getDn(),
|
||||
new AbstractContextMapper() {
|
||||
@Override
|
||||
protected Object doMapFromContext(DirContextOperations ctx) {
|
||||
DistinguishedName dn = (DistinguishedName) ctx.getDn();
|
||||
dn.prepend((DistinguishedName) rootContext.getDn());
|
||||
ldapTree.addSubTree(getLdapTree(ldapTemplate
|
||||
.lookupContext(dn)));
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
return ldapTree;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user