o merged changes done in trunk after branching


git-svn-id: https://svn.apache.org/repos/asf/directory/apacheds/branches/server-config-indexbean-experiment@1029978 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/directory/server/config/ConfigBuilder.java b/src/main/java/org/apache/directory/server/config/ConfigBuilder.java
index abc20ad..8c294b4 100644
--- a/src/main/java/org/apache/directory/server/config/ConfigBuilder.java
+++ b/src/main/java/org/apache/directory/server/config/ConfigBuilder.java
@@ -57,6 +57,7 @@
 import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.core.InstanceLayout;
 import org.apache.directory.server.core.PasswordPolicyConfiguration;
+import org.apache.directory.server.core.PpolicyConfigContainer;
 import org.apache.directory.server.core.changelog.ChangeLog;
 import org.apache.directory.server.core.changelog.DefaultChangeLog;
 import org.apache.directory.server.core.interceptor.Interceptor;
@@ -136,7 +137,10 @@
 
         for ( InterceptorBean interceptorBean : interceptorBeans )
         {
-            orderedInterceptorBeans.add( interceptorBean );
+            if ( interceptorBean.isEnabled() )
+            {
+                orderedInterceptorBeans.add( interceptorBean );
+            }
         }
 
         // Instantiate the interceptors now
@@ -169,7 +173,7 @@
      */
     public static PasswordPolicyConfiguration createPwdPolicyConfig( PasswordPolicyBean passwordPolicyBean )
     {
-        if ( passwordPolicyBean == null )
+        if ( ( passwordPolicyBean == null ) || passwordPolicyBean.isDisabled() )
         {
             return null;
         }
@@ -209,6 +213,11 @@
      */
     public static ChangeLog createChangeLog( ChangeLogBean changeLogBean )
     {
+        if ( ( changeLogBean == null ) || changeLogBean.isDisabled() )
+        {
+            return null;
+        }
+        
         ChangeLog changeLog = new DefaultChangeLog();
         
         changeLog.setEnabled( changeLogBean.isEnabled() );
@@ -226,6 +235,11 @@
      */
     public static Journal createJournal( JournalBean journalBean )
     {
+        if ( ( journalBean == null ) || journalBean.isDisabled() )
+        {
+            return null;
+        }
+        
         Journal journal = new DefaultJournal();
 
         journal.setRotation( journalBean.getJournalRotation() );
@@ -326,6 +340,11 @@
      */
     public static MechanismHandler createSaslMechHandler( SaslMechHandlerBean saslMechHandlerBean ) throws ConfigurationException
     {
+        if ( ( saslMechHandlerBean == null ) || saslMechHandlerBean.isDisabled() )
+        {
+            return null;
+        }
+        
         String mechClassName = saslMechHandlerBean.getSaslMechClassName();
         
         Class<?> mechClass = null;
@@ -378,6 +397,11 @@
      */
     public static Transport createTransport( TransportBean transportBean )
     {
+        if ( ( transportBean == null ) || transportBean.isDisabled() )
+        {
+            return null;
+        }
+        
         Transport transport = null;
 
         if ( transportBean instanceof TcpTransportBean )
@@ -412,7 +436,10 @@
         
         for ( TransportBean transportBean : transportBeans )
         {
-            transports[i++] = createTransport( transportBean );
+            if ( transportBean.isEnabled() )
+            {
+                transports[i++] = createTransport( transportBean );
+            }
         }
         
         return transports;
@@ -434,7 +461,7 @@
         
         for ( String encryptionType : encryptionTypes )
         {
-            types[pos++] = EncryptionType.valueOf( encryptionType );
+            types[pos++] = EncryptionType.getByName( encryptionType );
         }
         
         return types;
@@ -450,7 +477,7 @@
     public static NtpServer createNtpServer( NtpServerBean ntpServerBean, DirectoryService directoryService ) throws LdapException
     {
         // Fist, do nothing if the NtpServer is disabled
-        if ( !ntpServerBean.isEnabled() )
+        if ( ( ntpServerBean == null ) || ntpServerBean.isDisabled() )
         {
             return null;
         }
@@ -506,7 +533,7 @@
     public static KdcServer createKdcServer( KdcServerBean kdcServerBean, DirectoryService directoryService ) throws LdapException
     {
         // Fist, do nothing if the KdcServer is disabled
-        if ( !kdcServerBean.isEnabled() )
+        if ( ( kdcServerBean == null ) || kdcServerBean.isDisabled() )
         {
             return null;
         }
@@ -593,6 +620,11 @@
 
         for ( HttpWebAppBean httpWebAppBean : httpWebAppBeans )
         {
+            if ( httpWebAppBean.isDisabled() )
+            {
+                continue;
+            }
+            
             WebApp webApp = new WebApp();
             
             // HttpAppCtxPath
@@ -618,7 +650,7 @@
     public static HttpServer createHttpServer( HttpServerBean httpServerBean, DirectoryService directoryService ) throws LdapException
     {
         // Fist, do nothing if the HttpServer is disabled
-        if ( !httpServerBean.isEnabled() )
+        if ( ( httpServerBean == null ) || httpServerBean.isDisabled() )
         {
             return null;
         }
@@ -657,7 +689,7 @@
     public static ChangePasswordServer createChangePasswordServer( ChangePasswordServerBean changePasswordServerBean, DirectoryService directoryService ) throws LdapException
     {
         // Fist, do nothing if the LdapServer is disabled
-        if ( !changePasswordServerBean.isEnabled() )
+        if ( ( changePasswordServerBean == null ) || changePasswordServerBean.isDisabled() )
         {
             return null;
         }
@@ -719,7 +751,7 @@
     public static LdapServer createLdapServer( LdapServerBean ldapServerBean, DirectoryService directoryService ) throws LdapException
     {
         // Fist, do nothing if the LdapServer is disabled
-        if ( !ldapServerBean.isEnabled() )
+        if ( ( ldapServerBean == null ) || ldapServerBean.isDisabled() )
         {
             return null;
         }
@@ -844,6 +876,11 @@
      */
     public static JdbmIndex<?, Entry> createJdbmIndex( JdbmPartition partition, JdbmIndexBean<String, Entry> jdbmIndexBean, DirectoryService directoryService )
     {
+        if ( ( jdbmIndexBean == null ) || jdbmIndexBean.isDisabled() )
+        {
+            return null;
+        }
+        
         JdbmIndex<String, Entry> index = new JdbmIndex<String, Entry>();
         
         index.setAttributeId( jdbmIndexBean.getIndexAttributeId() );
@@ -894,7 +931,7 @@
 
         for ( IndexBean indexBean : indexesBeans )
         {
-            if ( indexBean instanceof JdbmIndexBean )
+            if ( indexBean.isEnabled() && ( indexBean instanceof JdbmIndexBean ) )
             {
                 indexes.add( createJdbmIndex( partition, (JdbmIndexBean)indexBean, directoryService ) );
             }
@@ -914,6 +951,11 @@
      */
     public static JdbmPartition createJdbmPartition( DirectoryService directoryService, JdbmPartitionBean jdbmPartitionBean ) throws ConfigurationException
     {
+        if ( ( jdbmPartitionBean == null ) || jdbmPartitionBean.isDisabled() )
+        {
+            return null;
+        }
+        
         JdbmPartition jdbmPartition = new JdbmPartition();
         
         jdbmPartition.setCacheSize( jdbmPartitionBean.getPartitionCacheSize() );
@@ -975,6 +1017,11 @@
      */
     public static Partition createPartition( DirectoryService directoryService, PartitionBean partitionBean ) throws ConfigurationException
     {
+        if ( ( partitionBean == null ) || partitionBean.isDisabled() )
+        {
+            return null;
+        }
+        
         if ( partitionBean instanceof JdbmPartitionBean )
         {
             return createJdbmPartition( directoryService, (JdbmPartitionBean)partitionBean );
@@ -998,6 +1045,11 @@
         
         for ( PartitionBean partitionBean : partitionBeans )
         {
+            if ( partitionBean.isDisabled() )
+            {
+                continue;
+            }
+            
             Partition partition = createPartition( directoryService, partitionBean );
             
             if ( partition != null )
@@ -1060,13 +1112,31 @@
         directoryService.setAllowAnonymousAccess( directoryServiceBean.isDsAllowAnonymousAccess() );
         
         // ChangeLog
-        directoryService.setChangeLog( createChangeLog( directoryServiceBean.getChangeLog() ) );
+        ChangeLog cl = createChangeLog( directoryServiceBean.getChangeLog() );
+        if ( cl != null )
+        {
+            directoryService.setChangeLog( cl );
+        }
         
         // DenormalizedOpAttrsEnabled
         directoryService.setDenormalizeOpAttrsEnabled( directoryServiceBean.isDsDenormalizeOpAttrsEnabled() );
         
         // Journal
-        directoryService.setJournal( createJournal( directoryServiceBean.getJournal() ) );
+        Journal jl = createJournal( directoryServiceBean.getJournal() );
+        if ( jl != null )
+        {
+            directoryService.setJournal( jl );
+        }
+        
+        // password policy
+        // TODO add support for reading multiple policies from the config
+        PasswordPolicyConfiguration pPolicyConfig = createPwdPolicyConfig( directoryServiceBean.getPasswordPolicy() );
+        if ( pPolicyConfig != null )
+        {
+            PpolicyConfigContainer pPolicies = new  PpolicyConfigContainer();
+            pPolicies.setDefaultPolicy( pPolicyConfig );
+            directoryService.setPwdPolicies( pPolicies );
+        }
         
         // MaxPDUSize
         directoryService.setMaxPDUSize( directoryServiceBean.getDsMaxPDUSize() );
diff --git a/src/main/java/org/apache/directory/server/config/beans/AdsBaseBean.java b/src/main/java/org/apache/directory/server/config/beans/AdsBaseBean.java
index b6db85e..c77a66b 100644
--- a/src/main/java/org/apache/directory/server/config/beans/AdsBaseBean.java
+++ b/src/main/java/org/apache/directory/server/config/beans/AdsBaseBean.java
@@ -137,6 +137,16 @@
         }
     }
     
+    /**
+     * a convenient method to finding if this bean was disabled in the config
+     * 
+     * @return true if the bean was disabled, false otherwise
+     */
+    public final boolean isDisabled()
+    {
+        return !enabled;
+    }
+    
     
     /**
      * Formated print of a long
diff --git a/src/main/java/org/apache/directory/server/config/beans/DirectoryServiceBean.java b/src/main/java/org/apache/directory/server/config/beans/DirectoryServiceBean.java
index 32c68df..aa4b5d1 100644
--- a/src/main/java/org/apache/directory/server/config/beans/DirectoryServiceBean.java
+++ b/src/main/java/org/apache/directory/server/config/beans/DirectoryServiceBean.java
@@ -50,7 +50,7 @@
     private int dsMaxPDUSize = 2048;
 
     /** The flag that tells if the password should be returned as a normal attribute or not */
-    private boolean dsPasswordHidden = true;
+    private boolean dsPasswordHidden = false;
 
     /** The delay between two flushes on disk */
     private long dsSyncPeriodMillis = 15000L;
diff --git a/src/main/resources/config.ldif b/src/main/resources/config.ldif
index 246c6cb..7ed7163 100644
--- a/src/main/resources/config.ldif
+++ b/src/main/resources/config.ldif
@@ -35,10 +35,10 @@
 ads-interceptors: defaultAuthorizationInterceptor
 ads-interceptors: eventInterceptor
 ads-interceptors: exceptionInterceptor
-ads-interceptors: keyderivationinterceptor
+ads-interceptors: keyDerivationInterceptor
 ads-interceptors: normalizationInterceptor
 ads-interceptors: operationalAttributeInterceptor
-ads-interceptors: passwordpolicyinterceptor
+ads-interceptors: passwordHashingInterceptor
 ads-interceptors: referralInterceptor
 ads-interceptors: schemaInterceptor
 ads-interceptors: subentryInterceptor
@@ -122,14 +122,14 @@
 ads-interceptorid: exceptionInterceptor
 ads-enabled: true
 
-dn: ads-interceptorId=keyderivationinterceptor,ou=interceptors,ads-directoryServiceId=default,ou=config
+dn: ads-interceptorId=keyDerivationInterceptor,ou=interceptors,ads-directoryServiceId=default,ou=config
 objectclass: top
 objectclass: ads-base
 objectclass: ads-interceptor
 ads-enabled: false
-ads-interceptororder: 9
+ads-interceptororder: 8
 ads-interceptorclassname: org.apache.directory.server.core.kerberos.KeyDerivationInterceptor
-ads-interceptorid: keyderivationinterceptor
+ads-interceptorid: keyDerivationInterceptor
 
 dn: ads-interceptorId=normalizationInterceptor,ou=interceptors,ads-directoryServiceId=default,ou=config
 objectclass: top
@@ -149,14 +149,14 @@
 ads-interceptorid: operationalAttributeInterceptor
 ads-enabled: true
 
-dn: ads-interceptorId=passwordpolicyinterceptor,ou=interceptors,ads-directoryServiceId=default,ou=config
+dn: ads-interceptorId=passwordHashingInterceptor,ou=interceptors,ads-directoryServiceId=default,ou=config
 objectclass: top
 objectclass: ads-base
 objectclass: ads-interceptor
-ads-enabled: false
-ads-interceptororder: 8
-ads-interceptorclassname: org.apache.directory.server.core.kerberos.PasswordPolicyInterceptor
-ads-interceptorid: passwordpolicyinterceptor
+ads-enabled: true
+ads-interceptororder: 9
+ads-interceptorclassname: org.apache.directory.server.core.hash.SshaPasswordHashingInterceptor
+ads-interceptorid: passwordHashingInterceptor
 
 dn: ads-interceptorId=referralInterceptor,ou=interceptors,ads-directoryServiceId=default,ou=config
 objectclass: top
@@ -198,7 +198,7 @@
 objectClass: top
 objectClass: ads-base
 objectClass: ads-passwordPolicy
-ads-pwdId: pwdpolicy
+ads-pwdId: pwdPolicy
 ads-pwdSafeModify: FALSE
 ads-pwdMaxAge: 0
 ads-pwdFailureCountInterval: 30
@@ -548,6 +548,7 @@
 ads-krbPrimaryRealm: EXAMPLE.COM
 ads-krbProxiableAllowed: true
 ads-krbRenewableAllowed: true
+ads-searchBaseDN: ou=users,dc=example,dc=com
 
 dn: ou=transports,ads-serverId=kerberos,ou=servers,ads-directoryServiceId=default,ou=config
 ou: transports
@@ -569,7 +570,7 @@
 ads-systemport: 60088
 ads-transportbacklog: 50
 ads-transportnbthreads: 4
-ads-transportaddress: localhost
+ads-transportaddress: 0.0.0.0
 ads-transportid: udp
 objectclass: ads-transport
 objectclass: ads-udpTransport
@@ -613,7 +614,7 @@
 dn: ads-transportid=ldaps,ou=transports,ads-serverId=ldapServer,ou=servers,ads-directoryServiceId=default,ou=config
 ads-systemport: 10636
 ads-transportenablessl: true
-ads-transportaddress: localhost
+ads-transportaddress: 0.0.0.0
 ads-transportid: ldaps
 objectclass: ads-transport
 objectclass: ads-tcpTransport