+++ /dev/null
-dn: dc=demo,dc=argeo,dc=org
-objectClass: domain
-objectClass: extensibleObject
-objectClass: top
-dc: springsecurity
-
-dn: ou=groups,dc=demo,dc=argeo,dc=org
-objectClass: organizationalUnit
-objectClass: top
-ou: groups
-
-dn: ou=users,dc=demo,dc=argeo,dc=org
-objectClass: organizationalUnit
-objectClass: top
-ou: users
-
-dn: uid=demo,ou=users,dc=demo,dc=argeo,dc=org
-objectClass: organizationalPerson
-objectClass: person
-objectClass: inetOrgPerson
-objectClass: top
-cn: demo User
-description: Demo user
-givenname: Demo
-mail: demo@localhost
-sn: User
-uid: demo
-userpassword:: e1NIQX1pZVNWNTVRYytlUU9hWURSU2hhL0Fqek5USkU9
-
-dn: uid=root,ou=users,dc=demo,dc=argeo,dc=org
-objectClass: person
-objectClass: inetOrgPerson
-objectClass: organizationalPerson
-objectClass: top
-cn: demo User
-description: Superuser
-givenname: Root
-mail: root@localhost
-sn: Root
-uid: root
-userpassword:: e1NIQX1pZVNWNTVRYytlUU9hWURSU2hhL0Fqek5USkU9
-
-dn: uid=frodo,ou=users,dc=demo,dc=argeo,dc=org
-objectClass: person
-objectClass: inetOrgPerson
-objectClass: organizationalPerson
-objectClass: top
-cn: demo User
-description: Heroe
-givenname: Frodo
-mail: frodo@localhost
-sn: User
-uid: frodo
-userpassword:: e1NIQX1pZVNWNTVRYytlUU9hWURSU2hhL0Fqek5USkU9
-
-dn: uid=gandalf,ou=users,dc=demo,dc=argeo,dc=org
-objectClass: organizationalPerson
-objectClass: person
-objectClass: inetOrgPerson
-objectClass: top
-cn: root User
-description: Superuser
-givenname: Gandalf
-mail: admin@localhost
-sn: User
-uid: gandalf
-userpassword:: e1NIQX1pZVNWNTVRYytlUU9hWURSU2hhL0Fqek5USkU9
-
-dn: cn=admin,ou=groups,dc=demo,dc=argeo,dc=org
-objectClass: groupOfUniqueNames
-objectClass: top
-cn: admin
-uniquemember: uid=gandalf,ou=users,dc=demo,dc=argeo,dc=org
-uniquemember: uid=root,ou=users,dc=demo,dc=argeo,dc=org
--- /dev/null
+Bundle-SymbolicName: org.argeo.security.demo.ldap
+Bundle-Version: 0.1.2.SNAPSHOT
+Fragment-Host: org.argeo.security.manager.ldap
--- /dev/null
+argeo.ldap.rootdn=dc=demo,dc=argeo,dc=org
+argeo.ldap.host=localhost
+argeo.ldap.port=10389
+argeo.ldap.manager.userdn=uid=admin,ou=system
+argeo.ldap.manager.password=secret
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.argeo.commons</groupId>
</argsToAppend>
<fork>false</fork>
<systemProperties>
- <slc.osgi.start>
+ <argeo.osgi.start>
org.springframework.osgi.extender,
org.springframework.osgi.web.extender,
org.argeo.dep.osgi.catalina.start,
org.argeo.security.ria,
org.argeo.security.core,
org.argeo.server.ads.server
- </slc.osgi.start>
- <slc.osgi.bundles>
+ </argeo.osgi.start>
+ <argeo.osgi.bundles>
${basedir};in=*;ex=pom.xml;ex=target;ex=.*;ex=*.ldif,
${basedir}/../modules;in=*;ex=pom.xml;ex=target;ex=.*,
${basedir}/../../server/modules;in=*;ex=pom.xml;ex=target;ex=.*,
- </slc.osgi.bundles>
+ </argeo.osgi.bundles>
</systemProperties>
</configuration>
</plugin>
<groupId>org.springframework.osgi</groupId>
<artifactId>org.springframework.osgi.web.extender</artifactId>
</dependency>
+
+ <!-- Used to start the Apache Directory server -->
+ <dependency>
+ <groupId>org.argeo.commons.server</groupId>
+ <artifactId>org.argeo.server.ads</artifactId>
+ <version>0.1.2-SNAPSHOT</version>
+ </dependency>
+
</dependencies>
</project>
\ No newline at end of file
Bundle-Version: 0.1.2.SNAPSHOT
Import-Package: org.argeo.security,
org.argeo.security.ldap,
+ org.springframework.beans.factory.config,
org.springframework.ldap.core.support,
org.springframework.security,
org.springframework.security.ldap,
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
+ xsi:schemaLocation="http://www.springframework.org/schema/osgi \r
+ http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
+ http://www.springframework.org/schema/beans \r
+ http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
+\r
+ <service ref="_authenticationManager"\r
+ interface="org.springframework.security.AuthenticationManager"\r
+ context-class-loader="service-provider" />\r
+\r
+ <service ref="securityDao" interface="org.argeo.security.ArgeoSecurityDao" />\r
+\r
+ <list id="userNatureMappers" interface="org.argeo.security.ldap.UserNatureMapper"\r
+ cardinality="0..N" />\r
+</beans:beans>
\ No newline at end of file
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.4.xsd">
+ <bean
+ class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
+ <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
+ <property name="ignoreUnresolvablePlaceholders" value="true" />
+ <property name="locations">
+ <value>osgibundle:ldap.properties
+ </value>
+ </property>
+ </bean>
+
<bean id="_authenticationManager" class="org.springframework.security.providers.ProviderManager">
<property name="providers">
<list>
<bean id="contextSource"
class="org.springframework.security.ldap.DefaultSpringSecurityContextSource">
- <constructor-arg value="ldap://localhost:10389/dc=demo,dc=argeo,dc=org" />
- <property name="userDn" value="uid=admin,ou=system" />
- <property name="password" value="secret" />
+ <constructor-arg
+ value="ldap://${argeo.ldap.host}:${argeo.ldap.port}/${argeo.ldap.rootdn}" />
+ <property name="userDn" value="${argeo.ldap.manager.userdn}" />
+ <property name="password" value="${argeo.ldap.manager.password}" />
</bean>
<bean id="authenticationProvider"
name="usernameMapper"> <bean
class="org.springframework.security.ldap.DefaultLdapUsernameToDnMapper">
<constructor-arg value="ou=users" /> <constructor-arg value="uid" />
- </bean> </property> </bean>
- <bean id="userDetailsMapper" class="org.argeo.security.ldap.ArgeoUserDetailsContextMapper">
- <property name="userNatureMappers" ref="userNatureMappers" />
- </bean>
+ </bean> </property> </bean> <bean id="userDetailsMapper"
+ class="org.argeo.security.ldap.ArgeoUserDetailsContextMapper">
+ <property name="userNatureMappers" ref="userNatureMappers" /> </bean>
-->
</beans>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
- xsi:schemaLocation="http://www.springframework.org/schema/osgi \r
- http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
- http://www.springframework.org/schema/beans \r
- http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
-\r
- <service ref="_authenticationManager"\r
- interface="org.springframework.security.AuthenticationManager"\r
- context-class-loader="service-provider" />\r
-\r
- <service ref="securityDao" interface="org.argeo.security.ArgeoSecurityDao" />\r
-\r
- <list id="userNatureMappers" interface="org.argeo.security.ldap.UserNatureMapper"\r
- cardinality="0..N" />\r
-</beans:beans>
\ No newline at end of file
org.apache.directory.server.jndi,
org.apache.directory.server.ldap.support.extended,
org.apache.directory.shared.asn1.codec,
- org.springframework.beans.factory.config,
- org.springframework.ldap.core.support,
- org.springframework.security.config,
- org.springframework.security.ldap
+ org.argeo.server.ads,
+ org.springframework.beans.factory.config
-<beans:beans xmlns="http://www.springframework.org/schema/security"
- xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
- http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.4.xsd">
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
- <ldap-server root="dc=demo,dc=argeo,dc=org" port="10389"
- ldif="file:init.ldif" />
+ <bean
+ class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
+ <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
+ <property name="ignoreUnresolvablePlaceholders" value="false" />
+ <property name="locations">
+ <value>osgibundle:ads.properties
+ </value>
+ </property>
+ </bean>
-</beans:beans>
+ <bean class="org.argeo.server.ads.AdsContainer">
+ <property name="workingDirectory" value="${argeo.osgi.data.dir}/apacheds" />
+ <property name="deleteWorkingDirOnExit" value="true" />
+ <property name="configuration" ref="configuration" />
+ <property name="environment" ref="environment" />
+ <property name="ldifs">
+ <list>
+ <value>osgibundle:init.ldif</value>
+ </list>
+ </property>
+ </bean>
+
+ <bean id="environment"
+ class="org.springframework.beans.factory.config.PropertiesFactoryBean">
+ <property name="properties">
+ <props>
+ <prop key="java.naming.security.authentication">simple</prop>
+ <prop key="java.naming.security.principal">${argeo.ldap.manager.userdn}</prop>
+ <prop key="java.naming.security.credentials">${argeo.ldap.manager.password}</prop>
+ <!--<prop key="kdc.entryBaseDn">ou=users,dc=example,dc=com</prop>-->
+ <!--<prop key="kdc.java.naming.security.credentials">secret</prop>-->
+ <!--
+ <prop key="changepw.entryBaseDn">ou=users,dc=example,dc=com</prop>
+ -->
+ <!--
+ <prop key="changepw.java.naming.security.credentials">secret</prop>
+ -->
+ <!--
+ Set this key to a space delimited set of attributeType descriptions
+ and their OID's if you want an attributeType to be handled as
+ binary content. The server will use the schema to derive the set of
+ attributeTypes to treat as binary. The union if the values you
+ provide here will be taken as the set of binaries. Note to be
+ consistent you must add both the OID and all the names an
+ attributeType can have.
+ -->
+ <!--
+ <prop key="java.naming.ldap.attributes.binary"></prop>
+ -->
+ </props>
+ </property>
+ </bean>
+
+
+</beans>
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
- <bean id="environment"
- class="org.springframework.beans.factory.config.PropertiesFactoryBean">
- <property name="properties">
- <props>
- <prop key="java.naming.security.authentication">simple</prop>
- <prop key="java.naming.security.principal">uid=admin,ou=system</prop>
- <prop key="java.naming.security.credentials">secret</prop>
- <!--<prop key="kdc.entryBaseDn">ou=users,dc=example,dc=com</prop>-->
- <!--<prop key="kdc.java.naming.security.credentials">secret</prop>-->
- <!--
- <prop key="changepw.entryBaseDn">ou=users,dc=example,dc=com</prop>
- -->
- <!--
- <prop key="changepw.java.naming.security.credentials">secret</prop>
- -->
- <!--
- Set this key to a space delimited set of attributeType descriptions
- and their OID's if you want an attributeType to be handled as
- binary content. The server will use the schema to derive the set of
- attributeTypes to treat as binary. The union if the values you
- provide here will be taken as the set of binaries. Note to be
- consistent you must add both the OID and all the names an
- attributeType can have.
- -->
- <!--
- <prop key="java.naming.ldap.attributes.binary"></prop>
- -->
- </props>
- </property>
- </bean>
-
<bean id="configuration"
class="org.apache.directory.server.configuration.MutableServerStartupConfiguration">
<property name="workingDirectory" value="example.com" />
-->
<!--
- <property name="ldifDirectory"> <value>example.ldif</value>
- </property> <property name="ldifFilters"> <list> <bean
- class="org.apache.directory.server.protocol.shared.store.Krb5KdcEntryFilter"/>
- </list> </property>
+ <property name="ldifDirectory">
+ <value>${argeo.ads.init.ldif}</value>
+ </property> -->
+
+ <!--
+ <property name="ldifFilters"> <list> <bean
+ class="org.apache.directory.server.protocol.shared.store.Krb5KdcEntryFilter"
+ /> </list> </property>
-->
+
<!--
the number of milliseconds before issuing a synch (flush to disk)
-->
-->
<property name="denormalizeOpAttrsEnabled" value="false" />
- <property name="ldapPort" value="10389" />
+ <property name="ldapPort" value="${argeo.ldap.port}" />
<property name="systemPartitionConfiguration" ref="systemPartitionConfiguration" />
</set>
</property>
<property name="contextEntry">
- <value>
+ <value><![CDATA[
objectClass: top
objectClass: organizationalUnit
- objectClass: extensibleObject
+ objectClass:extensibleObject
ou: system
- </value>
+ ]]></value>
</property>
</bean>
class="org.apache.directory.server.core.partition.impl.btree.MutableBTreePartitionConfiguration">
<property name="name" value="example" />
<property name="cacheSize" value="100" />
- <property name="suffix" value="dc=example,dc=com" />
+ <property name="suffix" value="${argeo.ldap.rootdn}" />
<!--
the optimizer is enabled by default but may not always be what
</set>
</property>
<property name="contextEntry">
- <value>
+ <value><![CDATA[
objectClass: top
objectClass: domain
objectClass: extensibleObject
dc: example
- </value>
+ ]]></value>
</property>
</bean>
--- /dev/null
+argeo.ldap.rootdn=dc=demo,dc=argeo,dc=org
+argeo.ldap.port=10389
+argeo.ldap.manager.userdn=uid=admin,ou=system
+argeo.ldap.manager.password=secret
--- /dev/null
+dn: dc=demo,dc=argeo,dc=org
+objectClass: domain
+objectClass: extensibleObject
+objectClass: top
+dc: springsecurity
+
+dn: ou=groups,dc=demo,dc=argeo,dc=org
+objectClass: organizationalUnit
+objectClass: top
+ou: groups
+
+dn: ou=users,dc=demo,dc=argeo,dc=org
+objectClass: organizationalUnit
+objectClass: top
+ou: users
+
+dn: uid=demo,ou=users,dc=demo,dc=argeo,dc=org
+objectClass: organizationalPerson
+objectClass: person
+objectClass: inetOrgPerson
+objectClass: top
+cn: demo User
+description: Demo user
+givenname: Demo
+mail: demo@localhost
+sn: User
+uid: demo
+userpassword:: e1NIQX1pZVNWNTVRYytlUU9hWURSU2hhL0Fqek5USkU9
+
+dn: uid=root,ou=users,dc=demo,dc=argeo,dc=org
+objectClass: person
+objectClass: inetOrgPerson
+objectClass: organizationalPerson
+objectClass: top
+cn: demo User
+description: Superuser
+givenname: Root
+mail: root@localhost
+sn: Root
+uid: root
+userpassword:: e1NIQX1pZVNWNTVRYytlUU9hWURSU2hhL0Fqek5USkU9
+
+dn: cn=admin,ou=groups,dc=demo,dc=argeo,dc=org
+objectClass: groupOfUniqueNames
+objectClass: top
+cn: admin
+uniquemember: uid=root,ou=users,dc=demo,dc=argeo,dc=org
org.springframework.security.ui.savedrequest;resolution:=optional,
org.springframework.security.userdetails;resolution:=optional,
org.springframework.security.context;resolution:=optional,
- org.argeo.security.core;resolution:=optional
+ org.argeo.security.core;resolution:=optional,
+ org.argeo.security.nature;resolution:=optional
-->
<Host name="localhost" appBase="webapps" unpackWARs="true"
autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"
- workDir="${slc.osgi.dataDir}/tomcat/work">
+ workDir="${argeo.osgi.data.dir}/tomcat/work">
<!--
SingleSignOn valve, share authentication between web applications
<version>0.1.2-SNAPSHOT</version>
<type>pom</type>
</dependency>
+
+ <!-- Used to start the Apache Directory server -->
+ <dependency>
+ <groupId>org.argeo.commons.server</groupId>
+ <artifactId>org.argeo.server.ads</artifactId>
+ <version>0.1.2-SNAPSHOT</version>
+ </dependency>
+
</dependencies>
</project>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="target/classes" path="src/main/java"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.argeo.server.ads</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
--- /dev/null
+#Mon Nov 23 13:34:23 CET 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.source=1.5
--- /dev/null
+#Mon Nov 23 13:34:22 CET 2009
+activeProfiles=
+eclipse.preferences.version=1
+fullBuildGoals=process-test-resources
+includeModules=false
+resolveWorkspaceProjects=true
+resourceFilterGoals=process-resources resources\:testResources
+skipCompilerPlugin=true
+version=1
--- /dev/null
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.argeo.commons.server</groupId>
+ <artifactId>runtime</artifactId>
+ <version>0.1.2-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+ <artifactId>org.argeo.server.ads</artifactId>
+ <name>Commons Server Apache Directory Server</name>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>${version.maven-bundle-plugin}</version>
+ <configuration>
+ <instructions>
+ <Export-Package>
+ org.argeo.server.ads.*
+ </Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <!-- Apache DS -->
+ <dependency>
+ <groupId>org.apache.directory</groupId>
+ <artifactId>com.springsource.org.apache.directory.server.jndi</artifactId>
+ </dependency>
+
+ <!-- Apache Commons -->
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>com.springsource.org.apache.commons.io</artifactId>
+ </dependency>
+
+ <!-- Spring -->
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>org.springframework.beans</artifactId>
+ </dependency>
+
+ <!-- Logging -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>com.springsource.slf4j.org.apache.commons.logging</artifactId>
+ </dependency>
+ </dependencies>
+</project>
--- /dev/null
+package org.argeo.server.ads;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.naming.directory.InitialDirContext;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.directory.server.configuration.MutableServerStartupConfiguration;
+import org.apache.directory.server.core.configuration.ShutdownConfiguration;
+import org.apache.directory.server.jndi.ServerContextFactory;
+import org.springframework.beans.factory.DisposableBean;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.core.io.Resource;
+import org.springframework.util.Assert;
+
+public class AdsContainer implements InitializingBean, DisposableBean {
+ private final static Log log = LogFactory.getLog(AdsContainer.class);
+
+ private MutableServerStartupConfiguration configuration;
+ private Properties environment = null;
+ private File workingDirectory = new File(System
+ .getProperty("java.io.tmpdir")
+ + File.separator + "argeo-apacheDirectoryServer");
+ private List<Resource> ldifs = new ArrayList<Resource>();
+ private File ldifDirectory;
+ private Boolean deleteWorkingDirOnExit = false;
+
+ @SuppressWarnings("unchecked")
+ public void afterPropertiesSet() throws Exception {
+
+ log.info("Starting directory server with id '"
+ + configuration.getInstanceId() + "' in directory "
+ + workingDirectory.getAbsolutePath());
+
+ if (deleteWorkingDirOnExit && workingDirectory.exists()) {
+ log.warn("Found existing directory " + workingDirectory
+ + " deleting it...");
+ FileUtils.deleteDirectory(workingDirectory);
+ }
+ configuration.setWorkingDirectory(workingDirectory);
+ workingDirectory.mkdirs();
+
+ if (ldifDirectory != null)
+ configuration.setLdifDirectory(ldifDirectory);
+ else
+ configuration.setLdifDirectory(new File(workingDirectory
+ .getAbsolutePath()
+ + File.separator + "ldif"));
+
+ if (ldifs.size() > 0)
+ configuration.getLdifDirectory().mkdirs();
+ for (Resource ldif : ldifs) {
+ FileUtils.copyURLToFile(ldif.getURL(), new File(configuration
+ .getLdifDirectory().getAbsolutePath()
+ + File.separator + ldif.getFilename().replace(':', '_')));
+ if (log.isDebugEnabled())
+ log.debug("Copied " + ldif + " to LDIF directory "
+ + configuration.getLdifDirectory());
+ }
+
+ Properties env = new Properties();
+ env.setProperty(Context.INITIAL_CONTEXT_FACTORY,
+ ServerContextFactory.class.getName());
+ Assert.notNull(environment);
+ env.putAll(environment);
+ env.putAll(configuration.toJndiEnvironment());
+
+ try {
+ new InitialDirContext(env);
+ } catch (NamingException e) {
+ throw new RuntimeException(
+ "Failed to start Apache Directory server", e);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public void destroy() throws Exception {
+ ShutdownConfiguration shutdown = new ShutdownConfiguration(
+ configuration.getInstanceId());
+
+ Properties env = new Properties();
+ env.setProperty(Context.INITIAL_CONTEXT_FACTORY,
+ ServerContextFactory.class.getName());
+ Assert.notNull(environment);
+ env.putAll(environment);
+ env.putAll(shutdown.toJndiEnvironment());
+
+ log.info("Shutting down directory server with id '"
+ + configuration.getInstanceId() + "'");
+
+ try {
+ new InitialContext(env);
+ } catch (NamingException e) {
+ throw new RuntimeException(
+ "Failed to stop Apache Directory server", e);
+ }
+
+ if (workingDirectory.exists() && deleteWorkingDirOnExit) {
+ if (log.isDebugEnabled())
+ log.debug("Delete Apache DS working dir " + workingDirectory);
+ FileUtils.deleteDirectory(workingDirectory);
+ }
+
+ }
+
+ public void setConfiguration(MutableServerStartupConfiguration configuration) {
+ this.configuration = configuration;
+ }
+
+ public void setWorkingDirectory(File workingDirectory) {
+ this.workingDirectory = workingDirectory;
+ }
+
+ public void setEnvironment(Properties environment) {
+ this.environment = environment;
+ }
+
+ public void setLdifs(List<Resource> ldifs) {
+ this.ldifs = ldifs;
+ }
+
+ public void setLdifDirectory(File ldifDirectory) {
+ this.ldifDirectory = ldifDirectory;
+ }
+
+ public void setDeleteWorkingDirOnExit(Boolean deleteWorkingDirOnExit) {
+ this.deleteWorkingDirOnExit = deleteWorkingDirOnExit;
+ }
+
+}
<module>org.argeo.server.osgi</module>
<module>org.argeo.server.jxl</module>
<module>org.argeo.server.hibernate</module>
+ <module>org.argeo.server.ads</module>
</modules>
</project>
\ No newline at end of file