directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1040123 - in /directory/apacheds/trunk/kerberos-codec/src: main/java/org/apache/directory/shared/kerberos/codec/authorizationData/ main/java/org/apache/directory/shared/kerberos/codec/authorizationData/actions/ test/java/org/apache/directo...
Date Mon, 29 Nov 2010 14:30:18 GMT
Author: elecharny
Date: Mon Nov 29 14:30:18 2010
New Revision: 1040123

URL: http://svn.apache.org/viewvc?rev=1040123&view=rev
Log:
Review the AuthorizationData class and tests

Modified:
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/authorizationData/AuthorizationDataGrammar.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/authorizationData/actions/AuthorizationDataInit.java
    directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/AuthorizationDataDecoderTest.java

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/authorizationData/AuthorizationDataGrammar.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/authorizationData/AuthorizationDataGrammar.java?rev=1040123&r1=1040122&r2=1040123&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/authorizationData/AuthorizationDataGrammar.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/authorizationData/AuthorizationDataGrammar.java
Mon Nov 29 14:30:18 2010
@@ -131,9 +131,6 @@ public final class AuthorizationDataGram
     }
 
 
-    // ~ Methods
-    // ------------------------------------------------------------------------------------
-
     /**
      * Get the instance of this grammar
      * 

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/authorizationData/actions/AuthorizationDataInit.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/authorizationData/actions/AuthorizationDataInit.java?rev=1040123&r1=1040122&r2=1040123&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/authorizationData/actions/AuthorizationDataInit.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/authorizationData/actions/AuthorizationDataInit.java
Mon Nov 29 14:30:18 2010
@@ -20,11 +20,11 @@
 package org.apache.directory.shared.kerberos.codec.authorizationData.actions;
 
 
+import org.apache.directory.server.i18n.I18n;
 import org.apache.directory.shared.asn1.ber.Asn1Container;
 import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
 import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.asn1.codec.DecoderException;
-import org.apache.directory.shared.i18n.I18n;
 import org.apache.directory.shared.kerberos.codec.authorizationData.AuthorizationDataContainer;
 import org.apache.directory.shared.kerberos.components.AuthorizationData;
 import org.slf4j.Logger;
@@ -66,10 +66,10 @@ public class AuthorizationDataInit exten
         // The Length should not be null
         if ( tlv.getLength() == 0 )
         {
-            LOG.error( I18n.err( I18n.ERR_04066 ) );
+            LOG.error( I18n.err( I18n.ERR_744_NULL_PDU_LENGTH ) );
 
             // This will generate a PROTOCOL_ERROR
-            throw new DecoderException( I18n.err( I18n.ERR_04067 ) );
+            throw new DecoderException( I18n.err( I18n.ERR_744_NULL_PDU_LENGTH ) );
         }
         
         if ( authDataContainer.getAuthorizationData() == null )

Modified: directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/AuthorizationDataDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/AuthorizationDataDecoderTest.java?rev=1040123&r1=1040122&r2=1040123&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/AuthorizationDataDecoderTest.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/AuthorizationDataDecoderTest.java
Mon Nov 29 14:30:18 2010
@@ -119,18 +119,15 @@ public class AuthorizationDataDecoderTes
     
     
     @Test( expected = DecoderException.class)
-    public void testAuthorizationDataWithoutType() throws DecoderException
+    public void testAuthorizationDataEmptyPdu() throws DecoderException
     {
         Asn1Decoder kerberosDecoder = new Asn1Decoder();
 
-        ByteBuffer stream = ByteBuffer.allocate( 0x09 );
+        ByteBuffer stream = ByteBuffer.allocate( 0x02 );
         
         stream.put( new byte[]
             { 
-              0x30, 0x7,
-               0x30, 0x5,
-                (byte)0xA1, 0x03,                 // ad-data
-                  0x04, 0x01, 'a'
+              0x30, 0x00,
             } );
 
         stream.flip();
@@ -140,21 +137,66 @@ public class AuthorizationDataDecoderTes
         kerberosDecoder.decode( stream, authDataContainer );
         fail();
     }
+
     
+    @Test( expected = DecoderException.class)
+    public void testAuthorizationDataWithNoInnerData() throws DecoderException
+    {
+        Asn1Decoder kerberosDecoder = new Asn1Decoder();
+
+        ByteBuffer stream = ByteBuffer.allocate( 0x04 );
+        
+        stream.put( new byte[]
+            { 
+              0x30, 0x02,
+               0x30, 0x00 
+            } );
+
+        stream.flip();
+
+        AuthorizationDataContainer authDataContainer = new AuthorizationDataContainer();
+        
+        kerberosDecoder.decode( stream, authDataContainer );
+        fail();
+    }
+
     
     @Test( expected = DecoderException.class)
-    public void testAuthorizationDataWithoutData() throws DecoderException
+    public void testAuthorizationDataEmptyTypeTag() throws DecoderException
     {
         Asn1Decoder kerberosDecoder = new Asn1Decoder();
 
-        ByteBuffer stream = ByteBuffer.allocate( 0x09 );
+        ByteBuffer stream = ByteBuffer.allocate( 0x06 );
         
         stream.put( new byte[]
             { 
-              0x30, 0x7,
-               0x30, 0x5,
-                (byte)0xA0, 0x03,                 // ad-data
-                  0x02, 0x01, 0x02
+              0x30, 0x04,
+               0x30, 0x02,
+                (byte)0xA0, 0x00                 // ad-data
+            } );
+
+        stream.flip();
+
+        AuthorizationDataContainer authDataContainer = new AuthorizationDataContainer();
+        
+        kerberosDecoder.decode( stream, authDataContainer );
+        fail();
+    }
+
+
+    @Test( expected = DecoderException.class)
+    public void testAuthorizationDataEmptyTypeValue() throws DecoderException
+    {
+        Asn1Decoder kerberosDecoder = new Asn1Decoder();
+
+        ByteBuffer stream = ByteBuffer.allocate( 0x08 );
+        
+        stream.put( new byte[]
+            { 
+              0x30, 0x06,
+               0x30, 0x04,
+                (byte)0xA0, 0x02,                 // ad-data
+                  0x02, 0x00
             } );
 
         stream.flip();
@@ -164,19 +206,45 @@ public class AuthorizationDataDecoderTes
         kerberosDecoder.decode( stream, authDataContainer );
         fail();
     }
+    
+    
+    @Test( expected = DecoderException.class)
+    public void testAuthorizationDataWithoutType() throws DecoderException
+    {
+        Asn1Decoder kerberosDecoder = new Asn1Decoder();
 
+        ByteBuffer stream = ByteBuffer.allocate( 0x09 );
+        
+        stream.put( new byte[]
+            { 
+              0x30, 0x07,
+               0x30, 0x05,
+                (byte)0xA1, 0x03,                 // ad-data
+                  0x04, 0x01, 'a'
+            } );
+
+        stream.flip();
+
+        AuthorizationDataContainer authDataContainer = new AuthorizationDataContainer();
+        
+        kerberosDecoder.decode( stream, authDataContainer );
+        fail();
+    }
+    
     
     @Test( expected = DecoderException.class)
-    public void testAuthorizationDataWithIncorrectPdu() throws DecoderException
+    public void testAuthorizationDataWithoutData() throws DecoderException
     {
         Asn1Decoder kerberosDecoder = new Asn1Decoder();
 
-        ByteBuffer stream = ByteBuffer.allocate( 0x04 );
+        ByteBuffer stream = ByteBuffer.allocate( 0x09 );
         
         stream.put( new byte[]
             { 
-              0x30, 0x2,
-               0x30, 0x0 
+              0x30, 0x07,
+               0x30, 0x05,
+                (byte)0xA0, 0x03,                 // ad-data
+                  0x02, 0x01, 0x02
             } );
 
         stream.flip();
@@ -189,20 +257,19 @@ public class AuthorizationDataDecoderTes
 
     
     @Test( expected = DecoderException.class)
-    public void testAuthorizationDataWithEmptyData() throws DecoderException
+    public void testAuthorizationDataWithEmptyDataTag() throws DecoderException
     {
         Asn1Decoder kerberosDecoder = new Asn1Decoder();
 
-        ByteBuffer stream = ByteBuffer.allocate( 0xD );
+        ByteBuffer stream = ByteBuffer.allocate( 0xB );
         
         stream.put( new byte[]
             { 
-               0x30, 0x0B,
-                0x30, 0x09,
+               0x30, 0x09,
+                0x30, 0x07,
                   (byte)0xA0, 0x03,                 // ad-type
                     0x02, 0x01, 0x02,
-                  (byte)0xA1, 0x02,                 // ad-data
-                    0x04, 0x00
+                  (byte)0xA1, 0x00                  // ad-data
             } );
 
         stream.flip();
@@ -215,7 +282,7 @@ public class AuthorizationDataDecoderTes
 
     
     @Test( expected = DecoderException.class)
-    public void testAuthorizationDataWithEmptyType() throws DecoderException
+    public void testAuthorizationDataWithEmptyData() throws DecoderException
     {
         Asn1Decoder kerberosDecoder = new Asn1Decoder();
 
@@ -223,12 +290,12 @@ public class AuthorizationDataDecoderTes
         
         stream.put( new byte[]
             { 
-               0x30, 0x0B,    
+               0x30, 0x0B,
                 0x30, 0x09,
-                  (byte)0xA0, 0x02,                 // ad-type
-                    0x02, 0x00,
-                  (byte)0xA1, 0x03,                 // ad-data
-                    0x04, 0x01, 0x02
+                  (byte)0xA0, 0x03,                 // ad-type
+                    0x02, 0x01, 0x02,
+                  (byte)0xA1, 0x02,                 // ad-data
+                    0x04, 0x00
             } );
 
         stream.flip();



Mime
View raw message