directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1041075 - in /directory/apacheds/branches/apacheds-kerberos-codec-2.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos: kdc/KdcServer.java protocol/KerberosUdpDecoder.java protocol/KerberosUdpEncoder.java
Date Wed, 01 Dec 2010 16:33:43 GMT
Author: kayyagari
Date: Wed Dec  1 16:33:43 2010
New Revision: 1041075

URL: http://svn.apache.org/viewvc?rev=1041075&view=rev
Log:
o extracted the container key as a constant
o removed line printing stack trace

Modified:
    directory/apacheds/branches/apacheds-kerberos-codec-2.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KdcServer.java
    directory/apacheds/branches/apacheds-kerberos-codec-2.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosUdpDecoder.java
    directory/apacheds/branches/apacheds-kerberos-codec-2.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosUdpEncoder.java

Modified: directory/apacheds/branches/apacheds-kerberos-codec-2.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KdcServer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos-codec-2.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KdcServer.java?rev=1041075&r1=1041074&r2=1041075&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos-codec-2.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KdcServer.java
(original)
+++ directory/apacheds/branches/apacheds-kerberos-codec-2.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KdcServer.java
Wed Dec  1 16:33:43 2010
@@ -499,6 +499,11 @@ public class KdcServer extends Directory
                                 KerberosUdpProtocolCodecFactory.getInstance() ) );
                 }
 
+//                // Inject the codec
+//                ((DefaultIoFilterChainBuilder)chainBuilder).addFirst( "codec", 
+//                    new ProtocolCodecFilter( 
+//                            KerberosTcpProtocolCodecFactory.getInstance() ) );
+
                 acceptor.setFilterChainBuilder( chainBuilder );
                 
                 // Inject the protocol handler

Modified: directory/apacheds/branches/apacheds-kerberos-codec-2.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosUdpDecoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos-codec-2.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosUdpDecoder.java?rev=1041075&r1=1041074&r2=1041075&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos-codec-2.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosUdpDecoder.java
(original)
+++ directory/apacheds/branches/apacheds-kerberos-codec-2.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosUdpDecoder.java
Wed Dec  1 16:33:43 2010
@@ -23,7 +23,6 @@ package org.apache.directory.server.kerb
 import java.io.IOException;
 import java.nio.ByteBuffer;
 
-import org.apache.directory.server.kerberos.shared.io.decoder.KdcRequestDecoder;
 import org.apache.directory.shared.asn1.ber.Asn1Decoder;
 import org.apache.directory.shared.asn1.ber.tlv.TLVStateEnum;
 import org.apache.directory.shared.asn1.codec.DecoderException;
@@ -42,26 +41,28 @@ import org.slf4j.LoggerFactory;
  */
 public class KerberosUdpDecoder extends ProtocolDecoderAdapter
 {
+
     /** The logger */
     private static Logger LOG = LoggerFactory.getLogger( LdapDecoder.class );
 
     /** A speedup for logger */
     private static final boolean IS_DEBUG = LOG.isDebugEnabled();
 
-    private KdcRequestDecoder decoder = new KdcRequestDecoder();
-
     /** The ASN 1 decoder instance */
     private Asn1Decoder asn1Decoder = new Asn1Decoder();
 
+    /** the key used while storing message container in the session */
+    private static final String KERBEROS_MESSAGE_CONTAINER = "kerberosMessageContainer";
+    
     public void decode( IoSession session, IoBuffer in, ProtocolDecoderOutput out ) throws
IOException
     {
         ByteBuffer buf = in.buf();
-        KerberosMessageContainer kerberosMessageContainer = ( KerberosMessageContainer )
session.getAttribute( "kerberosMessageContainer" );
+        KerberosMessageContainer kerberosMessageContainer = ( KerberosMessageContainer )
session.getAttribute( KERBEROS_MESSAGE_CONTAINER );
 
         if ( kerberosMessageContainer == null )
         {
             kerberosMessageContainer = new KerberosMessageContainer();
-            session.setAttribute( "kerberosMessageContainer", kerberosMessageContainer );
+            session.setAttribute( KERBEROS_MESSAGE_CONTAINER, kerberosMessageContainer );
             kerberosMessageContainer.setStream( buf );
         }
         
@@ -91,7 +92,7 @@ public class KerberosUdpDecoder extends 
             }
             catch ( Exception e )
             {
-                e.printStackTrace();
+                LOG.warn( "error while decoding", e );
             }
         }
     }

Modified: directory/apacheds/branches/apacheds-kerberos-codec-2.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosUdpEncoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos-codec-2.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosUdpEncoder.java?rev=1041075&r1=1041074&r2=1041075&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos-codec-2.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosUdpEncoder.java
(original)
+++ directory/apacheds/branches/apacheds-kerberos-codec-2.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosUdpEncoder.java
Wed Dec  1 16:33:43 2010
@@ -26,6 +26,8 @@ import org.apache.directory.server.kerbe
 import org.apache.directory.server.kerberos.shared.io.encoder.KdcReplyEncoder;
 import org.apache.directory.server.kerberos.shared.messages.ErrorMessage;
 import org.apache.directory.server.kerberos.shared.messages.KdcReply;
+import org.apache.directory.shared.asn1.AbstractAsn1Object;
+import org.apache.directory.shared.asn1.codec.EncoderException;
 import org.apache.mina.core.buffer.IoBuffer;
 import org.apache.mina.core.session.IoSession;
 import org.apache.mina.filter.codec.ProtocolEncoderAdapter;
@@ -43,22 +45,34 @@ public class KerberosUdpEncoder extends 
 
     public void encode( IoSession session, Object message, ProtocolEncoderOutput out ) throws
IOException
     {
-        IoBuffer buf = IoBuffer.allocate( 1024 );
+        AbstractAsn1Object asn1Obj = ( AbstractAsn1Object ) message;
+        
+        IoBuffer buf = IoBuffer.allocate( asn1Obj.computeLength() );
 
-        if ( message instanceof KdcReply )
+        try
         {
-            replyEncoder.encode( ( KdcReply ) message, buf.buf() );
+            asn1Obj.encode( buf.buf() );
+
+            buf.flip();
+
+            out.write( buf );
         }
-        else
+        catch( EncoderException e )
         {
-            if ( message instanceof ErrorMessage )
-            {
-                errorEncoder.encode( ( ErrorMessage ) message, buf.buf() );
-            }
+            e.printStackTrace();
         }
+        
+//        if ( message instanceof KdcReply )
+//        {
+//            replyEncoder.encode( ( KdcReply ) message, buf.buf() );
+//        }
+//        else
+//        {
+//            if ( message instanceof ErrorMessage )
+//            {
+//                errorEncoder.encode( ( ErrorMessage ) message, buf.buf() );
+//            }
+//        }
 
-        buf.flip();
-
-        out.write( buf );
     }
 }



Mime
View raw message