directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r202104 - in /directory/protocol-providers/kerberos/trunk/src/java/org/apache/kerberos: kdc/AuthenticationService.java sam/SamSubsystem.java sam/SamVerifier.java
Date Tue, 28 Jun 2005 00:26:40 GMT
Author: akarasulu
Date: Mon Jun 27 17:26:39 2005
New Revision: 202104

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

 o changed the sam subsystem to be a singleton
 o changed verifier signature to pass down the userContext
 o updates to AS due to call to getInstance()


Modified:
    directory/protocol-providers/kerberos/trunk/src/java/org/apache/kerberos/kdc/AuthenticationService.java
    directory/protocol-providers/kerberos/trunk/src/java/org/apache/kerberos/sam/SamSubsystem.java
    directory/protocol-providers/kerberos/trunk/src/java/org/apache/kerberos/sam/SamVerifier.java

Modified: directory/protocol-providers/kerberos/trunk/src/java/org/apache/kerberos/kdc/AuthenticationService.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/kerberos/trunk/src/java/org/apache/kerberos/kdc/AuthenticationService.java?rev=202104&r1=202103&r2=202104&view=diff
==============================================================================
--- directory/protocol-providers/kerberos/trunk/src/java/org/apache/kerberos/kdc/AuthenticationService.java
(original)
+++ directory/protocol-providers/kerberos/trunk/src/java/org/apache/kerberos/kdc/AuthenticationService.java
Mon Jun 27 17:26:39 2005
@@ -64,14 +64,12 @@
 {
     static
     {
-        SamSubsystem.setIntegrityChecker( new TimestampChecker() );
+        SamSubsystem.getInstance().setIntegrityChecker( new TimestampChecker() );
     }
     
 	public AuthenticationService( KdcConfiguration config, PrincipalStore store )
     {
         super( config, store );
-
-        SamSubsystem.setEnvironment( config.getProperties() );
 	}
 	
 	public AuthenticationReply getReplyFor( KdcRequest request ) throws KerberosException
@@ -180,7 +178,7 @@
 			    {
 			        if ( preAuthData[ii].getDataType().equals( PreAuthenticationDataType.PA_ENC_TIMESTAMP
) )
 			        {
-		    		    KerberosKey samKey = SamSubsystem.verify( entry, preAuthData[ii].getDataValue()
);
+		    		    KerberosKey samKey = SamSubsystem.getInstance().verify( entry, preAuthData[ii].getDataValue()
);
 		    		    clientKey = new EncryptionKey( EncryptionType.getTypeByOrdinal( samKey.getKeyType()
), samKey.getEncoded() );
 			        }
 			    }

Modified: directory/protocol-providers/kerberos/trunk/src/java/org/apache/kerberos/sam/SamSubsystem.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/kerberos/trunk/src/java/org/apache/kerberos/sam/SamSubsystem.java?rev=202104&r1=202103&r2=202104&view=diff
==============================================================================
--- directory/protocol-providers/kerberos/trunk/src/java/org/apache/kerberos/sam/SamSubsystem.java
(original)
+++ directory/protocol-providers/kerberos/trunk/src/java/org/apache/kerberos/sam/SamSubsystem.java
Mon Jun 27 17:26:39 2005
@@ -21,6 +21,8 @@
 import java.util.Hashtable;
 
 import javax.security.auth.kerberos.KerberosKey;
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
 
 import org.apache.kerberos.store.PrincipalStoreEntry;
 
@@ -37,14 +39,33 @@
     /** the property key base used for SAM algorithm verifiers */
     public static final String PROPKEY_BASE = "kerberos.sam.type.";
 
-    /** a map of verifiers so we do not need to create a new one every time */
-    private static final HashMap verifiers = new HashMap();
+    public static SamSubsystem instance;
 
-    /** a set of environment parameters */
-    private static final Hashtable env = new Hashtable();
+    /** a map of verifiers so we do not need to create a new one every time */
+    private final HashMap verifiers = new HashMap();
 
     /** the key integrity checker used by the subsystem for all sam types */
-    private static KeyIntegrityChecker keyChecker;
+    private KeyIntegrityChecker keyChecker;
+
+    /** the user context the SamSubsystem would use to verify passwords */
+    private DirContext userContext;
+    private String userBaseRdn;
+
+
+    /**
+     * Gets the singleton instance of the SamSubsystem.
+     *
+     * @return the singleton for the SamSubsystem
+     */
+    public static SamSubsystem getInstance()
+    {
+        if ( instance == null )
+        {
+            instance = new SamSubsystem();
+        }
+
+        return instance;
+    }
 
 
     /**
@@ -52,9 +73,9 @@
      *
      * @param keyChecker the KeyIntegrityChecker used by the entire SamSubsystem
      */
-    public static void setIntegrityChecker( KeyIntegrityChecker keyChecker )
+    public void setIntegrityChecker( KeyIntegrityChecker keyChecker )
     {
-        SamSubsystem.keyChecker = keyChecker;
+        this.keyChecker = keyChecker;
     }
 
 
@@ -68,7 +89,7 @@
      * @throws SamException thrown when there is a failure within the verifier
      * or a verifier cannot be found.
      */
-    public static KerberosKey verify( PrincipalStoreEntry entry, byte[] sad ) throws SamException
+    public KerberosKey verify( PrincipalStoreEntry entry, byte[] sad ) throws SamException
     {
         SamVerifier verifier = null;
 
@@ -91,6 +112,17 @@
 
         String key = PROPKEY_BASE + entry.getSamType().getOrdinal();
 
+        Hashtable env = new Hashtable();
+
+        try
+        {
+            env.putAll( userContext.getEnvironment() );
+        }
+        catch (NamingException e)
+        {
+            e.printStackTrace();
+        }
+
         if ( ! env.containsKey( key ) )
         {
             String msg = "Could not find property '" + key + "'";
@@ -106,7 +138,15 @@
 
             verifier = ( SamVerifier ) c.newInstance();
 
-            verifier.setEnvironment( env );
+            try
+            {
+                verifier.setUserContext( ( DirContext ) userContext.lookup( userBaseRdn )
);
+            }
+            catch (NamingException e)
+            {
+                e.printStackTrace();
+
+            }
 
             verifier.setIntegrityChecker( keyChecker );
 
@@ -152,8 +192,15 @@
     }
 
 
-    public static void setEnvironment( Hashtable properties )
+    /**
+     * Sets the context under which user entries can be found.
+     *
+     * @param userContext the jndi context under which users can be found.
+     * @param userBaseRdn the container with users
+     */
+    public void setUserContext( DirContext userContext, String userBaseRdn )
     {
-        env.putAll( properties );
+        this.userContext = userContext;
+        this.userBaseRdn = userBaseRdn;
     }
 }

Modified: directory/protocol-providers/kerberos/trunk/src/java/org/apache/kerberos/sam/SamVerifier.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/kerberos/trunk/src/java/org/apache/kerberos/sam/SamVerifier.java?rev=202104&r1=202103&r2=202104&view=diff
==============================================================================
--- directory/protocol-providers/kerberos/trunk/src/java/org/apache/kerberos/sam/SamVerifier.java
(original)
+++ directory/protocol-providers/kerberos/trunk/src/java/org/apache/kerberos/sam/SamVerifier.java
Mon Jun 27 17:26:39 2005
@@ -19,11 +19,10 @@
 
 import javax.security.auth.kerberos.KerberosKey;
 import javax.security.auth.kerberos.KerberosPrincipal;
+import javax.naming.directory.DirContext;
 
 import org.apache.kerberos.messages.value.SamType;
 
-import java.util.Hashtable;
-
 
 /**
  * Single-use Authentication Mechanism verifier (subsystem) interface.
@@ -52,9 +51,6 @@
     /** Shuts down one of many pluggable SAM type subsystem*/
     void shutdown();
 
-    /** Sets the environment properties for a SamVerifier */
-    void setEnvironment( Hashtable env );
-
     /**
      * SamVerifiers require a KeyIntegrityChecker to calculate the integrity of
      * a generated KerberosKey.  The Kerberos service exposes this interface
@@ -81,4 +77,7 @@
      * @return the type value for the SAM algorithm used to verify the SUP.
      */
     SamType getSamType();
+
+    /** sets the user context where users are stored for the primary realm */
+    void setUserContext( DirContext userContext );
 }



Mime
View raw message