directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r165505 - /directory/shared/kerberos/trunk/common/src/java/org/apache/kerberos/service/KdcConfiguration.java
Date Sun, 01 May 2005 14:03:33 GMT
Author: akarasulu
Date: Sun May  1 07:03:32 2005
New Revision: 165505

URL: http://svn.apache.org/viewcvs?rev=165505&view=rev
Log:
changes ...

 o added public env key constants for alt krb5 and chgpw ports
 o added some javadocs
 o formatted code 
 o using getProperty instead of get with cast to String
 

Modified:
    directory/shared/kerberos/trunk/common/src/java/org/apache/kerberos/service/KdcConfiguration.java

Modified: directory/shared/kerberos/trunk/common/src/java/org/apache/kerberos/service/KdcConfiguration.java
URL: http://svn.apache.org/viewcvs/directory/shared/kerberos/trunk/common/src/java/org/apache/kerberos/service/KdcConfiguration.java?rev=165505&r1=165504&r2=165505&view=diff
==============================================================================
--- directory/shared/kerberos/trunk/common/src/java/org/apache/kerberos/service/KdcConfiguration.java
(original)
+++ directory/shared/kerberos/trunk/common/src/java/org/apache/kerberos/service/KdcConfiguration.java
Sun May  1 07:03:32 2005
@@ -14,9 +14,9 @@
  *   limitations under the License.
  *
  */
-
 package org.apache.kerberos.service;
 
+
 import java.util.ArrayList;
 import java.util.Hashtable;
 import java.util.Iterator;
@@ -41,6 +41,19 @@
     /** the default change password port */
     public static final int DEFAULT_CHANGEPW_PORT = 464;
 
+    /*
+      kdc.default.port is a misnomer ... should just be kdc.port or something
+      since this is used to set it to an alternate port number which is not
+      the default of 88.  The same argument applies to the change password
+      property key name.
+    */
+
+    /** the environment property used for setting an alternative kdc port */
+    public static final String KERBEROS_PORT_KEY = "kdc.default.port";
+
+    /** the environment property used for setting the alternative changepw port */
+    public static final String CHANGEPW_PORT = "changepw.default.port";
+
     private static final int BUFFER_SIZE = 1024;
     private static final int MINUTE = 1000 * 60;
     
@@ -61,180 +74,231 @@
     public KdcConfiguration( Properties properties )
     {
         this.properties.putAll( properties );
+
         prepareEncryptionTypes();
     }
 
+
     public String getPrimaryRealm()
     {
         String key = KDC_PRIMARY_REALM;
+
         if ( properties.containsKey( key ) )
         {
-            return ( String ) properties.get( key );
+            return properties.getProperty( key );
         }
+
         return DEFAULT_REALM;
     }
 
+
     public KerberosPrincipal getKdcPrincipal()
     {
         String key = KDC_PRINCIPAL;
+
         if ( properties.containsKey( key ) )
         {
-            return new KerberosPrincipal( ( String ) properties.get( key ) );
+            return new KerberosPrincipal( properties.getProperty( key ) );
         }
+
         return new KerberosPrincipal( DEFAULT_PRINCIPAL );
     }
-    
+
+
     public EncryptionType[] getEncryptionTypes()
     {
         return _encryptionTypes;
     }
 
+
     public Hashtable getProperties()
     {
         // Request that the krb5key value be returned as binary
-        properties.put( "java.naming.ldap.attributes.binary", "krb5Key" );
+
+        properties.setProperty( "java.naming.ldap.attributes.binary", "krb5Key" );
 
         return properties;
     }
 
+
     public long getClockSkew()
     {
         String key = "kdc.allowable.clockskew";
+
         if ( properties.containsKey( key ) )
         {
-            return MINUTE * Long.parseLong( ( String ) properties.get( key ) );
+            return MINUTE * Long.parseLong( properties.getProperty( key ) );
         }
+
         return MINUTE * 5;
     }
 
+
     public long getMaximumTicketLifetime()
     {
         String key = "tgs.maximum.ticket.lifetime";
+
         if ( properties.containsKey( key ) )
         {
-            return MINUTE * Long.parseLong( ( String ) properties.get( key ) );
+            return MINUTE * Long.parseLong( properties.getProperty( key ) );
         }
+
         return MINUTE * 1440;
     }
 
+
     public long getMaximumRenewableLifetime()
     {
         String key = "tgs.maximum.renewable.lifetime";
+
         if ( properties.containsKey( key ) )
         {
-            return MINUTE * Long.parseLong( ( String ) properties.get( key ) );
+            return MINUTE * Long.parseLong( properties.getProperty( key ) );
         }
+
         return MINUTE * 10080;
     }
 
+
     public int getDefaultPort()
     {
-        String key = "kdc.default.port";
+        String key = KERBEROS_PORT_KEY;
+
         if ( properties.containsKey( key ) )
         {
-            return Integer.parseInt( ( String ) properties.get( key ) );
+            return Integer.parseInt( properties.getProperty( key ) );
         }
+
         return DEFAULT_KERBEROS_PORT;
     }
 
+
     public int getBufferSize()
     {
         String key = "kdc.buffer.size";
+
         if ( properties.containsKey( key ) )
         {
-            return Integer.parseInt( ( String ) properties.get( key ) );
+            return Integer.parseInt( properties.getProperty( key ) );
         }
+
         return BUFFER_SIZE;
     }
 
+
     public boolean isPaEncTimestampRequired()
     {
         String key = "kdc.pa.enc.timestamp.required";
+
         if ( properties.containsKey( key ) )
         {
-            return "true".equalsIgnoreCase( ( String ) properties.get( key ) );
+            return "true".equalsIgnoreCase( properties.getProperty( key ) );
         }
+
         return true;
     }
 
+
     public boolean isEmptyAddressesAllowed()
     {
         String key = "tgs.empty.addresses.allowed";
+
         if ( properties.containsKey( key ) )
         {
-            return "true".equalsIgnoreCase( ( String ) properties.get( key ) );
+            return "true".equalsIgnoreCase( properties.getProperty( key ) );
         }
+
         return true;
     }
 
+
     public boolean isForwardableAllowed()
     {
         String key = "tgs.forwardable.allowed";
+
         if ( properties.containsKey( key ) )
         {
-            return "true".equalsIgnoreCase( ( String ) properties.get( key ) );
+            return "true".equalsIgnoreCase( properties.getProperty( key ) );
         }
+
         return true;
     }
 
+
     public boolean isProxiableAllowed()
     {
         String key = "tgs.proxiable.allowed";
+
         if ( properties.containsKey( key ) )
         {
-            return "true".equalsIgnoreCase( ( String ) properties.get( key ) );
+            return "true".equalsIgnoreCase( properties.getProperty( key ) );
         }
+
         return true;
     }
 
+
     public boolean isPostdateAllowed()
     {
         String key = "tgs.postdate.allowed";
+
         if ( properties.containsKey( key ) )
         {
-            return "true".equalsIgnoreCase( ( String ) properties.get( key ) );
+            return "true".equalsIgnoreCase( properties.getProperty( key ) );
         }
+
         return true;
     }
 
+
     public boolean isRenewableAllowed()
     {
         String key = "tgs.renewable.allowed";
+
         if ( properties.containsKey( key ) )
         {
-            return "true".equalsIgnoreCase( ( String ) properties.get( key ) );
+            return "true".equalsIgnoreCase( properties.getProperty( key ) );
         }
+
         return true;
     }
 
+
     public int getChangepwPort()
     {
-        String key = "changepw.default.port";
+        String key = CHANGEPW_PORT;
+
         if ( properties.containsKey( key ) )
         {
-            return Integer.parseInt( ( String ) properties.get( key ) );
+            return Integer.parseInt( properties.getProperty( key ) );
         }
+
         return DEFAULT_CHANGEPW_PORT;
     }
 
+
     public KerberosPrincipal getChangepwPrincipal()
     {
         String key = "changepw.principal";
+
         if ( properties.containsKey( key ) )
         {
-            return new KerberosPrincipal( ( String ) properties.get( key ) );
+            return new KerberosPrincipal( properties.getProperty( key ) );
         }
+
         return new KerberosPrincipal( DEFAULT_CHANGEPW_PRINCIPAL );
     }
-    
+
+
     private void prepareEncryptionTypes()
     {
         String[] encryptionTypes = null;
         
         String key = "kdc.encryption.types";
+
         if ( properties.containsKey( key ) )
         {
-            encryptionTypes = ( ( String ) properties.get( key ) ).split( "\\s" );
+            encryptionTypes = ( properties.getProperty( key ) ).split( "\\s" );
         }
         else
         {
@@ -246,10 +310,13 @@
         for ( int i = 0; i < encryptionTypes.length; i++ )
         {
             String enc = encryptionTypes[i];
+
             Iterator it = EncryptionType.VALUES.iterator();
+
             while ( it.hasNext() )
             {
                 EncryptionType type = ( EncryptionType ) it.next();
+
                 if ( type.toString().equalsIgnoreCase( enc ) )
                 {
                     encTypes.add( type );



Mime
View raw message