Author: erodriguez
Date: Fri Jan 14 15:07:50 2005
New Revision: 125230

URL: http://svn.apache.org/viewcvs?view=rev&rev=125230
Log:
Changepw update to MINA front-end.
Added:
   
incubator/directory/changepw/trunk/main/src/java/org/apache/changepw/Main.java
   
incubator/directory/changepw/trunk/protocol/src/java/org/apache/changepw/protocol/ChangePasswordDecoder.java
   
incubator/directory/changepw/trunk/protocol/src/java/org/apache/changepw/protocol/ChangePasswordEncoder.java
   
incubator/directory/changepw/trunk/protocol/src/java/org/apache/changepw/protocol/ChangePasswordProtocolHandler.java
   
incubator/directory/changepw/trunk/protocol/src/java/org/apache/changepw/protocol/ChangePasswordProtocolProvider.java
Modified:
   
incubator/directory/changepw/trunk/core/src/java/org/apache/changepw/ChangePasswordDispatcher.java
   
incubator/directory/changepw/trunk/core/src/java/org/apache/changepw/io/ChangePasswordErrorEncoder.java
   
incubator/directory/changepw/trunk/core/src/java/org/apache/changepw/io/ChangePasswordReplyEncoder.java

Modified: 
incubator/directory/changepw/trunk/core/src/java/org/apache/changepw/ChangePasswordDispatcher.java
Url: 
http://svn.apache.org/viewcvs/incubator/directory/changepw/trunk/core/src/java/org/apache/changepw/ChangePasswordDispatcher.java?view=diff&rev=125230&p1=incubator/directory/changepw/trunk/core/src/java/org/apache/changepw/ChangePasswordDispatcher.java&r1=125229&p2=incubator/directory/changepw/trunk/core/src/java/org/apache/changepw/ChangePasswordDispatcher.java&r2=125230
==============================================================================
--- 
incubator/directory/changepw/trunk/core/src/java/org/apache/changepw/ChangePasswordDispatcher.java
  (original)
+++ 
incubator/directory/changepw/trunk/core/src/java/org/apache/changepw/ChangePasswordDispatcher.java
  Fri Jan 14 15:07:50 2005
@@ -53,9 +53,9 @@
                changepwService = new ChangePasswordServiceImpl( this.store, 
this.bootstrap, this.config );
        }
        
-       public byte[] dispatch( ByteBuffer requestBuffer ) throws IOException
+       public void dispatch( ByteBuffer requestBuffer ) throws IOException
     {
-               byte[] reply = null;
+               ByteBuffer replyBuffer = ByteBuffer.allocate( 512 );
                
                try
         {
@@ -65,14 +65,14 @@
                        ChangePasswordReply changepwReply = 
changepwService.getReplyFor( changepwRequest );
                        
                        ChangePasswordReplyEncoder encoder = new 
ChangePasswordReplyEncoder();
-                       reply = encoder.encode( changepwReply );
+                       encoder.encode( replyBuffer, changepwReply );
                }
         catch ( KerberosException ke )
         {
                        System.out.println( "Returning error message:  " + 
ke.getMessage() );
                        ChangePasswordError errorMessage = 
errorService.getReplyFor( ke );
                        ChangePasswordErrorEncoder errorEncoder = new 
ChangePasswordErrorEncoder();
-                       reply = errorEncoder.encode( errorMessage );
+                       errorEncoder.encode( replyBuffer, errorMessage );
                }
         catch ( IOException ioe )
         {
@@ -81,10 +81,8 @@
                        ChangePasswordError errorMessage =
                                errorService.getReplyFor( 
ChangePasswordException.KRB5_KPASSWD_MALFORMED );
                        ChangePasswordErrorEncoder errorEncoder = new 
ChangePasswordErrorEncoder();
-                       reply = errorEncoder.encode( errorMessage );
+                       errorEncoder.encode( replyBuffer, errorMessage );
                }
-               
-               return reply;
        }
 }
 

Modified: 
incubator/directory/changepw/trunk/core/src/java/org/apache/changepw/io/ChangePasswordErrorEncoder.java
Url: 
http://svn.apache.org/viewcvs/incubator/directory/changepw/trunk/core/src/java/org/apache/changepw/io/ChangePasswordErrorEncoder.java?view=diff&rev=125230&p1=incubator/directory/changepw/trunk/core/src/java/org/apache/changepw/io/ChangePasswordErrorEncoder.java&r1=125229&p2=incubator/directory/changepw/trunk/core/src/java/org/apache/changepw/io/ChangePasswordErrorEncoder.java&r2=125230
==============================================================================
--- 
incubator/directory/changepw/trunk/core/src/java/org/apache/changepw/io/ChangePasswordErrorEncoder.java
     (original)
+++ 
incubator/directory/changepw/trunk/core/src/java/org/apache/changepw/io/ChangePasswordErrorEncoder.java
     Fri Jan 14 15:07:50 2005
@@ -14,6 +14,7 @@
  *   limitations under the License.
  *
  */
+
 package org.apache.changepw.io;
 
 import java.io.IOException;
@@ -23,35 +24,27 @@
 import org.apache.kerberos.io.encoder.ErrorMessageEncoder;
 import org.apache.kerberos.messages.ErrorMessage;
 
-public class ChangePasswordErrorEncoder {
-       
-       public byte[] encode(ChangePasswordError message) throws IOException {
-               
+public class ChangePasswordErrorEncoder
+{
+       public void encode( ByteBuffer buf, ChangePasswordError message ) 
throws IOException
+       {
                // Build error message bytes
                ErrorMessage errorMessage = message.getErrorMessage();
                ErrorMessageEncoder errorEncoder = new ErrorMessageEncoder();
-               byte[] errorBytes = errorEncoder.encode(errorMessage);
-               
-               ByteBuffer buf = ByteBuffer.allocate(512);
+               byte[] errorBytes = errorEncoder.encode( errorMessage );
                
                short headerLength = 6;
                
-               short messageLength = (short)(headerLength + errorBytes.length);
-               
-               short protocolVersion     = 1;
-               short zeroIndicatesError  = 0;
-               
-               buf.putShort(messageLength);
-               buf.putShort(protocolVersion);
-               buf.putShort(zeroIndicatesError);
+               short messageLength = (short)( headerLength + errorBytes.length 
);
+               buf.putShort( messageLength );
                
-               buf.put(errorBytes);
+               short protocolVersion = 1;
+               buf.putShort( protocolVersion );
                
-               byte[] reply = new byte[buf.position()];
-               buf.rewind();
-               buf.get(reply, 0, reply.length);
+               short zeroIndicatesError = 0;
+               buf.putShort( zeroIndicatesError );
                
-               return reply;
+               buf.put( errorBytes );
        }
 }
 

Modified: 
incubator/directory/changepw/trunk/core/src/java/org/apache/changepw/io/ChangePasswordReplyEncoder.java
Url: 
http://svn.apache.org/viewcvs/incubator/directory/changepw/trunk/core/src/java/org/apache/changepw/io/ChangePasswordReplyEncoder.java?view=diff&rev=125230&p1=incubator/directory/changepw/trunk/core/src/java/org/apache/changepw/io/ChangePasswordReplyEncoder.java&r1=125229&p2=incubator/directory/changepw/trunk/core/src/java/org/apache/changepw/io/ChangePasswordReplyEncoder.java&r2=125230
==============================================================================
--- 
incubator/directory/changepw/trunk/core/src/java/org/apache/changepw/io/ChangePasswordReplyEncoder.java
     (original)
+++ 
incubator/directory/changepw/trunk/core/src/java/org/apache/changepw/io/ChangePasswordReplyEncoder.java
     Fri Jan 14 15:07:50 2005
@@ -14,6 +14,7 @@
  *   limitations under the License.
  *
  */
+
 package org.apache.changepw.io;
 
 import java.io.IOException;
@@ -25,40 +26,33 @@
 import org.apache.kerberos.messages.application.ApplicationReply;
 import org.apache.kerberos.messages.application.PrivateMessage;
 
-public class ChangePasswordReplyEncoder {
-       
-       public byte[] encode(ChangePasswordReply message) throws IOException {
-               
+
+public class ChangePasswordReplyEncoder
+{
+       public void encode( ByteBuffer buf, ChangePasswordReply message ) 
throws IOException
+       {
                // Build application reply bytes
                ApplicationReply appReply = message.getApplicationReply();
                ApplicationReplyEncoder appEncoder = new 
ApplicationReplyEncoder();
-               byte[] encodedAppReply = appEncoder.encode(appReply);
+               byte[] encodedAppReply = appEncoder.encode( appReply );
 
                // Build private message bytes
                PrivateMessage privateMessage = message.getPrivateMessage();
                PrivateMessageEncoder privateEncoder = new 
PrivateMessageEncoder();
-               byte[] privateBytes = privateEncoder.encode(privateMessage);
-               
-               ByteBuffer buf = ByteBuffer.allocate(512);
+               byte[] privateBytes = privateEncoder.encode( privateMessage );
                
                short headerLength = 6;
                
-               short messageLength = (short)(headerLength + 
encodedAppReply.length + privateBytes.length);
+               short messageLength = (short)( headerLength + 
encodedAppReply.length + privateBytes.length );
                
                short protocolVersion = 1;
                
-               buf.putShort(messageLength);
-               buf.putShort(protocolVersion);
-               buf.putShort((short)encodedAppReply.length);
-               
-               buf.put(encodedAppReply);
-               buf.put(privateBytes);
-               
-               byte[] reply = new byte[buf.position()];
-               buf.rewind();
-               buf.get(reply, 0, reply.length);
+               buf.putShort( messageLength );
+               buf.putShort( protocolVersion );
+               buf.putShort( (short)encodedAppReply.length );
                
-               return reply;
+               buf.put( encodedAppReply );
+               buf.put( privateBytes );
        }
 }
 

Added: 
incubator/directory/changepw/trunk/main/src/java/org/apache/changepw/Main.java
Url: 
http://svn.apache.org/viewcvs/incubator/directory/changepw/trunk/main/src/java/org/apache/changepw/Main.java?view=auto&rev=125230
==============================================================================
--- (empty file)
+++ 
incubator/directory/changepw/trunk/main/src/java/org/apache/changepw/Main.java  
    Fri Jan 14 15:07:50 2005
@@ -0,0 +1,183 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+
+package org.apache.changepw;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.util.Properties;
+
+import javax.naming.NamingException;
+import javax.naming.directory.InitialDirContext;
+
+import org.apache.changepw.protocol.ChangePasswordProtocolProvider;
+import org.apache.changepw.store.EmbeddedEveStore;
+import org.apache.changepw.store.PasswordStore;
+import org.apache.kerberos.kdc.KdcConfiguration;
+import org.apache.kerberos.kdc.store.BootstrapStore;
+import org.apache.ldap.server.jndi.EnvKeys;
+import org.apache.mina.io.datagram.DatagramAcceptor;
+import org.apache.mina.io.filter.IoThreadPoolFilter;
+import org.apache.mina.io.socket.SocketAcceptor;
+import org.apache.mina.protocol.filter.ProtocolThreadPoolFilter;
+import org.apache.mina.protocol.io.IoProtocolAcceptor;
+
+
+public class Main
+{
+    private final KdcConfiguration config = new KdcConfiguration();
+    private final BootstrapStore bootstrap = new BootstrapStore( config );
+    private PasswordStore store;
+    
+    public Main( Properties env )
+    {
+        store = new EmbeddedEveStore( env );
+
+        init();
+
+        try
+        {
+            setup();
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+    
+    public static void main( String[] args )
+    {
+        long startTime = System.currentTimeMillis();
+
+        if ( args.length == 0 )
+        {
+            System.err.println( "Path to configuration file required!" );
+
+            System.exit( 1 );
+        }
+
+        File file = new File( args[0] );
+
+        if ( ! file.exists() )
+        {
+            System.err.println( "Config file '" + file.getAbsolutePath() + "' 
does not exist!" );
+
+            System.exit( 2 );
+        }
+
+        Properties env = new Properties();
+
+        try
+        {
+            env.load( new FileInputStream( file ) );
+        }
+        catch ( IOException e )
+        {
+            System.err.println( "Failed while loading config file '" + 
file.getAbsolutePath() + "'" );
+
+            System.exit( 3 );
+        }
+
+        new Main( env );
+
+        System.out.println( "Apache Change Password: started in "
+                + ( System.currentTimeMillis() - startTime )
+                + " milliseconds" );
+
+        while ( true )
+        {
+            try
+            {
+                // this is a big time cludge for now to just play
+                Thread.sleep( 20000 );
+
+                try
+                {
+                    env.setProperty( EnvKeys.SYNC, "true" );
+                    new InitialDirContext( env );
+                }
+                catch ( NamingException e )
+                {
+                    e.printStackTrace();
+                }
+            }
+            catch ( InterruptedException e )
+            {
+                e.printStackTrace();
+            }
+        }
+    }
+    
+    /**
+     * Instantiates the factory then gets a handle on the Frontend.
+     *
+     * @throws Exception due to create()
+     */
+    protected void setup() throws IOException
+    {
+       int port = config.getDefaultPort();
+       
+        // Create I/O and Protocol thread pool filter.
+        // I/O thread pool performs encoding and decoding of messages.
+        // Protocol thread pool performs actual protocol flow.
+        IoThreadPoolFilter ioThreadPoolFilter = new IoThreadPoolFilter();
+        ProtocolThreadPoolFilter protocolThreadPoolFilter = new 
ProtocolThreadPoolFilter();
+
+        // and start both.
+        ioThreadPoolFilter.start();
+        protocolThreadPoolFilter.start();
+
+        // Create a TCP/IP acceptor.
+        IoProtocolAcceptor acceptor = new IoProtocolAcceptor( new 
SocketAcceptor() );
+
+        // Add both thread pool filters.
+        acceptor.getIoAcceptor().addFilter( Integer.MAX_VALUE, 
ioThreadPoolFilter );
+        acceptor.addFilter( Integer.MAX_VALUE, protocolThreadPoolFilter );
+
+        // Bind
+        acceptor.bind( new InetSocketAddress( port ), new 
ChangePasswordProtocolProvider( store, bootstrap, config ) );
+        
+        // Create a UDP/IP acceptor
+        IoProtocolAcceptor datagramAcceptor = new IoProtocolAcceptor( new 
DatagramAcceptor() );
+        
+        // Add both thread pool filters.
+        datagramAcceptor.getIoAcceptor().addFilter( Integer.MAX_VALUE, 
ioThreadPoolFilter );
+        datagramAcceptor.addFilter( Integer.MAX_VALUE, 
protocolThreadPoolFilter );
+        
+        // Bind
+        datagramAcceptor.bind( new InetSocketAddress( port ), new 
ChangePasswordProtocolProvider( store, bootstrap, config ) );
+
+        System.out.println( "Apache Changepw listening on port " + port );
+    }
+    
+    private void init()
+    {
+        Runnable runnable = new Runnable()
+        {
+            public void run()
+            {
+                bootstrap.init();
+                store.init();
+            }
+        };
+        Thread storeInit = new Thread( runnable );
+        storeInit.start();
+    }
+}
+

Added: 
incubator/directory/changepw/trunk/protocol/src/java/org/apache/changepw/protocol/ChangePasswordDecoder.java
Url: 
http://svn.apache.org/viewcvs/incubator/directory/changepw/trunk/protocol/src/java/org/apache/changepw/protocol/ChangePasswordDecoder.java?view=auto&rev=125230
==============================================================================
--- (empty file)
+++ 
incubator/directory/changepw/trunk/protocol/src/java/org/apache/changepw/protocol/ChangePasswordDecoder.java
        Fri Jan 14 15:07:50 2005
@@ -0,0 +1,46 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+
+package org.apache.changepw.protocol;
+
+import java.io.IOException;
+
+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;
+
+
+public class ChangePasswordDecoder implements ProtocolDecoder
+{
+    public void decode( ProtocolSession session, ByteBuffer in, 
ProtocolDecoderOutput out )
+            throws ProtocolViolationException
+    {
+        ChangePasswordRequestDecoder decoder = new 
ChangePasswordRequestDecoder();
+        try
+               {
+               out.write( decoder.decode( in.buf() ) );
+        }
+        catch ( IOException ioe)
+               {
+               ioe.printStackTrace();
+        }
+    }
+}
+

Added: 
incubator/directory/changepw/trunk/protocol/src/java/org/apache/changepw/protocol/ChangePasswordEncoder.java
Url: 
http://svn.apache.org/viewcvs/incubator/directory/changepw/trunk/protocol/src/java/org/apache/changepw/protocol/ChangePasswordEncoder.java?view=auto&rev=125230
==============================================================================
--- (empty file)
+++ 
incubator/directory/changepw/trunk/protocol/src/java/org/apache/changepw/protocol/ChangePasswordEncoder.java
        Fri Jan 14 15:07:50 2005
@@ -0,0 +1,78 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+
+package org.apache.changepw.protocol;
+
+import java.io.IOException;
+
+import org.apache.changepw.io.ChangePasswordErrorEncoder;
+import org.apache.changepw.io.ChangePasswordReplyEncoder;
+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;
+
+
+public class ChangePasswordEncoder implements ProtocolEncoder
+{
+    public void encode( ProtocolSession session, Object message, 
ProtocolEncoderOutput out )
+            throws ProtocolViolationException
+    {
+       ByteBuffer buf = ByteBuffer.allocate( 512 );
+       
+       try
+               {
+               if ( message instanceof ChangePasswordReply )
+               {
+                       encodeReply( (ChangePasswordReply)message, buf );
+               }
+               else
+               {
+                       if ( message instanceof ChangePasswordError )
+                       {
+                               encodeError( (ChangePasswordError)message, buf 
);
+                       }
+               }
+               
+               buf.flip();
+               
+               out.write( buf );
+               }
+       catch ( IOException ioe )
+               {
+               throw new ProtocolViolationException();
+               }
+    }
+    
+    private void encodeReply( ChangePasswordReply reply, ByteBuffer buf ) 
throws IOException
+    {
+       ChangePasswordReplyEncoder encoder = new ChangePasswordReplyEncoder();
+       
+        encoder.encode( buf.buf(), reply );
+    }
+    
+    private void encodeError( ChangePasswordError error, ByteBuffer buf ) 
throws IOException
+    {
+       ChangePasswordErrorEncoder encoder = new ChangePasswordErrorEncoder();
+       
+        encoder.encode( buf.buf(), error );
+    }
+}
+

Added: 
incubator/directory/changepw/trunk/protocol/src/java/org/apache/changepw/protocol/ChangePasswordProtocolHandler.java
Url: 
http://svn.apache.org/viewcvs/incubator/directory/changepw/trunk/protocol/src/java/org/apache/changepw/protocol/ChangePasswordProtocolHandler.java?view=auto&rev=125230
==============================================================================
--- (empty file)
+++ 
incubator/directory/changepw/trunk/protocol/src/java/org/apache/changepw/protocol/ChangePasswordProtocolHandler.java
        Fri Jan 14 15:07:50 2005
@@ -0,0 +1,91 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+
+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.changepw.store.PasswordStore;
+import org.apache.kerberos.kdc.KdcConfiguration;
+import org.apache.kerberos.kdc.store.PrincipalStore;
+import org.apache.mina.common.IdleStatus;
+import org.apache.mina.protocol.ProtocolHandler;
+import org.apache.mina.protocol.ProtocolSession;
+
+
+public class ChangePasswordProtocolHandler implements ProtocolHandler
+{
+       private PasswordStore    store;
+       private PrincipalStore   bootstrap;
+       private KdcConfiguration config;
+       
+       public ChangePasswordProtocolHandler( PasswordStore store, 
PrincipalStore bootstrap, KdcConfiguration config )
+    {
+               this.store     = store;
+               this.bootstrap = bootstrap;
+               this.config    = config;
+       }
+
+    public void sessionOpened( ProtocolSession session )
+    {
+        System.out.println( session.getRemoteAddress() + " OPENED" );
+    }
+
+    public void sessionClosed( ProtocolSession session )
+    {
+        System.out.println( session.getRemoteAddress() + " CLOSED" );
+    }
+
+    public void sessionIdle( ProtocolSession session, IdleStatus status )
+    {
+        System.out.println( session.getRemoteAddress() + " IDLE(" + status + 
")" );
+    }
+
+    public void exceptionCaught( ProtocolSession session, Throwable cause )
+    {
+        System.out.println( session.getRemoteAddress() + " EXCEPTION" );
+        cause.printStackTrace( System.out );
+
+        session.close();
+    }
+
+    public void messageReceived( ProtocolSession session, Object message )
+    {
+        System.out.println( session.getRemoteAddress() + " RCVD: " + message );
+        
+        ChangePasswordService changepwService = new ChangePasswordServiceImpl( 
store, bootstrap, config );
+        
+        try
+               {
+            ChangePasswordReply reply = changepwService.getReplyFor( 
(ChangePasswordRequest)message );
+            
+            session.write( reply );
+               }
+        catch ( Exception e)
+               {
+               e.printStackTrace();
+               }
+    }
+
+    public void messageSent( ProtocolSession session, Object message )
+    {
+        System.out.println( session.getRemoteAddress() + " SENT: " + message );
+    }
+}
+

Added: 
incubator/directory/changepw/trunk/protocol/src/java/org/apache/changepw/protocol/ChangePasswordProtocolProvider.java
Url: 
http://svn.apache.org/viewcvs/incubator/directory/changepw/trunk/protocol/src/java/org/apache/changepw/protocol/ChangePasswordProtocolProvider.java?view=auto&rev=125230
==============================================================================
--- (empty file)
+++ 
incubator/directory/changepw/trunk/protocol/src/java/org/apache/changepw/protocol/ChangePasswordProtocolProvider.java
       Fri Jan 14 15:07:50 2005
@@ -0,0 +1,72 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+
+package org.apache.changepw.protocol;
+
+import org.apache.changepw.store.PasswordStore;
+import org.apache.kerberos.kdc.KdcConfiguration;
+import org.apache.kerberos.kdc.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;
+
+
+public class ChangePasswordProtocolProvider implements ProtocolProvider
+{
+       private PasswordStore    store;
+       private PrincipalStore   bootstrap;
+       private KdcConfiguration config;
+       
+       public ChangePasswordProtocolProvider( PasswordStore store, 
PrincipalStore bootstrap, KdcConfiguration config )
+    {
+               this.store     = store;
+               this.bootstrap = bootstrap;
+               this.config    = config;
+       }
+       
+    // Protocol handler is usually a singleton.
+    private ProtocolHandler HANDLER = new ChangePasswordProtocolHandler( 
store, bootstrap, config );
+
+    // Codec factory is also usually a singleton.
+    private static ProtocolCodecFactory CODEC_FACTORY = new 
ProtocolCodecFactory()
+    {
+        public ProtocolEncoder newEncoder()
+        {
+            // Create a new encoder.
+            return new ChangePasswordEncoder();
+        }
+
+        public ProtocolDecoder newDecoder()
+        {
+            // Create a new decoder.
+            return new ChangePasswordDecoder();
+        }
+    };
+
+    public ProtocolCodecFactory getCodecFactory()
+    {
+        return CODEC_FACTORY;
+    }
+
+    public ProtocolHandler getHandler()
+    {
+        return HANDLER;
+    }
+}
+

Reply via email to