directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r263849 - in /directory/protocol-providers/changepw/trunk/src/java/org/apache/changepw/protocol: ChangePasswordProtocolHandler.java ChangePasswordProtocolProvider.java
Date Sun, 28 Aug 2005 09:44:24 GMT
Author: erodriguez
Date: Sun Aug 28 02:44:21 2005
New Revision: 263849

URL: http://svn.apache.org/viewcvs?rev=263849&view=rev
Log:
Updates to Change Password protocol provider:
o  Configuration now separate from the KDC, formerly in kerberos-common
o  Refactored to chain

Modified:
    directory/protocol-providers/changepw/trunk/src/java/org/apache/changepw/protocol/ChangePasswordProtocolHandler.java
    directory/protocol-providers/changepw/trunk/src/java/org/apache/changepw/protocol/ChangePasswordProtocolProvider.java

Modified: directory/protocol-providers/changepw/trunk/src/java/org/apache/changepw/protocol/ChangePasswordProtocolHandler.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/changepw/trunk/src/java/org/apache/changepw/protocol/ChangePasswordProtocolHandler.java?rev=263849&r1=263848&r2=263849&view=diff
==============================================================================
--- directory/protocol-providers/changepw/trunk/src/java/org/apache/changepw/protocol/ChangePasswordProtocolHandler.java
(original)
+++ directory/protocol-providers/changepw/trunk/src/java/org/apache/changepw/protocol/ChangePasswordProtocolHandler.java
Sun Aug 28 02:44:21 2005
@@ -17,75 +17,104 @@
 
 package org.apache.changepw.protocol;
 
-import org.apache.changepw.ChangePasswordService;
-import org.apache.changepw.messages.ChangePasswordReply;
 import org.apache.changepw.messages.ChangePasswordRequest;
-import org.apache.changepw.service.ChangePasswordServiceImpl;
-import org.apache.kerberos.service.KdcConfiguration;
+import org.apache.changepw.service.ChangePasswordChain;
+import org.apache.changepw.service.ChangePasswordConfiguration;
+import org.apache.changepw.service.ChangePasswordContext;
+import org.apache.kerberos.chain.Command;
 import org.apache.kerberos.store.PrincipalStore;
 import org.apache.mina.common.IdleStatus;
 import org.apache.mina.protocol.ProtocolHandler;
 import org.apache.mina.protocol.ProtocolSession;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class ChangePasswordProtocolHandler implements ProtocolHandler
 {
-    private KdcConfiguration config;
+    private static final Logger log = LoggerFactory.getLogger( ChangePasswordProtocolHandler.class
);
+
+    private ChangePasswordConfiguration config;
     private PrincipalStore store;
 
-    public ChangePasswordProtocolHandler( KdcConfiguration config, PrincipalStore store )
+    private Command changepwService;
+
+    public ChangePasswordProtocolHandler( ChangePasswordConfiguration config, PrincipalStore
store )
     {
         this.config = config;
         this.store = store;
+
+        changepwService = new ChangePasswordChain();
     }
 
     public void sessionCreated( ProtocolSession session )
     {
-        System.out.println( session.getRemoteAddress() + " CREATED" );
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( session.getRemoteAddress() + " CREATED" );
+        }
     }
 
     public void sessionOpened( ProtocolSession session )
     {
-        System.out.println( session.getRemoteAddress() + " OPENED" );
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( session.getRemoteAddress() + " OPENED" );
+        }
     }
 
     public void sessionClosed( ProtocolSession session )
     {
-        System.out.println( session.getRemoteAddress() + " CLOSED" );
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( session.getRemoteAddress() + " CLOSED" );
+        }
     }
 
     public void sessionIdle( ProtocolSession session, IdleStatus status )
     {
-        System.out.println( session.getRemoteAddress() + " IDLE(" + status + ")" );
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( session.getRemoteAddress() + " IDLE(" + status + ")" );
+        }
     }
 
     public void exceptionCaught( ProtocolSession session, Throwable cause )
     {
-        System.out.println( session.getRemoteAddress() + " EXCEPTION" );
-        cause.printStackTrace( System.out );
-
+        log.error( session.getRemoteAddress() + " EXCEPTION", cause );
         session.close();
     }
 
     public void messageReceived( ProtocolSession session, Object message )
     {
-        System.out.println( session.getRemoteAddress() + " RCVD: " + message );
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( session.getRemoteAddress() + " RCVD: " + message );
+        }
 
-        ChangePasswordService changepwService = new ChangePasswordServiceImpl( config, store
);
+        ChangePasswordRequest request = (ChangePasswordRequest) message;
 
         try
         {
-            ChangePasswordReply reply = changepwService.getReplyFor( (ChangePasswordRequest)
message );
+            ChangePasswordContext changepwContext = new ChangePasswordContext();
+            changepwContext.setConfig( config );
+            changepwContext.setStore( store );
+            changepwContext.setRequest( request );
+
+            changepwService.execute( changepwContext );
 
-            session.write( reply );
+            session.write( changepwContext.getReply() );
         }
         catch ( Exception e )
         {
-            e.printStackTrace();
+            log.error( e.getMessage() );
         }
     }
 
     public void messageSent( ProtocolSession session, Object message )
     {
-        System.out.println( session.getRemoteAddress() + " SENT: " + message );
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( session.getRemoteAddress() + " SENT: " + message );
+        }
     }
 }

Modified: directory/protocol-providers/changepw/trunk/src/java/org/apache/changepw/protocol/ChangePasswordProtocolProvider.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/changepw/trunk/src/java/org/apache/changepw/protocol/ChangePasswordProtocolProvider.java?rev=263849&r1=263848&r2=263849&view=diff
==============================================================================
--- directory/protocol-providers/changepw/trunk/src/java/org/apache/changepw/protocol/ChangePasswordProtocolProvider.java
(original)
+++ directory/protocol-providers/changepw/trunk/src/java/org/apache/changepw/protocol/ChangePasswordProtocolProvider.java
Sun Aug 28 02:44:21 2005
@@ -17,7 +17,7 @@
 
 package org.apache.changepw.protocol;
 
-import org.apache.kerberos.service.KdcConfiguration;
+import org.apache.changepw.service.ChangePasswordConfiguration;
 import org.apache.kerberos.store.PrincipalStore;
 import org.apache.mina.protocol.ProtocolCodecFactory;
 import org.apache.mina.protocol.ProtocolDecoder;
@@ -46,7 +46,7 @@
         }
     };
 
-    public ChangePasswordProtocolProvider( KdcConfiguration config, PrincipalStore store
)
+    public ChangePasswordProtocolProvider( ChangePasswordConfiguration config, PrincipalStore
store )
     {
         HANDLER = new ChangePasswordProtocolHandler( config, store );
     }



Mime
View raw message