You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ka...@apache.org on 2010/04/20 19:49:28 UTC

svn commit: r936012 - in /directory/apacheds/trunk/default-config: pom.xml src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java src/main/java/org/apache/directory/server/config/ConfigSchemaConstants.java

Author: kayyagari
Date: Tue Apr 20 17:49:28 2010
New Revision: 936012

URL: http://svn.apache.org/viewvc?rev=936012&view=rev
Log:
o added support for configuring and reading changepassword server
o added dependency on apacheds-protocol-changepw

Modified:
    directory/apacheds/trunk/default-config/pom.xml
    directory/apacheds/trunk/default-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java
    directory/apacheds/trunk/default-config/src/main/java/org/apache/directory/server/config/ConfigSchemaConstants.java

Modified: directory/apacheds/trunk/default-config/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/default-config/pom.xml?rev=936012&r1=936011&r2=936012&view=diff
==============================================================================
--- directory/apacheds/trunk/default-config/pom.xml (original)
+++ directory/apacheds/trunk/default-config/pom.xml Tue Apr 20 17:49:28 2010
@@ -71,6 +71,12 @@
     </dependency>
 
     <dependency>
+      <artifactId>apacheds-protocol-changepw</artifactId>
+      <groupId>${groupId}</groupId>
+      <version>${version}</version>
+    </dependency>
+
+    <dependency>
       <artifactId>apacheds-http-integration</artifactId>
       <groupId>${groupId}</groupId>
       <version>${version}</version>

Modified: directory/apacheds/trunk/default-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/default-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java?rev=936012&r1=936011&r2=936012&view=diff
==============================================================================
--- directory/apacheds/trunk/default-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java (original)
+++ directory/apacheds/trunk/default-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java Tue Apr 20 17:49:28 2010
@@ -34,6 +34,7 @@ import java.util.TreeSet;
 
 import javax.naming.directory.SearchControls;
 
+import org.apache.directory.server.changepw.ChangePasswordServer;
 import org.apache.directory.server.core.DefaultDirectoryService;
 import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.core.changelog.ChangeLog;
@@ -454,7 +455,113 @@ public class ConfigPartitionReader
         return ntpServer;
     }
 
+    
+    public ChangePasswordServer getChangePwdServer() throws Exception
+    {
+        EqualityNode<String> filter = new EqualityNode<String>( SchemaConstants.OBJECT_CLASS_AT, new StringValue(
+            ConfigSchemaConstants.ADS_CHANGEPWD_SERVER ) );
+        SearchControls controls = new SearchControls();
+        controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
+
+        IndexCursor<Long, ServerEntry, Long> cursor = se.cursor( configPartition.getSuffixDn(),
+            AliasDerefMode.NEVER_DEREF_ALIASES, filter, controls );
+
+        if ( !cursor.next() )
+        {
+            LOG.warn( "No ChangePassword server was configured under the DN {}", configPartition.getSuffixDn() );
+            return null;
+        }
+        
+        ForwardIndexEntry<Long, ServerEntry, Long> forwardEntry = ( ForwardIndexEntry<Long, ServerEntry, Long> ) cursor.get();
+        cursor.close();
+
+        ClonedServerEntry chgPwdEntry = configPartition.lookup( forwardEntry.getId() );
+        LOG.debug( "Changepassword server entry {}", chgPwdEntry );
+    
+        if ( !isEnabled( chgPwdEntry ) )
+        {
+            return null;
+        }
+
+        ChangePasswordServer chgPwdServer = new ChangePasswordServer();
+
+        chgPwdServer.setServiceId( getString( ConfigSchemaConstants.ADS_SERVER_ID, chgPwdEntry ) );
+
+        DN transportsDN = new DN( getString( ConfigSchemaConstants.ADS_TRANSPORTS, chgPwdEntry ) );
+        transportsDN.normalize( schemaManager.getNormalizerMapping() );
+        Transport[] transports = getTransports( transportsDN );
+        chgPwdServer.setTransports( transports );
+
+        // MAY attributes
+        EntryAttribute clockSkewAttr = chgPwdEntry.get( ConfigSchemaConstants.ADS_KRB_ALLOWABLE_CLOCKSKEW );
+
+        if ( clockSkewAttr != null )
+        {
+            chgPwdServer.setAllowableClockSkew( Long.parseLong( clockSkewAttr.getString() ) );
+        }
+
+        EntryAttribute encryptionTypeAttr = chgPwdEntry.get( ConfigSchemaConstants.ADS_KRB_ENCRYPTION_TYPES );
+
+        if ( encryptionTypeAttr != null )
+        {
+            EncryptionType[] encryptionTypes = new EncryptionType[encryptionTypeAttr.size()];
+            Iterator<Value<?>> itr = encryptionTypeAttr.getAll();
+            int count = 0;
+
+            while ( itr.hasNext() )
+            {
+                Value<?> val = itr.next();
+                encryptionTypes[count++] = EncryptionType.getByName( val.getString() );
+            }
+
+            chgPwdServer.setEncryptionTypes( encryptionTypes );
+        }
+
+        EntryAttribute emptyAddrAttr = chgPwdEntry.get( ConfigSchemaConstants.ADS_KRB_EMPTY_ADDRESSES_ALLOWED );
+
+        if ( emptyAddrAttr != null )
+        {
+            chgPwdServer.setEmptyAddressesAllowed( Boolean.parseBoolean( emptyAddrAttr.getString() ) );
+        }
+
+        EntryAttribute prmRealmAttr = chgPwdEntry.get( ConfigSchemaConstants.ADS_KRB_PRIMARY_REALM );
+
+        if ( prmRealmAttr != null )
+        {
+            chgPwdServer.setPrimaryRealm( prmRealmAttr.getString() );
+        }
+        
+        EntryAttribute policyCatCount = chgPwdEntry.get( ConfigSchemaConstants.ADS_CHANGEPWD_POLICY_CATEGORY_COUNT );
+        if( policyCatCount != null )
+        {
+            chgPwdServer.setPolicyCategoryCount( getInt( ConfigSchemaConstants.ADS_CHANGEPWD_POLICY_CATEGORY_COUNT, chgPwdEntry ) );
+        }
+
+        EntryAttribute policyPwdLen = chgPwdEntry.get( ConfigSchemaConstants.ADS_CHANGEPWD_POLICY_PASSWORD_LENGTH );
+        
+        if( policyPwdLen != null )
+        {
+            chgPwdServer.setPolicyPasswordLength( getInt( ConfigSchemaConstants.ADS_CHANGEPWD_POLICY_PASSWORD_LENGTH, chgPwdEntry ) );
+        }
+        
+        EntryAttribute policyTokenSize = chgPwdEntry.get( ConfigSchemaConstants.ADS_CHANGEPWD_POLICY_TOKEN_SIZE );
+        
+        if( policyTokenSize != null )
+        {
+            chgPwdServer.setPolicyTokenSize( getInt( ConfigSchemaConstants.ADS_CHANGEPWD_POLICY_TOKEN_SIZE, chgPwdEntry ) );
+        }
+        
+        EntryAttribute servicePrincipal = chgPwdEntry.get( ConfigSchemaConstants.ADS_CHANGEPWD_SERVICE_PRINCIPAL );
+        
+        if( servicePrincipal != null )
+        {
+            chgPwdServer.setServicePrincipal( servicePrincipal.getString() );
+        }
+        
+        return chgPwdServer;
+    }
 
+    
     public HttpServer getHttpServer() throws Exception
     {
         EqualityNode<String> filter = new EqualityNode<String>( SchemaConstants.OBJECT_CLASS_AT, new StringValue(

Modified: directory/apacheds/trunk/default-config/src/main/java/org/apache/directory/server/config/ConfigSchemaConstants.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/default-config/src/main/java/org/apache/directory/server/config/ConfigSchemaConstants.java?rev=936012&r1=936011&r2=936012&view=diff
==============================================================================
--- directory/apacheds/trunk/default-config/src/main/java/org/apache/directory/server/config/ConfigSchemaConstants.java (original)
+++ directory/apacheds/trunk/default-config/src/main/java/org/apache/directory/server/config/ConfigSchemaConstants.java Tue Apr 20 17:49:28 2010
@@ -162,4 +162,14 @@ public interface ConfigSchemaConstants
     String ADS_HTTP_APP_CTX_PATH = "ads-httpAppCtxPath";
 
     String ADS_ENABLED = "ads-enabled";
+    
+    String ADS_CHANGEPWD_POLICY_CATEGORY_COUNT = "ads-chgPwdPolicyCategoryCount";
+    
+    String ADS_CHANGEPWD_POLICY_PASSWORD_LENGTH = "ads-chgPwdPolicyPasswordLength";
+    
+    String ADS_CHANGEPWD_POLICY_TOKEN_SIZE = "ads-chgPwdPolicyTokenSize";
+    
+    String ADS_CHANGEPWD_SERVICE_PRINCIPAL = "ads-chgPwdServicePrincipal";
+    
+    String ADS_CHANGEPWD_SERVER = "ads-changePasswordServer";
 }