directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1036823 - in /directory/apacheds/trunk/kerberos-codec/src: main/java/org/apache/directory/shared/kerberos/codec/krbError/ main/java/org/apache/directory/shared/kerberos/messages/ test/java/org/apache/directory/shared/kerberos/codec/
Date Fri, 19 Nov 2010 12:45:27 GMT
Author: elecharny
Date: Fri Nov 19 12:45:27 2010
New Revision: 1036823

URL: http://svn.apache.org/viewvc?rev=1036823&view=rev
Log:
Fixed the KRB-ERROR codec

Modified:
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/krbError/KrbErrorGrammar.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/KrbError.java
    directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/KrbErrorDecoderTest.java

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/krbError/KrbErrorGrammar.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/krbError/KrbErrorGrammar.java?rev=1036823&r1=1036822&r2=1036823&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/krbError/KrbErrorGrammar.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/krbError/KrbErrorGrammar.java
Fri Nov 19 12:45:27 2010
@@ -31,6 +31,7 @@ import org.apache.directory.shared.kerbe
 import org.apache.directory.shared.kerberos.codec.krbError.actions.StoreCName;
 import org.apache.directory.shared.kerberos.codec.krbError.actions.StoreCRealm;
 import org.apache.directory.shared.kerberos.codec.krbError.actions.StoreCTime;
+import org.apache.directory.shared.kerberos.codec.krbError.actions.StoreCusec;
 import org.apache.directory.shared.kerberos.codec.krbError.actions.StoreEData;
 import org.apache.directory.shared.kerberos.codec.krbError.actions.StoreEText;
 import org.apache.directory.shared.kerberos.codec.krbError.actions.StoreErrorCode;
@@ -155,7 +156,7 @@ public final class KrbErrorGrammar exten
         // cusec           [3] Microseconds OPTIONAL
         super.transitions[KrbErrorStatesEnum.KRB_ERR_CUSEC_TAG_STATE.ordinal()][UniversalTag.INTEGER.getValue()]
= new GrammarTransition(
             KrbErrorStatesEnum.KRB_ERR_CUSEC_TAG_STATE, KrbErrorStatesEnum.KRB_ERR_CUSEC_STATE,
UniversalTag.INTEGER.getValue(), 
-            new StoreSusec() );
+            new StoreCusec() );
     
         // --------------------------------------------------------------------------------------------
         // Transition from cusec value to stime tag

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/KrbError.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/KrbError.java?rev=1036823&r1=1036822&r2=1036823&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/KrbError.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/KrbError.java
Fri Nov 19 12:45:27 2010
@@ -72,7 +72,7 @@ public class KrbError extends KerberosMe
     private KerberosTime cTime;
 
     /** microseconds of the client's current time */
-    private int cusec;
+    private Integer cusec;
 
     /** current time on the server */
     private KerberosTime sTime;
@@ -402,7 +402,7 @@ public class KrbError extends KerberosMe
             cTimeLength = 1 + 1 + 0x0F;
         }
 
-        if ( cusec >= 0 )
+        if ( cusec != null )
         {
             int cusecLen = Value.getNbBytes( cusec );
             cusecLength = 1 + TLV.getNbBytes( cusecLen ) + cusecLen;
@@ -458,7 +458,7 @@ public class KrbError extends KerberosMe
             krbErrorSeqLength += 1 + TLV.getNbBytes( cTimeLength ) + cTimeLength;
         }
 
-        if ( cusec >= 0 )
+        if ( cusec != null )
         {
             krbErrorSeqLength += 1 + TLV.getNbBytes( cusecLength ) + cusecLength;
         }
@@ -566,7 +566,7 @@ public class KrbError extends KerberosMe
             }
 
             // cusec tag and value if any
-            if ( cusec > 0 )
+            if ( cusec != null )
             {
                 buffer.put( ( byte ) KerberosConstants.KRB_ERR_CUSEC_TAG );
                 buffer.put( TLV.getBytes( cusecLength ) );

Modified: directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/KrbErrorDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/KrbErrorDecoderTest.java?rev=1036823&r1=1036822&r2=1036823&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/KrbErrorDecoderTest.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/KrbErrorDecoderTest.java
Fri Nov 19 12:45:27 2010
@@ -45,52 +45,52 @@ public class KrbErrorDecoderTest
     {
         Asn1Decoder decoder = new Asn1Decoder();
         
-        int streamLen = 0xCE;
+        int streamLen = 0x8F;
         ByteBuffer stream = ByteBuffer.allocate( streamLen );
         stream.put( new byte[]
         {
-                0x7E, (byte)0x81, (byte)0xCB,
-                  0x30, (byte)0x81, (byte)0xC8,
+                0x7E, (byte)0x81, (byte)0x8C,
+                  0x30, (byte)0x81, (byte)0x89,
                     (byte)0xA0, 0x03,           // pvno
-                           0x02, 0x01, 0x05,    
+                      0x02, 0x01, 0x05,    
                     (byte)0xA1, 0x03,           // msg-type
-                           0x02, 0x01, 0x1E,   
+                      0x02, 0x01, 0x1E,   
                     (byte)0xA2, 0x11,           // ctime
-                           0x18, 0xF, '2', '0', '1', '0', '1', '1', '1', '9', '0', '8', '0',
'0', '4', '3', 'Z',
+                      0x18, 0xF, '2', '0', '1', '0', '1', '1', '1', '9', '0', '8', '0', '0',
'4', '3', 'Z',
                     (byte)0xA3, 0x03,           // cusec
-                           0x02, 0x01, 0x01,
+                      0x02, 0x01, 0x01,
                     (byte)0xA4, 0x11,           // stime
-                           0x18, 0xF, '2', '0', '1', '0', '1', '1', '1', '9', '0', '8', '0',
'0', '4', '3', 'Z',
+                      0x18, 0xF, '2', '0', '1', '0', '1', '1', '1', '9', '0', '8', '0', '0',
'4', '3', 'Z',
                     (byte)0xA5, 0x03,           // susec
-                           0x02, 0x01, 0x02,
+                      0x02, 0x01, 0x02,
                     (byte)0xA6, 0x03,           // error-code
-                           0x02, 0x01, 0x00,
-                    (byte)0xA7, 0x8,            // crealm
-                           0x1B, 0x06, 'c', 'r', 'e', 'a', 'l', 'm',
+                      0x02, 0x01, 0x00,
+                    (byte)0xA7, 0x08,            // crealm
+                      0x1B, 0x06, 'c', 'r', 'e', 'a', 'l', 'm',
                     (byte)0xA8, 0x12,           // cname
-                           0x30, 0x10, 
-                           // FIXME here it fails with ERR_00001_BAD_TRANSITION_FROM_STATE
Bad transition from state START_STATE, tag 0xA0
-                           (byte)0xA0, 0x03,
-                             0x02, 0x01, 0x00, 
-                             (byte)0xA1, 0x09, 
-                             0x30, 0x07, 
-                              0x1B, 0x05, 'c', 'n', 'a', 'm', 'e',
+                      0x30, 0x10, 
+                        (byte)0xA0, 0x03,
+                          0x02, 0x01, 0x00, 
+                        (byte)0xA1, 0x09, 
+                          0x30, 0x07, 
+                            0x1B, 0x05, 'c', 'n', 'a', 'm', 'e',
                     (byte)0xA9, 0x07,           // realm
-                           0x1B, 0x05, 'r', 'e', 'a', 'l', 'm',
+                      0x1B, 0x05, 'r', 'e', 'a', 'l', 'm',
                     (byte)0xAA, 0x12,           // sname
-                           0x30, 0x10, 
-                           (byte)0xA0, 0x03,
-                             0x02, 0x01, 0x00, 
-                             (byte)0xA1, 0x09, 
-                             0x30, 0x07, 
-                              0x1B, 0x05, 's', 'n', 'a', 'm', 'e',
+                      0x30, 0x10, 
+                        (byte)0xA0, 0x03,
+                          0x02, 0x01, 0x00, 
+                        (byte)0xA1, 0x09, 
+                          0x30, 0x07, 
+                            0x1B, 0x05, 's', 'n', 'a', 'm', 'e',
                     (byte)0xAB, 0x07,           // e-text
-                           0x1B, 0x5, 'e', 't', 'e', 'x', 't',
+                      0x1B, 0x5, 'e', 't', 'e', 'x', 't',
                     (byte)0xAC, 0x04,           // e-data
-                           0x04, 0x02, 0x00, 0x01
+                      0x04, 0x02, 
+                        0x00, 0x01
         } );
         
-        String decoded = StringTools.utf8ToString( stream.array() );
+        String decoded = StringTools.dumpBytes( stream.array() );
         stream.flip();
         
         KrbErrorContainer container = new KrbErrorContainer();
@@ -116,7 +116,8 @@ public class KrbErrorDecoderTest
         try
         {
             buffer = krbError.encode( buffer );
-            assertEquals( decoded, StringTools.utf8ToString( buffer.array() ) );
+            
+            assertEquals( decoded, StringTools.dumpBytes( buffer.array() ) );
         }
         catch( EncoderException e )
         {



Mime
View raw message