blob: 0f7da7bc1482bca452f1cbe208dc5333b874adf1 [file]
<?xml version="1.0" encoding="UTF-8"?>
<document>
<properties>
<author email="trustin">trustin</author>
<title>Configuration</title>
</properties>
<body>
<p>
The Apache Directory team introduced new configuration interface of ApacheDS
from the version 0.9.1. This page introduces
it.</p>
<section heading="h1" name="The Configuration API">
<p>
ApacheDS provides its configuration API in the
org.apache.ldap.server.configuration package. This package contains concrete
configuration instruction classes that you can instantiate and specify in your
JNDI environment variable. To put your configuration instruction class into the
JNDI environment
variable:</p>
<source>Properties env = new Properties();
env.setProperty( Context.INITIAL_CONTEXT_FACTORY, CoreContextFactory.class.getName() );
...
// Create a configuration instruction.
Configuration cfg = new MutableStartupConfiguration();
...
// Put the configuration instruction to the environment variable.
env.putAll( cfg.toJndiEnvironment() );
// Execute the instruction you've specified.
new InitialContext( env );
</source>
<p>
Now let's find out what kind of instruction you can give to
ApacheDS.</p>
<subsection heading="h2" name="StartupConfiguration">
<p>
This instruction starts up the ApacheDS if it is not started. Here's the list of
known
properties:</p>
<ul nesting="1">
<li>
authenticatorConfigurations - a collection of AuthenticatorConfigurations.
AuthenticatorConfiguration specifies Authenticators that authenticate a user who
accesses the ApacheDS DIT. (Default: &lt;all default
authenticators&gt;)</li>
<li>
bootstrapSchemas - a set of BootstrapSchemas which are loaded at the first time
ApacheDS starts up (Default: &lt;all default
schemas&gt;)</li>
<li>
contextPartitionConfigurations - A collection of ContextPartitionConfigurations.
ContextPartitionConfiguration specified ContextPartitions that consist the
ApacheDS DIT. (Default: no context partitions except system
partition)</li>
<li>
accessControl - Set to true if you want to enable access control support of the
ApacheDS. (Default:
false)</li>
<li>
allowAnonymousAccess - Set to true if you want to enable anonymous access.
(Default:
true)</li>
<li>
interceptorConfigurations - a list of InterceptorConfigurations which will
configure the initial interceptor chain of the ApacheDS (Default: &lt;all default
interceptors&gt;)</li>
<li>
testEntries - a list of javax.naming.directory.Attributes which will be added to
the DIT while the ApacheDS is started up (Default: no test
entries)</li>
<li>
workingDirectory - a working directory the content of DIT will be stored to
(Default:
./server-work/)</li>
</ul>
<p>
You don't need to specify any properties because all properties have the
default. Please use MutableStartupConfiguration to modify any properties
above.</p>
</subsection>
<subsection heading="h2" name="ShutdownConfiguration">
<p>
This instruction shuts down the ApacheDS if it is not already shut down. There's
no property to
configure.</p>
</subsection>
<subsection heading="h2" name="SyncConfiguration">
<p>
This instruction flushes out any I/O buffer or write cache. There's no property
to
configure.</p>
</subsection>
<subsection heading="h2" name="AddContextPartitionConfiguration">
<p>
This instruction adds a new context partition on-the-fly while the ApacheDS is
running. There is only one property, 'contextPartitionConfiguration'. You can
specify an appropriate ContextPartitionConfiguration to plug a context partition
into the
ApacheDS.</p>
</subsection>
<subsection heading="h2" name="RemoveContextPartitionConfiguration">
<p>
This instruction removes an existing context partition on-the-fly while the
ApacheDS is running. There is only one property, 'suffix'. You can specify the
suffix of the partition you want to remove from the
ApacheDS.</p>
</subsection>
<subsection heading="h2" name="Running and Choosing Multiple Instances">
<p>
You can run multiple instances of ApacheDS by specifying {{instanceId}} to all
Configuration instructions. InstanceId can be specified as a constructor
parameter. Please take a look at the API documentation (JavaDoc) for more
details.</p>
<source>// Create a configuration instruction that affects an ApacheDS instance 'instance4'.
Configuration cfg = new MutableStartupConfiguration( "instance4" );
...
// Put the configuration instruction to the environment variable.
env.putAll( cfg.toJndiEnvironment() );
// Execute the instruction you've specified for an ApacheDS instance 'instance4'.
new InitialContext( env );
</source>
</subsection>
</section>
<section heading="h1" name="Using Spring Framework">
<p>
The configuration API is designed to fit tightly
with
<a href="http://www.springframework.org/">Spring Framework</a>
. Here is an example beans xml
file:
</p>
<source>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd"&gt;
&lt;beans&gt;
&lt;!-- JNDI environment variable --&gt;
&lt;bean id="environment" class="org.springframework.beans.factory.config.PropertiesFactoryBean"&gt;
&lt;property name="properties"&gt;
&lt;props&gt;
&lt;prop key="asn.1.berlib.provider"&gt;org.apache.ldap.common.berlib.asn1.SnickersProvider&lt;/prop&gt;
&lt;!--prop key="asn.1.berlib.provider"&gt;org.apache.asn1new.ldap.TwixProvider&lt;/prop--&gt;
&lt;prop key="java.naming.security.authentication"&gt;simple&lt;/prop&gt;
&lt;prop key="java.naming.security.principal"&gt;uid=admin,ou=system&lt;/prop&gt;
&lt;prop key="java.naming.security.credentials"&gt;secret&lt;/prop&gt;
&lt;prop key="java.naming.ldap.attributes.binary"&gt;
photo personalSignature audio jpegPhoto javaSerializedData userPassword
userCertificate cACertificate authorityRevocationList certificateRevocationList
crossCertificatePair x500UniqueIdentifier krb5Key
&lt;/prop&gt;
&lt;/props&gt;
&lt;/property&gt;
&lt;/bean&gt;
&lt;!-- StartupConfiguration to start ApacheDS --&gt;
&lt;bean id="configuration" class="org.apache.ldap.server.configuration.MutableServerStartupConfiguration"&gt;
&lt;property name="workingDirectory"&gt;&lt;value&gt;apache.org&lt;/value&gt;&lt;/property&gt;
&lt;property name="allowAnonymousAccess"&gt;&lt;value&gt;false&lt;/value&gt;&lt;/property&gt;
&lt;property name="accessControlEnabled"&gt;&lt;value&gt;false&lt;/value&gt;&lt;/property&gt;
&lt;property name="ldapPort"&gt;&lt;value&gt;10389&lt;/value&gt;&lt;/property&gt;
&lt;property name="contextPartitionConfigurations"&gt;
&lt;set&gt;
&lt;ref bean="apachePartitionConfiguration"/&gt;
&lt;/set&gt;
&lt;/property&gt;
&lt;!-- Bootstrap schemas --&gt;
&lt;property name="bootstrapSchemas"&gt;
&lt;set&gt;
&lt;bean class="org.apache.ldap.server.schema.bootstrap.AutofsSchema"/&gt;
&lt;bean class="org.apache.ldap.server.schema.bootstrap.CorbaSchema"/&gt;
&lt;bean class="org.apache.ldap.server.schema.bootstrap.CoreSchema"/&gt;
......
&lt;/set&gt;
&lt;/property&gt;
&lt;!-- Interceptor configurations --&gt;
&lt;property name="interceptorConfigurations"&gt;
&lt;list&gt;
&lt;bean class="org.apache.ldap.server.configuration.MutableInterceptorConfiguration"&gt;
&lt;property name="name"&gt;&lt;value&gt;normalizationService&lt;/value&gt;&lt;/property&gt;
&lt;property name="interceptor"&gt;
&lt;bean class="org.apache.ldap.server.normalization.NormalizationService" /&gt;
&lt;/property&gt;
&lt;/bean&gt;
&lt;bean class="org.apache.ldap.server.configuration.MutableInterceptorConfiguration"&gt;
&lt;property name="name"&gt;&lt;value&gt;authenticationService&lt;/value&gt;&lt;/property&gt;
&lt;property name="interceptor"&gt;
&lt;bean class="org.apache.ldap.server.authn.AuthenticationService" /&gt;
&lt;/property&gt;
&lt;/bean&gt;
......
&lt;/list&gt;
&lt;/property&gt;
&lt;/bean&gt;
&lt;!-- Additional ContextPartitionConfiguration --&gt;
&lt;bean id="apachePartitionConfiguration" class="org.apache.ldap.server.configuration.MutableContextPartitionConfiguration"&gt;
&lt;property name="name"&gt;&lt;value&gt;apache&lt;/value&gt;&lt;/property&gt;
&lt;property name="suffix"&gt;&lt;value&gt;dc=apache,dc=org&lt;/value&gt;&lt;/property&gt;
&lt;property name="indexedAttributes"&gt;
&lt;set&gt;
&lt;value&gt;objectClass&lt;/value&gt;
&lt;value&gt;ou&lt;/value&gt;
&lt;value&gt;uid&lt;/value&gt;
&lt;/set&gt;
&lt;/property&gt;
&lt;property name="contextEntry"&gt;
&lt;value&gt;
objectClass: top
objectClass: domain
objectClass: extensibleObject
dc: apache
&lt;/value&gt;
&lt;/property&gt;
&lt;/bean&gt;
&lt;!-- Custom editors required to launch ApacheDS --&gt;
&lt;bean class="org.springframework.beans.factory.config.CustomEditorConfigurer"&gt;
&lt;property name="customEditors"&gt;
&lt;map&gt;
&lt;entry key="javax.naming.directory.Attributes"&gt;
&lt;bean class="org.apache.ldap.server.configuration.AttributesPropertyEditor"/&gt;
&lt;/entry&gt;
&lt;/map&gt;
&lt;/property&gt;
&lt;/bean&gt;
&lt;/beans&gt;
</source>
<p>
With the XML file above, you can start up the ApacheDS with this
code:</p>
<source>Properties env;
ServerStartupConfiguration cfg;
ApplicationContext factory = new FileSystemXmlApplicationContext( args[0] );
cfg = ( StartupConfiguration ) factory.getBean( "configuration" );
env = ( Properties ) factory.getBean( "environment" );
env.setProperty( Context.PROVIDER_URL, "" );
env.setProperty( Context.INITIAL_CONTEXT_FACTORY, CoreContextFactory.class.getName() );
env.putAll( cfg.toJndiEnvironment() );
new InitialDirContext( env );
</source>
</section>
</body>
</document>