directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r240272 - in /directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/service: ChangepwConfiguration.java KdcConfiguration.java
Date Fri, 26 Aug 2005 16:12:19 GMT
Author: erodriguez
Date: Fri Aug 26 09:12:13 2005
New Revision: 240272

URL: http://svn.apache.org/viewcvs?rev=240272&view=rev
Log:
Spun changepw configuration into its own class.

Added:
    directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/service/ChangepwConfiguration.java
  (with props)
Modified:
    directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/service/KdcConfiguration.java

Added: directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/service/ChangepwConfiguration.java
URL: http://svn.apache.org/viewcvs/directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/service/ChangepwConfiguration.java?rev=240272&view=auto
==============================================================================
--- directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/service/ChangepwConfiguration.java
(added)
+++ directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/service/ChangepwConfiguration.java
Fri Aug 26 09:12:13 2005
@@ -0,0 +1,152 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.kerberos.service;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+import javax.security.auth.kerberos.KerberosPrincipal;
+
+import org.apache.kerberos.crypto.encryption.EncryptionType;
+
+public class ChangepwConfiguration
+{
+    /** the prop key const for changepw.port */
+    public static final String CHANGEPW_PORT_KEY = "changepw.port";
+
+    /** the prop key const for changepw.principal */
+    private static final String CHANGEPW_PRINCIPAL_KEY = "changepw.principal";
+
+    /** the prop key const for changepw.encryption.types */
+    private static final String CHANGEPW_ENCRYPTION_TYPES = "changepw.encryption.types";
+
+    /** the prop key const for changepw.buffer.size */
+    private static final String CHANGEPW_BUFFER_SIZE = "changepw.buffer.size";
+
+    /** the default change password port */
+    public static final int CHANGEPW_DEFAULT_PORT = 464;
+
+    /** the default changepw principal */
+    private static final String CHANGEPW_DEFAULT_PRINCIPAL = "kadmin/changepw@EXAMPLE.COM";
+
+    /** the default changepw buffer size */
+    private static final int CHANGEPW_DEFAULT_BUFFER_SIZE = 1024;
+
+    private final Properties properties = new Properties();
+    private EncryptionType[] encryptionTypes;
+
+    public ChangepwConfiguration()
+    {
+        prepareEncryptionTypes();
+    }
+
+    public ChangepwConfiguration( Properties properties )
+    {
+        this.properties.putAll( properties );
+
+        prepareEncryptionTypes();
+    }
+
+    public EncryptionType[] getEncryptionTypes()
+    {
+        return encryptionTypes;
+    }
+
+    public Hashtable getProperties()
+    {
+        // Request that the krb5key value be returned as binary
+        properties.setProperty( "java.naming.ldap.attributes.binary", "krb5Key" );
+
+        return properties;
+    }
+
+    public int getBufferSize()
+    {
+        String key = CHANGEPW_BUFFER_SIZE;
+
+        if ( properties.containsKey( key ) )
+        {
+            return Integer.parseInt( properties.getProperty( key ) );
+        }
+
+        return CHANGEPW_DEFAULT_BUFFER_SIZE;
+    }
+
+    public int getChangepwPort()
+    {
+        String key = CHANGEPW_PORT_KEY;
+
+        if ( properties.containsKey( key ) )
+        {
+            return Integer.parseInt( properties.getProperty( key ) );
+        }
+
+        return CHANGEPW_DEFAULT_PORT;
+    }
+
+    public KerberosPrincipal getChangepwPrincipal()
+    {
+        String key = CHANGEPW_PRINCIPAL_KEY;
+
+        if ( properties.containsKey( key ) )
+        {
+            return new KerberosPrincipal( properties.getProperty( key ) );
+        }
+
+        return new KerberosPrincipal( CHANGEPW_DEFAULT_PRINCIPAL );
+    }
+
+    private void prepareEncryptionTypes()
+    {
+        String[] encryptionTypeStrings = null;
+
+        String key = CHANGEPW_ENCRYPTION_TYPES;
+
+        if ( properties.containsKey( key ) )
+        {
+            encryptionTypeStrings = ( properties.getProperty( key ) ).split( "\\s" );
+        }
+        else
+        {
+            encryptionTypeStrings = new String[] { "des-cbc-md5" };
+        }
+
+        List encTypes = new ArrayList();
+
+        for ( int i = 0; i < encryptionTypeStrings.length; i++ )
+        {
+            String enc = encryptionTypeStrings[ i ];
+
+            Iterator it = EncryptionType.VALUES.iterator();
+
+            while ( it.hasNext() )
+            {
+                EncryptionType type = (EncryptionType) it.next();
+
+                if ( type.toString().equalsIgnoreCase( enc ) )
+                {
+                    encTypes.add( type );
+                }
+            }
+        }
+
+        encryptionTypes = (EncryptionType[]) encTypes.toArray( new EncryptionType[ encTypes.size()
] );
+    }
+}

Propchange: directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/service/ChangepwConfiguration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/service/KdcConfiguration.java
URL: http://svn.apache.org/viewcvs/directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/service/KdcConfiguration.java?rev=240272&r1=240271&r2=240272&view=diff
==============================================================================
--- directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/service/KdcConfiguration.java
(original)
+++ directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/service/KdcConfiguration.java
Fri Aug 26 09:12:13 2005
@@ -52,18 +52,6 @@
     private final Properties properties = new Properties();
     private EncryptionType[] encryptionTypes;
 
-    /** the prop key const for changepw.port */
-    public static final String CHANGEPW_PORT_KEY = "changepw.port";
-
-    /** the prop key const for changepw.principal */
-    private static final String CHANGEPW_PRINCIPAL_KEY = "changepw.principal";
-
-    /** the default change password port */
-    public static final int CHANGEPW_DEFAULT_PORT = 464;
-
-    /** the default changepw principal */
-    private static final String CHANGEPW_DEFAULT_PRINCIPAL = "kadmin/changepw@EXAMPLE.COM";
-
     public KdcConfiguration()
     {
         prepareEncryptionTypes();
@@ -244,30 +232,6 @@
         }
 
         return true;
-    }
-
-    public int getChangepwPort()
-    {
-        String key = CHANGEPW_PORT_KEY;
-
-        if (properties.containsKey(key))
-        {
-            return Integer.parseInt(properties.getProperty(key));
-        }
-
-        return CHANGEPW_DEFAULT_PORT;
-    }
-
-    public KerberosPrincipal getChangepwPrincipal()
-    {
-        String key = CHANGEPW_PRINCIPAL_KEY;
-
-        if (properties.containsKey(key))
-        {
-            return new KerberosPrincipal(properties.getProperty(key));
-        }
-
-        return new KerberosPrincipal(CHANGEPW_DEFAULT_PRINCIPAL);
     }
 
     private void prepareEncryptionTypes()



Mime
View raw message