directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r240283 - /directory/protocol-providers/kerberos/branches/refactor-to-chain/src/java/org/apache/kerberos/protocol/KerberosProtocolHandler.java
Date Fri, 26 Aug 2005 16:44:46 GMT
Author: erodriguez
Date: Fri Aug 26 09:44:44 2005
New Revision: 240283

URL: http://svn.apache.org/viewcvs?rev=240283&view=rev
Log:
Handler rewrite to call AS and TGS chains.

Modified:
    directory/protocol-providers/kerberos/branches/refactor-to-chain/src/java/org/apache/kerberos/protocol/KerberosProtocolHandler.java

Modified: directory/protocol-providers/kerberos/branches/refactor-to-chain/src/java/org/apache/kerberos/protocol/KerberosProtocolHandler.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/kerberos/branches/refactor-to-chain/src/java/org/apache/kerberos/protocol/KerberosProtocolHandler.java?rev=240283&r1=240282&r2=240283&view=diff
==============================================================================
--- directory/protocol-providers/kerberos/branches/refactor-to-chain/src/java/org/apache/kerberos/protocol/KerberosProtocolHandler.java
(original)
+++ directory/protocol-providers/kerberos/branches/refactor-to-chain/src/java/org/apache/kerberos/protocol/KerberosProtocolHandler.java
Fri Aug 26 09:44:44 2005
@@ -16,16 +16,15 @@
  */
 package org.apache.kerberos.protocol;
 
-import java.io.IOException;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.kerberos.chain.Command;
 import org.apache.kerberos.exceptions.ErrorType;
-import org.apache.kerberos.exceptions.KerberosException;
-import org.apache.kerberos.messages.AuthenticationReply;
-import org.apache.kerberos.messages.ErrorMessage;
+import org.apache.kerberos.kdc.authentication.AuthenticationContext;
+import org.apache.kerberos.kdc.authentication.AuthenticationServiceChain;
+import org.apache.kerberos.kdc.ticketgrant.TicketGrantingContext;
+import org.apache.kerberos.kdc.ticketgrant.TicketGrantingServiceChain;
 import org.apache.kerberos.messages.KdcRequest;
-import org.apache.kerberos.messages.TicketGrantReply;
 import org.apache.kerberos.service.KdcConfiguration;
 import org.apache.kerberos.store.PrincipalStore;
 import org.apache.mina.common.IdleStatus;
@@ -42,15 +41,20 @@
 public class KerberosProtocolHandler implements ProtocolHandler
 {
     private static final Log log = LogFactory.getLog( KerberosProtocolHandler.class );
-    private AuthenticationService authService;
-    private TicketGrantingService tgsService;
-    private ErrorService errorService;
+
+    private KdcConfiguration config;
+    private PrincipalStore store;
+
+    private Command authService;
+    private Command tgsService;
 
     public KerberosProtocolHandler( KdcConfiguration config, PrincipalStore store )
     {
-        errorService = new ErrorService( config );
-        authService = new AuthenticationService( config, store );
-        tgsService = new TicketGrantingService( config, store );
+        this.config = config;
+        this.store = store;
+
+        authService = new AuthenticationServiceChain();
+        tgsService = new TicketGrantingServiceChain();
     }
 
     public void sessionCreated( ProtocolSession session )
@@ -98,41 +102,47 @@
             log.debug( session.getRemoteAddress() + " RCVD: " + message );
         }
 
-        try
-        {
-            KdcRequest request = (KdcRequest) message;
+        KdcRequest request = (KdcRequest) message;
 
-            int messageType = request.getMessageType().getOrdinal();
+        int messageType = request.getMessageType().getOrdinal();
 
+        try
+        {
             switch ( messageType )
             {
                 case 10:
-                    AuthenticationReply authReply = authService.getReplyFor( request );
-                    session.write( authReply );
+                    AuthenticationContext authContext = new AuthenticationContext();
+                    authContext.setConfig( config );
+                    authContext.setStore( store );
+                    authContext.setRequest( request );
+
+                    authService.execute( authContext );
+
+                    session.write( authContext.getReply() );
                     break;
 
                 case 12:
-                    TicketGrantReply ticketReply = tgsService.getReplyFor( request );
-                    session.write( ticketReply );
+                    TicketGrantingContext tgsContext = new TicketGrantingContext();
+                    tgsContext.setConfig( config );
+                    tgsContext.setStore( store );
+                    tgsContext.setRequest( request );
+
+                    tgsService.execute( tgsContext );
+
+                    session.write( tgsContext.getReply() );
                     break;
 
                 case 11:
                 case 13:
-                    throw new KerberosException( ErrorType.KRB_AP_ERR_BADDIRECTION );
+                    log.error( "Kerberos error:  " + ErrorType.KRB_AP_ERR_BADDIRECTION.getMessage()
);
 
                 default:
-                    throw new KerberosException( ErrorType.KRB_AP_ERR_MSG_TYPE );
+                    log.error( "Kerberos error:  " + ErrorType.KRB_AP_ERR_MSG_TYPE.getMessage()
);
             }
         }
-        catch ( KerberosException ke )
-        {
-            log.error( "Returning error message:  " + ke.getMessage(), ke );
-            ErrorMessage errorMessage = errorService.getReplyFor( ke );
-            session.write( errorMessage );
-        }
-        catch ( IOException ioe )
+        catch ( Exception e )
         {
-            log.error( ioe );
+            log.error( e.getStackTrace() );
         }
     }
 



Mime
View raw message