directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1026713 - in /directory/apacheds/branches/apacheds-config/server-config/src: main/java/org/apache/directory/server/config/ main/java/org/apache/directory/server/config/beans/ test/java/org/apache/directory/server/config/ test/resources/
Date Sat, 23 Oct 2010 23:36:26 GMT
Author: elecharny
Date: Sat Oct 23 23:36:26 2010
New Revision: 1026713

URL: http://svn.apache.org/viewvc?rev=1026713&view=rev
Log:
o Lists are now processed as Sets were
o Added a toString() method to process longs
o Fixed some issues with the EncryptionTypes
o Added the KrbServerBean toString() method
o Added a test for KrbServer config

Added:
    directory/apacheds/branches/apacheds-config/server-config/src/test/java/org/apache/directory/server/config/KerberosServerConfigReaderTest.java
    directory/apacheds/branches/apacheds-config/server-config/src/test/resources/kerberosserver.ldif
Modified:
    directory/apacheds/branches/apacheds-config/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java
    directory/apacheds/branches/apacheds-config/server-config/src/main/java/org/apache/directory/server/config/beans/AdsBaseBean.java
    directory/apacheds/branches/apacheds-config/server-config/src/main/java/org/apache/directory/server/config/beans/KdcServerBean.java

Modified: directory/apacheds/branches/apacheds-config/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-config/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java?rev=1026713&r1=1026712&r2=1026713&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-config/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java
(original)
+++ directory/apacheds/branches/apacheds-config/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java
Sat Oct 23 23:36:26 2010
@@ -807,6 +807,26 @@ public class ConfigPartitionReader
 
                 method.invoke( bean, new Object[]{ new String[]{valueStr} } );
             }
+            else if ( type == List.class )
+            {
+                Type genericFieldType = beanField.getGenericType();
+                Class<?> fieldArgClass = null;
+                    
+                if ( genericFieldType instanceof ParameterizedType ) 
+                {
+                    ParameterizedType parameterizedType = (ParameterizedType) genericFieldType;
+                    Type[] fieldArgTypes = parameterizedType.getActualTypeArguments();
+                    
+                    for ( Type fieldArgType : fieldArgTypes )
+                    {
+                        fieldArgClass = (Class<?>) fieldArgType;
+                    }
+                }
+
+                Method method = bean.getClass().getMethod( "add" + beanField.getName(), Array.newInstance(
fieldArgClass, 0 ).getClass() );
+
+                method.invoke( bean, new Object[]{ new String[]{valueStr} } );
+            }
         }
 
     }

Modified: directory/apacheds/branches/apacheds-config/server-config/src/main/java/org/apache/directory/server/config/beans/AdsBaseBean.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-config/server-config/src/main/java/org/apache/directory/server/config/beans/AdsBaseBean.java?rev=1026713&r1=1026712&r2=1026713&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-config/server-config/src/main/java/org/apache/directory/server/config/beans/AdsBaseBean.java
(original)
+++ directory/apacheds/branches/apacheds-config/server-config/src/main/java/org/apache/directory/server/config/beans/AdsBaseBean.java
Sat Oct 23 23:36:26 2010
@@ -115,6 +115,12 @@ public abstract class AdsBaseBean 
     }
     
     
+    protected String toString( String tabs, String name, long value )
+    {
+        return tabs + name + " : " + value + "\n";
+    }
+    
+    
     /**
      * {@inheritDoc}
      */

Modified: directory/apacheds/branches/apacheds-config/server-config/src/main/java/org/apache/directory/server/config/beans/KdcServerBean.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-config/server-config/src/main/java/org/apache/directory/server/config/beans/KdcServerBean.java?rev=1026713&r1=1026712&r2=1026713&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-config/server-config/src/main/java/org/apache/directory/server/config/beans/KdcServerBean.java
(original)
+++ directory/apacheds/branches/apacheds-config/server-config/src/main/java/org/apache/directory/server/config/beans/KdcServerBean.java
Sat Oct 23 23:36:26 2010
@@ -19,12 +19,11 @@
  */
 package org.apache.directory.server.config.beans;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import javax.security.auth.kerberos.KerberosPrincipal;
 
-import org.apache.directory.server.kerberos.shared.crypto.encryption.EncryptionType;
-
 /**
  * A class used to store the KdcServer configuration.
  *
@@ -102,7 +101,7 @@ public class KdcServerBean extends DSBas
     private boolean krbbodychecksumverified = DEFAULT_VERIFY_BODY_CHECKSUM;
 
     /** The encryption types. */
-    private List<EncryptionType> krbencryptiontypes;
+    private List<String> krbencryptiontypes = new ArrayList<String>();
 
     /** The service principal name. */
     private String krbkdcprincipal = DEFAULT_PRINCIPAL;
@@ -144,7 +143,7 @@ public class KdcServerBean extends DSBas
      *
      * @return The encryption types.
      */
-    public List<EncryptionType> getKrbEncryptionTypes()
+    public List<String> getKrbEncryptionTypes()
     {
         return krbencryptiontypes;
     }
@@ -155,16 +154,11 @@ public class KdcServerBean extends DSBas
      * 
      * @param krbEncryptionTypes the encryptionTypes to set
      */
-    public void setKrbEncryptionTypes( EncryptionType... krbEncryptionTypes )
+    public void addkrbencryptiontypes( String... krbEncryptionTypes )
     {
-        if ( krbEncryptionTypes != null )
+        for ( String encryptionType:krbEncryptionTypes )
         {
-            this.krbencryptiontypes.clear();
-            
-            for ( EncryptionType encryptionType:krbEncryptionTypes )
-            {
-                this.krbencryptiontypes.add( encryptionType );
-            }
+            this.krbencryptiontypes.add( encryptionType );
         }
     }
 
@@ -371,4 +365,49 @@ public class KdcServerBean extends DSBas
     {
         this.krbkdcprincipal = krbKdcPrincipal;
     }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public String toString( String tabs )
+    {
+        StringBuilder sb = new StringBuilder();
+        
+        sb.append( tabs ).append( "KDCServer :\n" );
+        sb.append( super.toString( tabs + "  " ) );
+        sb.append( toString( tabs, "  body checksum verified", krbbodychecksumverified )
);
+        sb.append( toString( tabs, "  empty address alowed", krbemptyaddressesallowed ) );
+        sb.append( toString( tabs, "  forwardable allowed", krbforwardableallowed ) );
+        sb.append( toString( tabs, "  PA encode timestamp required", krbpaenctimestamprequired
) );
+        sb.append( toString( tabs, "  postdated allowed", krbpostdatedallowed ) );
+        sb.append( toString( tabs, "  proxiable allowed", krbproxiableallowed ) );
+        sb.append( toString( tabs, "  renew allowed", krbrenewableallowed ) );
+        sb.append( toString( tabs, "  allowable clock skew", krballowableclockskew ) );
+        sb.append( toString( tabs, "  KDC principal", krbkdcprincipal ) );
+        sb.append( toString( tabs, "  maximum renewable lifetime", krbmaximumrenewablelifetime
) );
+        sb.append( toString( tabs, "  maximum ticket lifetime", krbmaximumticketlifetime
) );
+        sb.append( toString( tabs, "  primary realm", krbprimaryrealm ) );
+
+        if ( ( krbencryptiontypes != null ) && ( krbencryptiontypes.size() > 0
) )
+        {
+            sb.append( tabs ).append( "  encryption types :\n" );
+            
+            for ( String encryptionType : krbencryptiontypes )
+            {
+                sb.append( toString( tabs, "    encryption type", encryptionType ) );
+            }
+        }
+        
+        return sb.toString();
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public String toString()
+    {
+        return toString( "" );
+    }
 }

Added: directory/apacheds/branches/apacheds-config/server-config/src/test/java/org/apache/directory/server/config/KerberosServerConfigReaderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-config/server-config/src/test/java/org/apache/directory/server/config/KerberosServerConfigReaderTest.java?rev=1026713&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-config/server-config/src/test/java/org/apache/directory/server/config/KerberosServerConfigReaderTest.java
(added)
+++ directory/apacheds/branches/apacheds-config/server-config/src/test/java/org/apache/directory/server/config/KerberosServerConfigReaderTest.java
Sat Oct 23 23:36:26 2010
@@ -0,0 +1,118 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you under the Apache License, Version 2.0 (the
+ *   "License"); you may not use this file except in compliance
+ *   with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing,
+ *   software distributed under the License is distributed on an
+ *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *   KIND, either express or implied.  See the License for the
+ *   specific language governing permissions and limitations
+ *   under the License.
+ *
+ */
+
+package org.apache.directory.server.config;
+
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.directory.junit.tools.Concurrent;
+import org.apache.directory.junit.tools.ConcurrentJunitRunner;
+import org.apache.directory.server.config.beans.ConfigBean;
+import org.apache.directory.server.config.beans.KdcServerBean;
+import org.apache.directory.server.core.partition.ldif.SingleFileLdifPartition;
+import org.apache.directory.shared.ldap.name.DN;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
+import org.apache.directory.shared.ldap.schema.ldif.extractor.impl.DefaultSchemaLdifExtractor;
+import org.apache.directory.shared.ldap.schema.loader.ldif.LdifSchemaLoader;
+import org.apache.directory.shared.ldap.schema.manager.impl.DefaultSchemaManager;
+import org.apache.directory.shared.ldap.schema.registries.SchemaLoader;
+import org.apache.directory.shared.ldap.util.LdapExceptionUtils;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * Test class for ConfigPartitionReader
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@RunWith(ConcurrentJunitRunner.class)
+@Concurrent()
+public class KerberosServerConfigReaderTest
+{
+    private static File workDir = new File( System.getProperty( "java.io.tmpdir" ) + "/server-work"
);
+
+    private static SchemaManager schemaManager;
+
+
+    @BeforeClass
+    public static void readConfig() throws Exception
+    {
+        File workDir = new File( System.getProperty( "java.io.tmpdir" ) + "/server-work"
);
+        FileUtils.deleteDirectory( workDir );
+        workDir.mkdir();
+
+        String workingDirectory = workDir.getPath();
+        // Extract the schema on disk (a brand new one) and load the registries
+        File schemaRepository = new File( workingDirectory, "schema" );
+        
+        if ( schemaRepository.exists() )
+        {
+            FileUtils.deleteDirectory( schemaRepository );
+        }
+
+        SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor( new File( workingDirectory
) );
+        extractor.extractOrCopy();
+
+        SchemaLoader loader = new LdifSchemaLoader( schemaRepository );
+        schemaManager = new DefaultSchemaManager( loader );
+
+        // We have to load the schema now, otherwise we won't be able
+        // to initialize the Partitions, as we won't be able to parse 
+        // and normalize their suffix DN
+        schemaManager.loadAllEnabled();
+
+        List<Throwable> errors = schemaManager.getErrors();
+
+        if ( errors.size() != 0 )
+        {
+            throw new Exception( "Schema load failed : " + LdapExceptionUtils.printErrors(
errors ) );
+        }
+    }
+
+
+    @Test
+    public void testDhcpService() throws Exception
+    {
+        File configDir = new File( workDir, "kerberosserver" ); // could be any directory,
cause the config is now in a single file
+        String configFile = LdifConfigExtractor.extractSingleFileConfig( configDir, "kerberosserver.ldif",
true );
+
+        SingleFileLdifPartition configPartition = new SingleFileLdifPartition( configFile
);
+        configPartition.setId( "config" );
+        configPartition.setSuffix( new DN( "ou=config" ) );
+        configPartition.setSchemaManager( schemaManager );
+        
+        configPartition.initialize();
+        ConfigPartitionReader cpReader = new ConfigPartitionReader( configPartition, workDir
);
+        
+        ConfigBean configBean = cpReader.readConfig( new DN( "ou=servers,ads-directoryServiceId=default,ou=config"
), ConfigSchemaConstants.ADS_KERBEROS_SERVER_OC.getValue() );
+
+        assertNotNull( configBean );
+        KdcServerBean kdcServerBean = (KdcServerBean)configBean.getDirectoryServiceBeans().get(
0 );
+        assertNotNull( kdcServerBean );
+    }
+}

Added: directory/apacheds/branches/apacheds-config/server-config/src/test/resources/kerberosserver.ldif
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-config/server-config/src/test/resources/kerberosserver.ldif?rev=1026713&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-config/server-config/src/test/resources/kerberosserver.ldif
(added)
+++ directory/apacheds/branches/apacheds-config/server-config/src/test/resources/kerberosserver.ldif
Sat Oct 23 23:36:26 2010
@@ -0,0 +1,94 @@
+version: 1
+dn: ou=config
+ou: config
+objectclass: top
+objectclass: organizationalUnit
+
+dn: ads-directoryServiceId=default,ou=config
+objectclass: top
+objectclass: ads-directoryService
+ads-directoryserviceid: default
+ads-dsreplicaid: 1
+ads-dssyncperiodmillis: 15000
+ads-dsmaxpdusize: 2000000
+ads-dsallowanonymousaccess: true
+ads-dsaccesscontrolenabled: false
+ads-dsdenormalizeopattrsenabled: false
+ads-servers: changepasswordserver
+ads-servers: dns
+ads-servers: httpserver
+ads-servers: kerberos
+ads-servers: ldapserver
+ads-servers: ntp
+ads-partitions: example
+ads-partitions: system
+ads-interceptors: aciAuthorizationInterceptor
+ads-interceptors: authenticationInterceptor
+ads-interceptors: collectiveAttributeInterceptor
+ads-interceptors: defaultAuthorizationInterceptor
+ads-interceptors: eventInterceptor
+ads-interceptors: exceptionInterceptor
+ads-interceptors: keyderivationinterceptor
+ads-interceptors: normalizationInterceptor
+ads-interceptors: operationalAttributeInterceptor
+ads-interceptors: passwordpolicyinterceptor
+ads-interceptors: referralInterceptor
+ads-interceptors: schemaInterceptor
+ads-interceptors: subentryInterceptor
+ads-interceptors: triggerInterceptor
+ads-enabled: true
+
+dn: ou=servers,ads-directoryServiceId=default,ou=config
+ou: servers
+objectclass: organizationalUnit
+objectclass: top
+
+dn: ads-serverId=kdcServer,ou=servers,ads-directoryServiceId=default,ou=config
+objectclass: top
+objectclass: ads-server
+objectclass: ads-dsBasedServer
+objectclass: ads-kdcServer
+ads-serverId: kerberosServer
+description: a Kerberos server instance
+ads-krbAllowableClockSkew: 1000
+ads-krbEncryptionTypes: SPNEGO
+ads-krbEncryptionTypes: MD5
+ads-krbEncryptionTypes: SSHA
+ads-krbEmptyAddressesAllowed: TRUE
+ads-krbForwardableAllowed: TRUE
+ads-krbPaEncTimestampRequired: TRUE
+ads-krbPostdatedAllowed: TRUE
+ads-krbProxiableAllowed: TRUE
+ads-krbRenewableAllowed: TRUE
+ads-krbKdcPrincipal: uid=admin
+ads-krbMaximumRenewableLifetime: 100
+ads-krbMaximumTicketLifetime: 200
+ads-krbPrimaryRealm: EXAMPLE.COM
+ads-krbBodyChecksumVerified: TRUE
+
+dn: ou=transports,ads-serverId=kdcServer,ou=servers,ads-directoryServiceId=default,ou=config
+ou: transports
+objectclass: organizationalUnit
+objectclass: top
+
+dn: ads-transportid=ldap1,ou=transports,ads-serverId=kdcServer,ou=servers,ads-directoryServiceId=default,ou=config
+ads-systemport: 10389
+ads-transportenablessl: false
+ads-transportbacklog: 50
+ads-transportnbthreads: 8
+ads-transportaddress: 0.0.0.0
+ads-transportid: ldap1
+objectclass: ads-transport
+objectclass: ads-tcpTransport
+objectclass: top
+ads-enabled: true
+
+dn: ads-transportid=ldaps,ou=transports,ads-serverId=kdcServer,ou=servers,ads-directoryServiceId=default,ou=config
+ads-systemport: 10636
+ads-transportenablessl: true
+ads-transportaddress: localhost
+ads-transportid: ldaps
+objectclass: ads-transport
+objectclass: ads-tcpTransport
+objectclass: top
+ads-enabled: true



Mime
View raw message