mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-01 09:42:13 +00:00
SEC-1732: Implement loading of multiple LDIF resources.
This commit is contained in:
parent
25ebc5e5f4
commit
491ca545ae
@ -33,7 +33,7 @@ public final class ApacheDSServerIntegrationTests {
|
|||||||
// contextSource = new DefaultSpringSecurityContextSource("ldap://127.0.0.1:22389/dc=springsource,dc=com");
|
// contextSource = new DefaultSpringSecurityContextSource("ldap://127.0.0.1:22389/dc=springsource,dc=com");
|
||||||
// contextSource.setUserDn("cn=admin,dc=springsource,dc=com");
|
// contextSource.setUserDn("cn=admin,dc=springsource,dc=com");
|
||||||
// contextSource.setPassword("password");
|
// contextSource.setPassword("password");
|
||||||
server = new ApacheDSContainer("dc=springframework,dc=org", "classpath:test-server.ldif");
|
server = new ApacheDSContainer("dc=springframework,dc=org", "classpath*:*.ldif");
|
||||||
server.setPort(53389);
|
server.setPort(53389);
|
||||||
server.afterPropertiesSet();
|
server.afterPropertiesSet();
|
||||||
}
|
}
|
||||||
|
39
ldap/src/integration-test/resources/base-server.ldif
Normal file
39
ldap/src/integration-test/resources/base-server.ldif
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
dn: ou=people,dc=springframework,dc=org
|
||||||
|
objectclass: top
|
||||||
|
objectclass: organizationalUnit
|
||||||
|
ou: people
|
||||||
|
|
||||||
|
dn: ou=otherpeople,dc=springframework,dc=org
|
||||||
|
objectclass: top
|
||||||
|
objectclass: organizationalUnit
|
||||||
|
ou: otherpeople
|
||||||
|
|
||||||
|
dn: uid=ben,ou=people,dc=springframework,dc=org
|
||||||
|
objectclass: top
|
||||||
|
objectclass: person
|
||||||
|
objectclass: organizationalPerson
|
||||||
|
objectclass: inetOrgPerson
|
||||||
|
cn: Ben Alex
|
||||||
|
sn: Alex
|
||||||
|
uid: ben
|
||||||
|
userPassword: {SHA}nFCebWjxfaLbHHG1Qk5UU4trbvQ=
|
||||||
|
|
||||||
|
dn: uid=bob,ou=people,dc=springframework,dc=org
|
||||||
|
objectclass: top
|
||||||
|
objectclass: person
|
||||||
|
objectclass: organizationalPerson
|
||||||
|
objectclass: inetOrgPerson
|
||||||
|
cn: Bob Hamilton
|
||||||
|
sn: Hamilton
|
||||||
|
uid: bob
|
||||||
|
userPassword: bobspassword
|
||||||
|
|
||||||
|
dn: uid=joe,ou=otherpeople,dc=springframework,dc=org
|
||||||
|
objectclass: top
|
||||||
|
objectclass: person
|
||||||
|
objectclass: organizationalPerson
|
||||||
|
objectclass: inetOrgPerson
|
||||||
|
cn: Joe Smeth
|
||||||
|
sn: Smeth
|
||||||
|
uid: joe
|
||||||
|
userPassword: joespassword
|
49
ldap/src/integration-test/resources/odd-chars.ldif
Normal file
49
ldap/src/integration-test/resources/odd-chars.ldif
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
dn: ou=space cadets,dc=springframework,dc=org
|
||||||
|
objectclass: top
|
||||||
|
objectclass: organizationalUnit
|
||||||
|
ou: space cadets
|
||||||
|
|
||||||
|
dn: ou=\"quoted people\",dc=springframework,dc=org
|
||||||
|
objectclass: top
|
||||||
|
objectclass: organizationalUnit
|
||||||
|
ou: "quoted people"
|
||||||
|
|
||||||
|
dn: cn=mouse\, jerry,ou=people,dc=springframework,dc=org
|
||||||
|
objectclass: top
|
||||||
|
objectclass: person
|
||||||
|
objectclass: organizationalPerson
|
||||||
|
objectclass: inetOrgPerson
|
||||||
|
cn: Mouse, Jerry
|
||||||
|
sn: Mouse
|
||||||
|
uid: jerry
|
||||||
|
userPassword: jerryspassword
|
||||||
|
|
||||||
|
dn: cn=slash/guy,ou=people,dc=springframework,dc=org
|
||||||
|
objectclass: top
|
||||||
|
objectclass: person
|
||||||
|
objectclass: organizationalPerson
|
||||||
|
objectclass: inetOrgPerson
|
||||||
|
cn: slash/guy
|
||||||
|
sn: Slash
|
||||||
|
uid: slashguy
|
||||||
|
userPassword: slashguyspassword
|
||||||
|
|
||||||
|
dn: cn=quote\"guy,ou=\"quoted people\",dc=springframework,dc=org
|
||||||
|
objectclass: top
|
||||||
|
objectclass: person
|
||||||
|
objectclass: organizationalPerson
|
||||||
|
objectclass: inetOrgPerson
|
||||||
|
cn: quote\"guy
|
||||||
|
sn: Quote
|
||||||
|
uid: quoteguy
|
||||||
|
userPassword: quoteguyspassword
|
||||||
|
|
||||||
|
dn: uid=space cadet,ou=space cadets,dc=springframework,dc=org
|
||||||
|
objectclass: top
|
||||||
|
objectclass: person
|
||||||
|
objectclass: organizationalPerson
|
||||||
|
objectclass: inetOrgPerson
|
||||||
|
cn: Space Cadet
|
||||||
|
sn: Cadet
|
||||||
|
uid: space cadet
|
||||||
|
userPassword: spacecadetspassword
|
@ -1,124 +0,0 @@
|
|||||||
dn: ou=groups,dc=springframework,dc=org
|
|
||||||
objectclass: top
|
|
||||||
objectclass: organizationalUnit
|
|
||||||
ou: groups
|
|
||||||
|
|
||||||
dn: ou=subgroups,ou=groups,dc=springframework,dc=org
|
|
||||||
objectclass: top
|
|
||||||
objectclass: organizationalUnit
|
|
||||||
ou: subgroups
|
|
||||||
|
|
||||||
dn: ou=people,dc=springframework,dc=org
|
|
||||||
objectclass: top
|
|
||||||
objectclass: organizationalUnit
|
|
||||||
ou: people
|
|
||||||
|
|
||||||
dn: ou=space cadets,dc=springframework,dc=org
|
|
||||||
objectclass: top
|
|
||||||
objectclass: organizationalUnit
|
|
||||||
ou: space cadets
|
|
||||||
|
|
||||||
dn: ou=\"quoted people\",dc=springframework,dc=org
|
|
||||||
objectclass: top
|
|
||||||
objectclass: organizationalUnit
|
|
||||||
ou: "quoted people"
|
|
||||||
|
|
||||||
dn: ou=otherpeople,dc=springframework,dc=org
|
|
||||||
objectclass: top
|
|
||||||
objectclass: organizationalUnit
|
|
||||||
ou: otherpeople
|
|
||||||
|
|
||||||
dn: uid=ben,ou=people,dc=springframework,dc=org
|
|
||||||
objectclass: top
|
|
||||||
objectclass: person
|
|
||||||
objectclass: organizationalPerson
|
|
||||||
objectclass: inetOrgPerson
|
|
||||||
cn: Ben Alex
|
|
||||||
sn: Alex
|
|
||||||
uid: ben
|
|
||||||
userPassword: {SHA}nFCebWjxfaLbHHG1Qk5UU4trbvQ=
|
|
||||||
|
|
||||||
dn: uid=bob,ou=people,dc=springframework,dc=org
|
|
||||||
objectclass: top
|
|
||||||
objectclass: person
|
|
||||||
objectclass: organizationalPerson
|
|
||||||
objectclass: inetOrgPerson
|
|
||||||
cn: Bob Hamilton
|
|
||||||
sn: Hamilton
|
|
||||||
uid: bob
|
|
||||||
userPassword: bobspassword
|
|
||||||
|
|
||||||
dn: uid=joe,ou=otherpeople,dc=springframework,dc=org
|
|
||||||
objectclass: top
|
|
||||||
objectclass: person
|
|
||||||
objectclass: organizationalPerson
|
|
||||||
objectclass: inetOrgPerson
|
|
||||||
cn: Joe Smeth
|
|
||||||
sn: Smeth
|
|
||||||
uid: joe
|
|
||||||
userPassword: joespassword
|
|
||||||
|
|
||||||
dn: cn=mouse\, jerry,ou=people,dc=springframework,dc=org
|
|
||||||
objectclass: top
|
|
||||||
objectclass: person
|
|
||||||
objectclass: organizationalPerson
|
|
||||||
objectclass: inetOrgPerson
|
|
||||||
cn: Mouse, Jerry
|
|
||||||
sn: Mouse
|
|
||||||
uid: jerry
|
|
||||||
userPassword: jerryspassword
|
|
||||||
|
|
||||||
dn: cn=slash/guy,ou=people,dc=springframework,dc=org
|
|
||||||
objectclass: top
|
|
||||||
objectclass: person
|
|
||||||
objectclass: organizationalPerson
|
|
||||||
objectclass: inetOrgPerson
|
|
||||||
cn: slash/guy
|
|
||||||
sn: Slash
|
|
||||||
uid: slashguy
|
|
||||||
userPassword: slashguyspassword
|
|
||||||
|
|
||||||
dn: cn=quote\"guy,ou=\"quoted people\",dc=springframework,dc=org
|
|
||||||
objectclass: top
|
|
||||||
objectclass: person
|
|
||||||
objectclass: organizationalPerson
|
|
||||||
objectclass: inetOrgPerson
|
|
||||||
cn: quote\"guy
|
|
||||||
sn: Quote
|
|
||||||
uid: quoteguy
|
|
||||||
userPassword: quoteguyspassword
|
|
||||||
|
|
||||||
dn: uid=space cadet,ou=space cadets,dc=springframework,dc=org
|
|
||||||
objectclass: top
|
|
||||||
objectclass: person
|
|
||||||
objectclass: organizationalPerson
|
|
||||||
objectclass: inetOrgPerson
|
|
||||||
cn: Space Cadet
|
|
||||||
sn: Cadet
|
|
||||||
uid: space cadet
|
|
||||||
userPassword: spacecadetspassword
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
dn: cn=developers,ou=groups,dc=springframework,dc=org
|
|
||||||
objectclass: top
|
|
||||||
objectclass: groupOfNames
|
|
||||||
cn: developers
|
|
||||||
ou: developer
|
|
||||||
member: uid=ben,ou=people,dc=springframework,dc=org
|
|
||||||
member: uid=bob,ou=people,dc=springframework,dc=org
|
|
||||||
|
|
||||||
dn: cn=managers,ou=groups,dc=springframework,dc=org
|
|
||||||
objectclass: top
|
|
||||||
objectclass: groupOfNames
|
|
||||||
cn: managers
|
|
||||||
ou: manager
|
|
||||||
member: uid=ben,ou=people,dc=springframework,dc=org
|
|
||||||
member: cn=mouse\, jerry,ou=people,dc=springframework,dc=org
|
|
||||||
|
|
||||||
dn: cn=submanagers,ou=subgroups,ou=groups,dc=springframework,dc=org
|
|
||||||
objectclass: top
|
|
||||||
objectclass: groupOfNames
|
|
||||||
cn: submanagers
|
|
||||||
ou: submanager
|
|
||||||
member: uid=ben,ou=people,dc=springframework,dc=org
|
|
32
ldap/src/integration-test/resources/user-groups.ldif
Normal file
32
ldap/src/integration-test/resources/user-groups.ldif
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
dn: ou=groups,dc=springframework,dc=org
|
||||||
|
objectclass: top
|
||||||
|
objectclass: organizationalUnit
|
||||||
|
ou: groups
|
||||||
|
|
||||||
|
dn: cn=developers,ou=groups,dc=springframework,dc=org
|
||||||
|
objectclass: top
|
||||||
|
objectclass: groupOfNames
|
||||||
|
cn: developers
|
||||||
|
ou: developer
|
||||||
|
member: uid=ben,ou=people,dc=springframework,dc=org
|
||||||
|
member: uid=bob,ou=people,dc=springframework,dc=org
|
||||||
|
|
||||||
|
dn: cn=managers,ou=groups,dc=springframework,dc=org
|
||||||
|
objectclass: top
|
||||||
|
objectclass: groupOfNames
|
||||||
|
cn: managers
|
||||||
|
ou: manager
|
||||||
|
member: uid=ben,ou=people,dc=springframework,dc=org
|
||||||
|
member: cn=mouse\, jerry,ou=people,dc=springframework,dc=org
|
||||||
|
|
||||||
|
dn: ou=subgroups,ou=groups,dc=springframework,dc=org
|
||||||
|
objectclass: top
|
||||||
|
objectclass: organizationalUnit
|
||||||
|
ou: subgroups
|
||||||
|
|
||||||
|
dn: cn=submanagers,ou=subgroups,ou=groups,dc=springframework,dc=org
|
||||||
|
objectclass: top
|
||||||
|
objectclass: groupOfNames
|
||||||
|
cn: submanagers
|
||||||
|
ou: submanager
|
||||||
|
member: uid=ben,ou=people,dc=springframework,dc=org
|
@ -35,7 +35,7 @@ import org.springframework.util.Assert;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides lifecycle services for the embedded apacheDS server defined by the supplied configuration.
|
* Provides lifecycle services for the embedded apacheDS server defined by the supplied configuration.
|
||||||
* Used by {code LdapServerBeanDefinitionParser}. An instance will be stored in the application context for
|
* Used by {@code LdapServerBeanDefinitionParser}. An instance will be stored in the application context for
|
||||||
* each embedded server instance. It will start the server when the context is initialized and shut it down when
|
* each embedded server instance. It will start the server when the context is initialized and shut it down when
|
||||||
* it is closed. It is intended for temporary embedded use and will not retain changes across start/stop boundaries. The
|
* it is closed. It is intended for temporary embedded use and will not retain changes across start/stop boundaries. The
|
||||||
* working directory is deleted on shutdown.
|
* working directory is deleted on shutdown.
|
||||||
@ -227,18 +227,13 @@ public class ApacheDSContainer implements InitializingBean, DisposableBean, Life
|
|||||||
ldifs = ctxt.getResources(ldifResources);
|
ldifs = ctxt.getResources(ldifResources);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note that we can't just import using the ServerContext returned
|
for(Resource r : ldifs) {
|
||||||
// from starting Apache DS, apparently because of the long-running issue DIRSERVER-169.
|
|
||||||
// We need a standard context.
|
|
||||||
//DirContext dirContext = contextSource.getReadWriteContext();
|
|
||||||
|
|
||||||
if(ldifs != null && ldifs.length > 0) {
|
|
||||||
String ldifFile;
|
String ldifFile;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ldifFile = ldifs[0].getFile().getAbsolutePath();
|
ldifFile = r.getFile().getAbsolutePath();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
ldifFile = ldifs[0].getURI().toString();
|
ldifFile = r.getURI().toString();
|
||||||
}
|
}
|
||||||
logger.info("Loading LDIF file: " + ldifFile);
|
logger.info("Loading LDIF file: " + ldifFile);
|
||||||
LdifFileLoader loader = new LdifFileLoader(service.getAdminSession(), ldifFile);
|
LdifFileLoader loader = new LdifFileLoader(service.getAdminSession(), ldifFile);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user