directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r330756 - in /directory/protocol-providers/changepw/trunk: ./ src/main/java/org/apache/changepw/ src/main/java/org/apache/changepw/exceptions/ src/main/java/org/apache/changepw/protocol/ src/main/java/org/apache/changepw/service/
Date Fri, 04 Nov 2005 08:38:59 GMT
Author: trustin
Date: Fri Nov  4 00:38:49 2005
New Revision: 330756

URL: http://svn.apache.org/viewcvs?rev=330756&view=rev
Log:
Migrated protocol-provider for ChangePW protocol to MINA 0.9.

Added:
    directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/protocol/ChangePasswordProtocolCodecFactory.java
      - copied, changed from r330736, directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/protocol/ChangePasswordProtocolProvider.java
Removed:
    directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/protocol/ChangePasswordProtocolProvider.java
Modified:
    directory/protocol-providers/changepw/trunk/project.xml
    directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/ChangePasswordConfiguration.java
    directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/ChangePasswordServer.java
    directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/exceptions/ChangePasswordException.java
    directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/protocol/ChangePasswordDecoder.java
    directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/protocol/ChangePasswordEncoder.java
    directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/protocol/ChangePasswordProtocolHandler.java
    directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/service/ChangePasswordContext.java

Modified: directory/protocol-providers/changepw/trunk/project.xml
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/changepw/trunk/project.xml?rev=330756&r1=330755&r2=330756&view=diff
==============================================================================
--- directory/protocol-providers/changepw/trunk/project.xml (original)
+++ directory/protocol-providers/changepw/trunk/project.xml Fri Nov  4 00:38:49 2005
@@ -100,7 +100,7 @@
     <dependency>
       <groupId>directory-network</groupId>
       <artifactId>mina</artifactId>
-      <version>0.8.0</version>
+      <version>0.9.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.slf4j</groupId>
@@ -125,7 +125,7 @@
   <build>
     <nagEmailAddress>dev@directory.apache.org</nagEmailAddress>
     <sourceDirectory>${basedir}/src/main/java</sourceDirectory>
-    <unitTestSourceDirectory>${basedir}/src/test</unitTestSourceDirectory>
+    <unitTestSourceDirectory>${basedir}/src/test/java</unitTestSourceDirectory>
     <unitTest>
       <includes>
         <include>**/*Test*</include>

Modified: directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/ChangePasswordConfiguration.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/ChangePasswordConfiguration.java?rev=330756&r1=330755&r2=330756&view=diff
==============================================================================
--- directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/ChangePasswordConfiguration.java
(original)
+++ directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/ChangePasswordConfiguration.java
Fri Nov  4 00:38:49 2005
@@ -33,6 +33,8 @@
 
 public class ChangePasswordConfiguration extends ServiceConfiguration
 {
+    private static final long serialVersionUID = 3509208713288140629L;
+
     /** the prop key const for changepw.principal */
     private static final String PRINCIPAL_KEY = "principal";
 

Modified: directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/ChangePasswordServer.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/ChangePasswordServer.java?rev=330756&r1=330755&r2=330756&view=diff
==============================================================================
--- directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/ChangePasswordServer.java
(original)
+++ directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/ChangePasswordServer.java
Fri Nov  4 00:38:49 2005
@@ -20,10 +20,10 @@
 import java.io.IOException;
 import java.util.Dictionary;
 
-import org.apache.changepw.protocol.ChangePasswordProtocolProvider;
+import org.apache.changepw.protocol.ChangePasswordProtocolHandler;
 import org.apache.kerberos.store.PrincipalStore;
+import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.TransportType;
-import org.apache.mina.protocol.ProtocolProvider;
 import org.apache.mina.registry.Service;
 import org.apache.mina.registry.ServiceRegistry;
 import org.slf4j.Logger;
@@ -45,7 +45,7 @@
     private ServiceRegistry registry;
     private PrincipalStore store;
 
-    private ProtocolProvider provider;
+    private IoHandler handler;
     private Service tcpService;
     private Service udpService;
 
@@ -60,13 +60,13 @@
 
         try
         {
-            provider = new ChangePasswordProtocolProvider( config, this.store );
+            handler = new ChangePasswordProtocolHandler( config, this.store );
 
             udpService = new Service( name, TransportType.DATAGRAM, port );
             tcpService = new Service( name, TransportType.SOCKET, port );
 
-            registry.bind( udpService, provider );
-            registry.bind( tcpService, provider );
+            registry.bind( udpService, handler );
+            registry.bind( tcpService, handler );
 
             log.debug( name + " listening on port " + port );
         }
@@ -87,7 +87,7 @@
         registry.unbind( tcpService );
 
         registry = null;
-        provider = null;
+        handler = null;
         udpService = null;
         tcpService = null;
 

Modified: directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/exceptions/ChangePasswordException.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/exceptions/ChangePasswordException.java?rev=330756&r1=330755&r2=330756&view=diff
==============================================================================
--- directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/exceptions/ChangePasswordException.java
(original)
+++ directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/exceptions/ChangePasswordException.java
Fri Nov  4 00:38:49 2005
@@ -27,6 +27,8 @@
  */
 public class ChangePasswordException extends KerberosException
 {
+    private static final long serialVersionUID = 4880242751298831543L;
+
     // ------------------------------------------------------------------------
     // C O N S T R U C T O R S
     // ------------------------------------------------------------------------

Modified: directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/protocol/ChangePasswordDecoder.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/protocol/ChangePasswordDecoder.java?rev=330756&r1=330755&r2=330756&view=diff
==============================================================================
--- directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/protocol/ChangePasswordDecoder.java
(original)
+++ directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/protocol/ChangePasswordDecoder.java
Fri Nov  4 00:38:49 2005
@@ -21,24 +21,19 @@
 
 import org.apache.changepw.io.ChangePasswordRequestDecoder;
 import org.apache.mina.common.ByteBuffer;
-import org.apache.mina.protocol.ProtocolDecoder;
-import org.apache.mina.protocol.ProtocolDecoderOutput;
-import org.apache.mina.protocol.ProtocolSession;
-import org.apache.mina.protocol.ProtocolViolationException;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.filter.codec.ProtocolDecoder;
+import org.apache.mina.filter.codec.ProtocolDecoderOutput;
 
 public class ChangePasswordDecoder implements ProtocolDecoder
 {
-    public void decode( ProtocolSession session, ByteBuffer in, ProtocolDecoderOutput out
)
-            throws ProtocolViolationException
+    public void decode( IoSession session, ByteBuffer in, ProtocolDecoderOutput out ) throws
IOException
     {
         ChangePasswordRequestDecoder decoder = new ChangePasswordRequestDecoder();
-        try
-        {
-            out.write( decoder.decode( in.buf() ) );
-        }
-        catch ( IOException ioe )
-        {
-            ioe.printStackTrace();
-        }
+        out.write( decoder.decode( in.buf() ) );
+    }
+
+    public void dispose( IoSession session ) throws Exception
+    {
     }
 }

Modified: directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/protocol/ChangePasswordEncoder.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/protocol/ChangePasswordEncoder.java?rev=330756&r1=330755&r2=330756&view=diff
==============================================================================
--- directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/protocol/ChangePasswordEncoder.java
(original)
+++ directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/protocol/ChangePasswordEncoder.java
Fri Nov  4 00:38:49 2005
@@ -24,40 +24,31 @@
 import org.apache.changepw.messages.ChangePasswordError;
 import org.apache.changepw.messages.ChangePasswordReply;
 import org.apache.mina.common.ByteBuffer;
-import org.apache.mina.protocol.ProtocolEncoder;
-import org.apache.mina.protocol.ProtocolEncoderOutput;
-import org.apache.mina.protocol.ProtocolSession;
-import org.apache.mina.protocol.ProtocolViolationException;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.filter.codec.ProtocolEncoder;
+import org.apache.mina.filter.codec.ProtocolEncoderOutput;
 
 public class ChangePasswordEncoder implements ProtocolEncoder
 {
-    public void encode( ProtocolSession session, Object message, ProtocolEncoderOutput out
)
-            throws ProtocolViolationException
+    public void encode( IoSession session, Object message, ProtocolEncoderOutput out ) throws
IOException
     {
         ByteBuffer buf = ByteBuffer.allocate( 512 );
 
-        try
+        if ( message instanceof ChangePasswordReply )
         {
-            if ( message instanceof ChangePasswordReply )
-            {
-                encodeReply( (ChangePasswordReply) message, buf );
-            }
-            else
+            encodeReply( (ChangePasswordReply) message, buf );
+        }
+        else
+        {
+            if ( message instanceof ChangePasswordError )
             {
-                if ( message instanceof ChangePasswordError )
-                {
-                    encodeError( (ChangePasswordError) message, buf );
-                }
+                encodeError( (ChangePasswordError) message, buf );
             }
+        }
 
-            buf.flip();
+        buf.flip();
 
-            out.write( buf );
-        }
-        catch ( IOException ioe )
-        {
-            throw new ProtocolViolationException();
-        }
+        out.write( buf );
     }
 
     private void encodeReply( ChangePasswordReply reply, ByteBuffer buf ) throws IOException
@@ -72,5 +63,9 @@
         ChangePasswordErrorEncoder encoder = new ChangePasswordErrorEncoder();
 
         encoder.encode( buf.buf(), error );
+    }
+
+    public void dispose( IoSession arg0 ) throws Exception
+    {
     }
 }

Copied: directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/protocol/ChangePasswordProtocolCodecFactory.java
(from r330736, directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/protocol/ChangePasswordProtocolProvider.java)
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/protocol/ChangePasswordProtocolCodecFactory.java?p2=directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/protocol/ChangePasswordProtocolCodecFactory.java&p1=directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/protocol/ChangePasswordProtocolProvider.java&r1=330736&r2=330756&rev=330756&view=diff
==============================================================================
--- directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/protocol/ChangePasswordProtocolProvider.java
(original)
+++ directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/protocol/ChangePasswordProtocolCodecFactory.java
Fri Nov  4 00:38:49 2005
@@ -17,47 +17,33 @@
 
 package org.apache.changepw.protocol;
 
-import org.apache.changepw.ChangePasswordConfiguration;
-import org.apache.kerberos.store.PrincipalStore;
-import org.apache.mina.protocol.ProtocolCodecFactory;
-import org.apache.mina.protocol.ProtocolDecoder;
-import org.apache.mina.protocol.ProtocolEncoder;
-import org.apache.mina.protocol.ProtocolHandler;
-import org.apache.mina.protocol.ProtocolProvider;
+import org.apache.mina.filter.codec.ProtocolCodecFactory;
+import org.apache.mina.filter.codec.ProtocolDecoder;
+import org.apache.mina.filter.codec.ProtocolEncoder;
 
-public class ChangePasswordProtocolProvider implements ProtocolProvider
+public class ChangePasswordProtocolCodecFactory implements ProtocolCodecFactory
 {
-    // Protocol handler is usually a singleton.
-    private ProtocolHandler HANDLER;
+    private static final ChangePasswordProtocolCodecFactory INSTANCE = 
+        new ChangePasswordProtocolCodecFactory();
 
-    // Codec factory is also usually a singleton.
-    private static ProtocolCodecFactory CODEC_FACTORY = new ProtocolCodecFactory()
+    public static ChangePasswordProtocolCodecFactory getInstance()
     {
-        public ProtocolEncoder newEncoder()
-        {
-            // Create a new encoder.
-            return new ChangePasswordEncoder();
-        }
-
-        public ProtocolDecoder newDecoder()
-        {
-            // Create a new decoder.
-            return new ChangePasswordDecoder();
-        }
-    };
+        return INSTANCE;
+    }
 
-    public ChangePasswordProtocolProvider( ChangePasswordConfiguration config, PrincipalStore
store )
+    private ChangePasswordProtocolCodecFactory()
     {
-        HANDLER = new ChangePasswordProtocolHandler( config, store );
     }
-
-    public ProtocolCodecFactory getCodecFactory()
+    
+    public ProtocolEncoder getEncoder()
     {
-        return CODEC_FACTORY;
+        // Create a new encoder.
+        return new ChangePasswordEncoder();
     }
 
-    public ProtocolHandler getHandler()
+    public ProtocolDecoder getDecoder()
     {
-        return HANDLER;
+        // Create a new decoder.
+        return new ChangePasswordDecoder();
     }
 }

Modified: directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/protocol/ChangePasswordProtocolHandler.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/protocol/ChangePasswordProtocolHandler.java?rev=330756&r1=330755&r2=330756&view=diff
==============================================================================
--- directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/protocol/ChangePasswordProtocolHandler.java
(original)
+++ directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/protocol/ChangePasswordProtocolHandler.java
Fri Nov  4 00:38:49 2005
@@ -26,13 +26,14 @@
 import org.apache.changepw.service.ChangePasswordContext;
 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.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.filter.codec.ProtocolCodecFilter;
 import org.apache.protocol.common.chain.Command;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class ChangePasswordProtocolHandler implements ProtocolHandler
+public class ChangePasswordProtocolHandler implements IoHandler
 {
     private static final Logger log = LoggerFactory.getLogger( ChangePasswordProtocolHandler.class
);
 
@@ -49,15 +50,20 @@
         changepwService = new ChangePasswordChain();
     }
 
-    public void sessionCreated( ProtocolSession session )
+    public void sessionCreated( IoSession session ) throws Exception
     {
         if ( log.isDebugEnabled() )
         {
             log.debug( session.getRemoteAddress() + " CREATED" );
         }
+        
+        session.getFilterChain().addFirst(
+                "codec",
+                new ProtocolCodecFilter(
+                        ChangePasswordProtocolCodecFactory.getInstance() ) );
     }
 
-    public void sessionOpened( ProtocolSession session )
+    public void sessionOpened( IoSession session )
     {
         if ( log.isDebugEnabled() )
         {
@@ -65,7 +71,7 @@
         }
     }
 
-    public void sessionClosed( ProtocolSession session )
+    public void sessionClosed( IoSession session )
     {
         if ( log.isDebugEnabled() )
         {
@@ -73,7 +79,7 @@
         }
     }
 
-    public void sessionIdle( ProtocolSession session, IdleStatus status )
+    public void sessionIdle( IoSession session, IdleStatus status )
     {
         if ( log.isDebugEnabled() )
         {
@@ -81,13 +87,13 @@
         }
     }
 
-    public void exceptionCaught( ProtocolSession session, Throwable cause )
+    public void exceptionCaught( IoSession session, Throwable cause )
     {
         log.error( session.getRemoteAddress() + " EXCEPTION", cause );
         session.close();
     }
 
-    public void messageReceived( ProtocolSession session, Object message )
+    public void messageReceived( IoSession session, Object message )
     {
         if ( log.isDebugEnabled() )
         {
@@ -115,7 +121,7 @@
         }
     }
 
-    public void messageSent( ProtocolSession session, Object message )
+    public void messageSent( IoSession session, Object message )
     {
         if ( log.isDebugEnabled() )
         {

Modified: directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/service/ChangePasswordContext.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/service/ChangePasswordContext.java?rev=330756&r1=330755&r2=330756&view=diff
==============================================================================
--- directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/service/ChangePasswordContext.java
(original)
+++ directory/protocol-providers/changepw/trunk/src/main/java/org/apache/changepw/service/ChangePasswordContext.java
Fri Nov  4 00:38:49 2005
@@ -31,6 +31,8 @@
 
 public class ChangePasswordContext extends ContextBase
 {
+    private static final long serialVersionUID = -5124209294966799740L;
+
     private ChangePasswordConfiguration config;
     private PrincipalStore store;
     private AbstractPasswordMessage request;



Mime
View raw message