directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r548177 - /directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/
Date Mon, 18 Jun 2007 02:52:02 GMT
Author: erodriguez
Date: Sun Jun 17 19:52:00 2007
New Revision: 548177

URL: http://svn.apache.org/viewvc?view=rev&rev=548177
Log:
Added first cut of TCP support for Set/Change Password client.

Added:
    directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientTcpCodecFactory.java
  (with props)
    directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientTcpDecoder.java
  (with props)
    directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientTcpEncoder.java
  (with props)
    directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientUdpCodecFactory.java
  (contents, props changed)
      - copied, changed from r546752, directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientCodecFactory.java
    directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientUdpDecoder.java
  (contents, props changed)
      - copied, changed from r546752, directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientDecoder.java
    directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientUdpEncoder.java
  (contents, props changed)
      - copied, changed from r546752, directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientEncoder.java
Removed:
    directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientCodecFactory.java
    directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientDecoder.java
    directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientEncoder.java
Modified:
    directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientHandler.java

Modified: directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientHandler.java
URL: http://svn.apache.org/viewvc/directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientHandler.java?view=diff&rev=548177&r1=548176&r2=548177
==============================================================================
--- directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientHandler.java
(original)
+++ directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientHandler.java
Sun Jun 17 19:52:00 2007
@@ -30,7 +30,7 @@
 
 
 /**
- * An {@link IoHandler} implementation for a Kerberos client.
+ * An {@link IoHandler} implementation for a Set/Change Password client.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$

Added: directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientTcpCodecFactory.java
URL: http://svn.apache.org/viewvc/directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientTcpCodecFactory.java?view=auto&rev=548177
==============================================================================
--- directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientTcpCodecFactory.java
(added)
+++ directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientTcpCodecFactory.java
Sun Jun 17 19:52:00 2007
@@ -0,0 +1,66 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.directory.client.password.protocol;
+
+
+import org.apache.mina.filter.codec.ProtocolCodecFactory;
+import org.apache.mina.filter.codec.ProtocolDecoder;
+import org.apache.mina.filter.codec.ProtocolEncoder;
+
+
+/**
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class PasswordClientTcpCodecFactory implements ProtocolCodecFactory
+{
+    private static final PasswordClientTcpCodecFactory INSTANCE = new PasswordClientTcpCodecFactory();
+
+
+    /**
+     * Returns the singleton {@link PasswordClientTcpCodecFactory}.
+     *
+     * @return The singleton {@link PasswordClientTcpCodecFactory}.
+     */
+    public static PasswordClientTcpCodecFactory getInstance()
+    {
+        return INSTANCE;
+    }
+
+
+    private PasswordClientTcpCodecFactory()
+    {
+        // Private constructor prevents instantiation outside this class.
+    }
+
+
+    public ProtocolEncoder getEncoder()
+    {
+        // Create a new encoder.
+        return new PasswordClientTcpEncoder();
+    }
+
+
+    public ProtocolDecoder getDecoder()
+    {
+        // Create a new decoder.
+        return new PasswordClientTcpDecoder();
+    }
+}

Propchange: directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientTcpCodecFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientTcpDecoder.java
URL: http://svn.apache.org/viewvc/directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientTcpDecoder.java?view=auto&rev=548177
==============================================================================
--- directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientTcpDecoder.java
(added)
+++ directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientTcpDecoder.java
Sun Jun 17 19:52:00 2007
@@ -0,0 +1,110 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.directory.client.password.protocol;
+
+
+import java.util.Arrays;
+
+import org.apache.directory.server.changepw.io.ChangePasswordReplyDecoder;
+import org.apache.directory.server.kerberos.shared.io.decoder.ErrorMessageDecoder;
+import org.apache.mina.common.BufferDataException;
+import org.apache.mina.common.ByteBuffer;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.filter.codec.CumulativeProtocolDecoder;
+import org.apache.mina.filter.codec.ProtocolDecoderOutput;
+
+
+/**
+ * A {@link CumulativeProtocolDecoder} which supports Set/Change Password client
+ * operation over TCP, by reassembling split packets prior to ASN.1 DER decoding.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class PasswordClientTcpDecoder extends CumulativeProtocolDecoder
+{
+    private static final byte[] ERROR = new byte[]
+        { ( byte ) 0x7E, ( byte ) 0x78, ( byte ) 0x30, ( byte ) 0x76 };
+
+    private ChangePasswordReplyDecoder replyDecoder = new ChangePasswordReplyDecoder();
+    private ErrorMessageDecoder errorDecoder = new ErrorMessageDecoder();
+
+    private int maxObjectSize = 16384; // 16KB
+
+
+    /**
+     * Returns the allowed maximum size of the object to be decoded.
+     * If the size of the object to be decoded exceeds this value, this
+     * decoder will throw a {@link BufferDataException}.  The default
+     * value is <tt>16384</tt> (16KB).
+     * 
+     * @return The max object size.
+     */
+    public int getMaxObjectSize()
+    {
+        return maxObjectSize;
+    }
+
+
+    /**
+     * Sets the allowed maximum size of the object to be decoded.
+     * If the size of the object to be decoded exceeds this value, this
+     * decoder will throw a {@link BufferDataException}.  The default
+     * value is <tt>16384</tt> (16KB).
+     * 
+     * @param maxObjectSize 
+     */
+    public void setMaxObjectSize( int maxObjectSize )
+    {
+        if ( maxObjectSize <= 0 )
+        {
+            throw new IllegalArgumentException( "maxObjectSize: " + maxObjectSize );
+        }
+
+        this.maxObjectSize = maxObjectSize;
+    }
+
+
+    @Override
+    protected boolean doDecode( IoSession session, ByteBuffer in, ProtocolDecoderOutput out
) throws Exception
+    {
+        if ( !in.prefixedDataAvailable( 4, maxObjectSize ) )
+        {
+            return false;
+        }
+
+        in.getInt();
+
+        byte[] header = new byte[4];
+        in.get( header );
+        in.rewind();
+
+        if ( Arrays.equals( ERROR, header ) )
+        {
+            out.write( errorDecoder.decode( in.buf() ) );
+        }
+        else
+        {
+            out.write( replyDecoder.decode( in.buf() ) );
+        }
+
+        return true;
+    }
+}

Propchange: directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientTcpDecoder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientTcpEncoder.java
URL: http://svn.apache.org/viewvc/directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientTcpEncoder.java?view=auto&rev=548177
==============================================================================
--- directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientTcpEncoder.java
(added)
+++ directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientTcpEncoder.java
Sun Jun 17 19:52:00 2007
@@ -0,0 +1,67 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.directory.client.password.protocol;
+
+
+import java.io.IOException;
+
+import org.apache.directory.server.changepw.io.ChangePasswordRequestEncoder;
+import org.apache.directory.server.changepw.messages.ChangePasswordRequest;
+import org.apache.mina.common.ByteBuffer;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.filter.codec.ProtocolEncoderAdapter;
+import org.apache.mina.filter.codec.ProtocolEncoderOutput;
+
+
+/**
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class PasswordClientTcpEncoder extends ProtocolEncoderAdapter
+{
+    private ChangePasswordRequestEncoder requestEncoder = new ChangePasswordRequestEncoder();
+
+
+    public void encode( IoSession session, Object message, ProtocolEncoderOutput out ) throws
IOException
+    {
+        ByteBuffer buf = ByteBuffer.allocate( 1024 );
+
+        // make space for int length
+        buf.putInt( 0 );
+
+        requestEncoder.encode( buf.buf(), ( ChangePasswordRequest ) message );
+
+        // mark position
+        int end = buf.position();
+
+        // length is the data minus 4 bytes for the pre-pended length
+        int recordLength = end - 4;
+
+        // write the length
+        buf.rewind();
+        buf.putInt( recordLength );
+
+        // set the position back before flipping the buffer
+        buf.position( end );
+        buf.flip();
+
+        out.write( buf );
+    }
+}

Propchange: directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientTcpEncoder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientUdpCodecFactory.java
(from r546752, directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientCodecFactory.java)
URL: http://svn.apache.org/viewvc/directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientUdpCodecFactory.java?view=diff&rev=548177&p1=directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientCodecFactory.java&r1=546752&p2=directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientUdpCodecFactory.java&r2=548177
==============================================================================
--- directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientCodecFactory.java
(original)
+++ directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientUdpCodecFactory.java
Sun Jun 17 19:52:00 2007
@@ -29,23 +29,23 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class PasswordClientCodecFactory implements ProtocolCodecFactory
+public class PasswordClientUdpCodecFactory implements ProtocolCodecFactory
 {
-    private static final PasswordClientCodecFactory INSTANCE = new PasswordClientCodecFactory();
+    private static final PasswordClientUdpCodecFactory INSTANCE = new PasswordClientUdpCodecFactory();
 
 
     /**
-     * Returns the singleton {@link PasswordClientCodecFactory}.
+     * Returns the singleton {@link PasswordClientUdpCodecFactory}.
      *
-     * @return The singleton {@link PasswordClientCodecFactory}.
+     * @return The singleton {@link PasswordClientUdpCodecFactory}.
      */
-    public static PasswordClientCodecFactory getInstance()
+    public static PasswordClientUdpCodecFactory getInstance()
     {
         return INSTANCE;
     }
 
 
-    private PasswordClientCodecFactory()
+    private PasswordClientUdpCodecFactory()
     {
         // Private constructor prevents instantiation outside this class.
     }
@@ -54,13 +54,13 @@
     public ProtocolEncoder getEncoder()
     {
         // Create a new encoder.
-        return new PasswordClientEncoder();
+        return new PasswordClientUdpEncoder();
     }
 
 
     public ProtocolDecoder getDecoder()
     {
         // Create a new decoder.
-        return new PasswordClientDecoder();
+        return new PasswordClientUdpDecoder();
     }
 }

Propchange: directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientUdpCodecFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientUdpDecoder.java
(from r546752, directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientDecoder.java)
URL: http://svn.apache.org/viewvc/directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientUdpDecoder.java?view=diff&rev=548177&p1=directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientDecoder.java&r1=546752&p2=directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientUdpDecoder.java&r2=548177
==============================================================================
--- directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientDecoder.java
(original)
+++ directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientUdpDecoder.java
Sun Jun 17 19:52:00 2007
@@ -35,7 +35,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class PasswordClientDecoder extends ProtocolDecoderAdapter
+public class PasswordClientUdpDecoder extends ProtocolDecoderAdapter
 {
     private static final byte[] ERROR = new byte[]
         { ( byte ) 0x7E, ( byte ) 0x78, ( byte ) 0x30, ( byte ) 0x76 };

Propchange: directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientUdpDecoder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientUdpEncoder.java
(from r546752, directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientEncoder.java)
URL: http://svn.apache.org/viewvc/directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientUdpEncoder.java?view=diff&rev=548177&p1=directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientEncoder.java&r1=546752&p2=directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientUdpEncoder.java&r2=548177
==============================================================================
--- directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientEncoder.java
(original)
+++ directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientUdpEncoder.java
Sun Jun 17 19:52:00 2007
@@ -34,7 +34,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class PasswordClientEncoder extends ProtocolEncoderAdapter
+public class PasswordClientUdpEncoder extends ProtocolEncoderAdapter
 {
     private ChangePasswordRequestEncoder requestEncoder = new ChangePasswordRequestEncoder();
 

Propchange: directory/clients/trunk/kerberos/password/src/main/java/org/apache/directory/client/password/protocol/PasswordClientUdpEncoder.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message