You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2012/01/24 17:15:29 UTC
svn commit: r1235326 [16/28] - in /directory/apacheds/trunk:
jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/
jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/
jdbm-partitio...
Modified: directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/AsRepDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/AsRepDecoderTest.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/AsRepDecoderTest.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/AsRepDecoderTest.java Tue Jan 24 16:15:05 2012
@@ -54,73 +54,183 @@ public class AsRepDecoderTest
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0xAC );
-
+
stream.put( new byte[]
- {
- 0x6B, (byte)0x81, (byte)0xA9,
- 0x30, (byte)0x81, (byte)0xA6,
- (byte)0xA0, 0x03, // PVNO
- 0x02, 0x01, 0x05,
- (byte)0xA1, 0x03, // msg-type
- 0x02, 0x01, 0x0B,
- (byte)0xA2, 0x20, // PA-DATA
- 0x30, 0x1E,
- 0x30, 0x0D,
- (byte)0xA1,0x03,
- 0x02, 0x01, 01,
- (byte)0xA2, 0x06,
- 0x04, 0x04, 'a', 'b', 'c', 'd',
- 0x30, 0x0D,
- (byte)0xA1,0x03,
- 0x02, 0x01, 01,
- (byte)0xA2, 0x06,
- 0x04, 0x04, 'e', 'f', 'g', 'h',
- (byte)0xA3, 0x0D, // crealm
- 0x1B, 0x0B, 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
- (byte)0xA4, 0x14, // cname
- 0x30, 0x12,
- (byte)0xA0, 0x03, // name-type
- 0x02, 0x01, 0x01,
- (byte)0xA1, 0x0B, // name-string
- 0x30, 0x09,
- 0x1B, 0x07, 'h', 'n', 'e', 'l', 's', 'o', 'n',
- (byte)0xA5, 0x40, // Ticket
- 0x61, 0x3E,
- 0x30, 0x3C,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x05,
- (byte)0xA1, 0x0D,
- 0x1B, 0x0B,
- 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
- (byte)0xA2, 0x13,
- 0x30, 0x11,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x01,
- (byte)0xA1, 0x0A,
- 0x30, 0x08,
- 0x1B, 0x06,
- 'c', 'l', 'i', 'e', 'n', 't',
- (byte)0xA3, 0x11,
- 0x30, 0x0F,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x11,
- (byte)0xA2, 0x08,
- 0x04, 0x06,
- 'a', 'b', 'c', 'd', 'e', 'f',
- (byte)0xA6, 0x11, // enc-part
- 0x30, 0x0F,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x11,
- (byte)0xA2, 0x08,
- 0x04, 0x06,
- 'a', 'b', 'c', 'd', 'e', 'f',
- });
+ {
+ 0x6B, ( byte ) 0x81, ( byte ) 0xA9,
+ 0x30, ( byte ) 0x81, ( byte ) 0xA6,
+ ( byte ) 0xA0, 0x03, // PVNO
+ 0x02,
+ 0x01,
+ 0x05,
+ ( byte ) 0xA1,
+ 0x03, // msg-type
+ 0x02,
+ 0x01,
+ 0x0B,
+ ( byte ) 0xA2,
+ 0x20, // PA-DATA
+ 0x30,
+ 0x1E,
+ 0x30,
+ 0x0D,
+ ( byte ) 0xA1,
+ 0x03,
+ 0x02,
+ 0x01,
+ 01,
+ ( byte ) 0xA2,
+ 0x06,
+ 0x04,
+ 0x04,
+ 'a',
+ 'b',
+ 'c',
+ 'd',
+ 0x30,
+ 0x0D,
+ ( byte ) 0xA1,
+ 0x03,
+ 0x02,
+ 0x01,
+ 01,
+ ( byte ) 0xA2,
+ 0x06,
+ 0x04,
+ 0x04,
+ 'e',
+ 'f',
+ 'g',
+ 'h',
+ ( byte ) 0xA3,
+ 0x0D, // crealm
+ 0x1B,
+ 0x0B,
+ 'E',
+ 'X',
+ 'A',
+ 'M',
+ 'P',
+ 'L',
+ 'E',
+ '.',
+ 'C',
+ 'O',
+ 'M',
+ ( byte ) 0xA4,
+ 0x14, // cname
+ 0x30,
+ 0x12,
+ ( byte ) 0xA0,
+ 0x03, // name-type
+ 0x02,
+ 0x01,
+ 0x01,
+ ( byte ) 0xA1,
+ 0x0B, // name-string
+ 0x30,
+ 0x09,
+ 0x1B,
+ 0x07,
+ 'h',
+ 'n',
+ 'e',
+ 'l',
+ 's',
+ 'o',
+ 'n',
+ ( byte ) 0xA5,
+ 0x40, // Ticket
+ 0x61,
+ 0x3E,
+ 0x30,
+ 0x3C,
+ ( byte ) 0xA0,
+ 0x03,
+ 0x02,
+ 0x01,
+ 0x05,
+ ( byte ) 0xA1,
+ 0x0D,
+ 0x1B,
+ 0x0B,
+ 'E',
+ 'X',
+ 'A',
+ 'M',
+ 'P',
+ 'L',
+ 'E',
+ '.',
+ 'C',
+ 'O',
+ 'M',
+ ( byte ) 0xA2,
+ 0x13,
+ 0x30,
+ 0x11,
+ ( byte ) 0xA0,
+ 0x03,
+ 0x02,
+ 0x01,
+ 0x01,
+ ( byte ) 0xA1,
+ 0x0A,
+ 0x30,
+ 0x08,
+ 0x1B,
+ 0x06,
+ 'c',
+ 'l',
+ 'i',
+ 'e',
+ 'n',
+ 't',
+ ( byte ) 0xA3,
+ 0x11,
+ 0x30,
+ 0x0F,
+ ( byte ) 0xA0,
+ 0x03,
+ 0x02,
+ 0x01,
+ 0x11,
+ ( byte ) 0xA2,
+ 0x08,
+ 0x04,
+ 0x06,
+ 'a',
+ 'b',
+ 'c',
+ 'd',
+ 'e',
+ 'f',
+ ( byte ) 0xA6,
+ 0x11, // enc-part
+ 0x30,
+ 0x0F,
+ ( byte ) 0xA0,
+ 0x03,
+ 0x02,
+ 0x01,
+ 0x11,
+ ( byte ) 0xA2,
+ 0x08,
+ 0x04,
+ 0x06,
+ 'a',
+ 'b',
+ 'c',
+ 'd',
+ 'e',
+ 'f',
+ } );
stream.flip();
// Allocate a AsRep Container
AsRepContainer asRepContainer = new AsRepContainer( stream );
-
+
// Decode the AsRep PDU
try
{
@@ -132,20 +242,20 @@ public class AsRepDecoderTest
}
AsRep asRep = asRepContainer.getAsRep();
-
+
// Check the encoding
int length = asRep.computeLength();
// Check the length
assertEquals( 0xAC, length );
-
+
// Check the encoding
ByteBuffer encodedPdu = ByteBuffer.allocate( length );
-
+
try
{
encodedPdu = asRep.encode( encodedPdu );
-
+
// Check the length
assertEquals( 0xAC, encodedPdu.limit() );
}
@@ -154,18 +264,18 @@ public class AsRepDecoderTest
fail();
}
}
-
-
+
+
/**
* Test the decoding of a AS-REP with nothing in it
*/
- @Test( expected = DecoderException.class)
+ @Test(expected = DecoderException.class)
public void testAsRepEmpty() throws DecoderException
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x02 );
-
+
stream.put( new byte[]
{ 0x30, 0x00 } );
@@ -178,23 +288,23 @@ public class AsRepDecoderTest
kerberosDecoder.decode( stream, asRepContainer );
fail();
}
-
-
+
+
/**
* Test the decoding of a AS-REP with empty Pvno tag
*/
- @Test( expected = DecoderException.class)
+ @Test(expected = DecoderException.class)
public void testAsRepEmptyPvnoTag() throws DecoderException
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x04 );
-
+
stream.put( new byte[]
- {
+ {
0x30, 0x02,
- (byte)0xA0, 0x00
- } );
+ ( byte ) 0xA0, 0x00
+ } );
stream.flip();
@@ -205,24 +315,24 @@ public class AsRepDecoderTest
kerberosDecoder.decode( stream, asRepContainer );
fail();
}
-
-
+
+
/**
* Test the decoding of a AS-REP with empty Pvno value
*/
- @Test( expected = DecoderException.class)
+ @Test(expected = DecoderException.class)
public void testAsRepEmptyPvnoValue() throws DecoderException
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x06 );
-
+
stream.put( new byte[]
- {
+ {
0x30, 0x04,
- (byte)0xA0, 0x02,
- 0x02, 0x00
- } );
+ ( byte ) 0xA0, 0x02,
+ 0x02, 0x00
+ } );
stream.flip();
Modified: directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/AsReqDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/AsReqDecoderTest.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/AsReqDecoderTest.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/AsReqDecoderTest.java Tue Jan 24 16:15:05 2012
@@ -55,142 +55,142 @@ public class AsReqDecoderTest
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x193 );
-
+
stream.put( new byte[]
- {
- 0x6A, (byte)0x82, 0x01, (byte)0x8F,
- 0x30, (byte)0x82, 0x01, (byte)0x8B,
- (byte)0xA1, 0x03,
+ {
+ 0x6A, ( byte ) 0x82, 0x01, ( byte ) 0x8F,
+ 0x30, ( byte ) 0x82, 0x01, ( byte ) 0x8B,
+ ( byte ) 0xA1, 0x03,
0x02, 0x01, 0x05,
- (byte)0xA2, 0x03,
+ ( byte ) 0xA2, 0x03,
0x02, 0x01, 0x0A,
- (byte)0xA3, 0x20,
+ ( byte ) 0xA3, 0x20,
0x30, 0x1E,
- 0x30, 0x0D,
- (byte)0xA1,0x03,
- 0x02, 0x01, 01,
- (byte)0xA2, 0x06,
- 0x04, 0x04, 'a', 'b', 'c', 'd',
- 0x30, 0x0D,
- (byte)0xA1,0x03,
- 0x02, 0x01, 01,
- (byte)0xA2, 0x06,
- 0x04, 0x04, 'e', 'f', 'g', 'h',
- (byte)0xA4, (byte)0x82, 0x01, 0x5B,
- 0x30, (byte)0x82, 0x01, 0x57,
- (byte)0xA0, 0x07,
- 0x03, 0x05,
- 0x00, 0x01, 0x04, 0x00, 0x32,
- (byte)0xA1, 0x13,
- 0x30, 0x11,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x0A,
- (byte)0xA1, 0x0A,
- 0x30, 0x08,
- 0x1B, 0x06,
- 'c', 'l', 'i', 'e', 'n', 't',
- (byte)0xA2, 0x0D,
- 0x1B, 0x0B,
- 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
- (byte)0xA3, 0x13,
- 0x30, 0x11,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x0A,
- (byte)0xA1, 0x0A,
- 0x30, 0x08,
- 0x1B, 0x06,
- 's', 'e', 'r', 'v', 'e', 'r',
- (byte)0xA4, 0x11,
- 0x18, 0x0F,
- '2', '0', '1', '0', '1', '1', '1', '0', '1', '5', '4', '5', '2', '5', 'Z',
- (byte)0xA5, 0x11,
- 0x18, 0x0F,
- '2', '0', '1', '0', '1', '1', '1', '0', '1', '5', '4', '5', '2', '5', 'Z',
- (byte)0xA6, 0x11,
- 0x18, 0x0F,
- '2', '0', '1', '0', '1', '1', '1', '0', '1', '5', '4', '5', '2', '5', 'Z',
- (byte)0xA7, 0x04,
- 0x02, 0x02,
- 0x30, 0x39,
- (byte)0xA8, 0x0B,
- 0x30, 0x09,
- 0x02, 0x01, 0x06,
- 0x02, 0x01, 0x11,
- 0x02, 0x01, 0x12,
- (byte)0xA9, 0x2E,
- 0x30, 0x2C,
- 0x30, 0x14,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x02,
- (byte)0xA1, 0x0D,
- 0x04, 0x0B,
- '1', '9', '2', '.', '1', '6', '8', '.', '0', '.', '1',
- 0x30, 0x14,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x02,
- (byte)0xA1, 0x0D,
- 0x04, 0x0B,
- '1', '9', '2', '.', '1', '6', '8', '.', '0', '.', '2',
- (byte)0xAA, 0x11,
- 0x30, 0x0F,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x11,
- (byte)0xA2, 0x08,
- 0x04, 0x06,
- 'a', 'b', 'c', 'd', 'e', 'f',
- (byte)0xAB, (byte)0x81, (byte)0x83,
- 0x30, (byte)0x81, (byte)0x80,
- 0x61, 0x3E,
- 0x30, 0x3C,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x05,
- (byte)0xA1, 0x0D,
- 0x1B, 0x0B,
- 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
- (byte)0xA2, 0x13,
- 0x30, 0x11,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x01,
- (byte)0xA1, 0x0A,
- 0x30, 0x08,
- 0x1B, 0x06,
- 'c', 'l', 'i', 'e', 'n', 't',
- (byte)0xA3, 0x11,
- 0x30, 0x0F,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x11,
- (byte)0xA2, 0x08,
- 0x04, 0x06,
- 'a', 'b', 'c', 'd', 'e', 'f',
- 0x61, 0x3E,
- 0x30, 0x3C,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x05,
- (byte)0xA1, 0x0D,
- 0x1B, 0x0B,
- 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
- (byte)0xA2, 0x13,
- 0x30, 0x11,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x01,
- (byte)0xA1, 0x0A,
- 0x30, 0x08,
- 0x1B, 0x06,
- 's', 'e', 'r', 'v', 'e', 'r',
- (byte)0xA3, 0x11,
- 0x30, 0x0F,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x11,
- (byte)0xA2, 0x08,
- 0x04, 0x06,
- 'a', 'b', 'c', 'd', 'e', 'f'
- });
+ 0x30, 0x0D,
+ ( byte ) 0xA1, 0x03,
+ 0x02, 0x01, 01,
+ ( byte ) 0xA2, 0x06,
+ 0x04, 0x04, 'a', 'b', 'c', 'd',
+ 0x30, 0x0D,
+ ( byte ) 0xA1, 0x03,
+ 0x02, 0x01, 01,
+ ( byte ) 0xA2, 0x06,
+ 0x04, 0x04, 'e', 'f', 'g', 'h',
+ ( byte ) 0xA4, ( byte ) 0x82, 0x01, 0x5B,
+ 0x30, ( byte ) 0x82, 0x01, 0x57,
+ ( byte ) 0xA0, 0x07,
+ 0x03, 0x05,
+ 0x00, 0x01, 0x04, 0x00, 0x32,
+ ( byte ) 0xA1, 0x13,
+ 0x30, 0x11,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x0A,
+ ( byte ) 0xA1, 0x0A,
+ 0x30, 0x08,
+ 0x1B, 0x06,
+ 'c', 'l', 'i', 'e', 'n', 't',
+ ( byte ) 0xA2, 0x0D,
+ 0x1B, 0x0B,
+ 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
+ ( byte ) 0xA3, 0x13,
+ 0x30, 0x11,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x0A,
+ ( byte ) 0xA1, 0x0A,
+ 0x30, 0x08,
+ 0x1B, 0x06,
+ 's', 'e', 'r', 'v', 'e', 'r',
+ ( byte ) 0xA4, 0x11,
+ 0x18, 0x0F,
+ '2', '0', '1', '0', '1', '1', '1', '0', '1', '5', '4', '5', '2', '5', 'Z',
+ ( byte ) 0xA5, 0x11,
+ 0x18, 0x0F,
+ '2', '0', '1', '0', '1', '1', '1', '0', '1', '5', '4', '5', '2', '5', 'Z',
+ ( byte ) 0xA6, 0x11,
+ 0x18, 0x0F,
+ '2', '0', '1', '0', '1', '1', '1', '0', '1', '5', '4', '5', '2', '5', 'Z',
+ ( byte ) 0xA7, 0x04,
+ 0x02, 0x02,
+ 0x30, 0x39,
+ ( byte ) 0xA8, 0x0B,
+ 0x30, 0x09,
+ 0x02, 0x01, 0x06,
+ 0x02, 0x01, 0x11,
+ 0x02, 0x01, 0x12,
+ ( byte ) 0xA9, 0x2E,
+ 0x30, 0x2C,
+ 0x30, 0x14,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x02,
+ ( byte ) 0xA1, 0x0D,
+ 0x04, 0x0B,
+ '1', '9', '2', '.', '1', '6', '8', '.', '0', '.', '1',
+ 0x30, 0x14,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x02,
+ ( byte ) 0xA1, 0x0D,
+ 0x04, 0x0B,
+ '1', '9', '2', '.', '1', '6', '8', '.', '0', '.', '2',
+ ( byte ) 0xAA, 0x11,
+ 0x30, 0x0F,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x11,
+ ( byte ) 0xA2, 0x08,
+ 0x04, 0x06,
+ 'a', 'b', 'c', 'd', 'e', 'f',
+ ( byte ) 0xAB, ( byte ) 0x81, ( byte ) 0x83,
+ 0x30, ( byte ) 0x81, ( byte ) 0x80,
+ 0x61, 0x3E,
+ 0x30, 0x3C,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x05,
+ ( byte ) 0xA1, 0x0D,
+ 0x1B, 0x0B,
+ 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
+ ( byte ) 0xA2, 0x13,
+ 0x30, 0x11,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x01,
+ ( byte ) 0xA1, 0x0A,
+ 0x30, 0x08,
+ 0x1B, 0x06,
+ 'c', 'l', 'i', 'e', 'n', 't',
+ ( byte ) 0xA3, 0x11,
+ 0x30, 0x0F,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x11,
+ ( byte ) 0xA2, 0x08,
+ 0x04, 0x06,
+ 'a', 'b', 'c', 'd', 'e', 'f',
+ 0x61, 0x3E,
+ 0x30, 0x3C,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x05,
+ ( byte ) 0xA1, 0x0D,
+ 0x1B, 0x0B,
+ 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
+ ( byte ) 0xA2, 0x13,
+ 0x30, 0x11,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x01,
+ ( byte ) 0xA1, 0x0A,
+ 0x30, 0x08,
+ 0x1B, 0x06,
+ 's', 'e', 'r', 'v', 'e', 'r',
+ ( byte ) 0xA3, 0x11,
+ 0x30, 0x0F,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x11,
+ ( byte ) 0xA2, 0x08,
+ 0x04, 0x06,
+ 'a', 'b', 'c', 'd', 'e', 'f'
+ } );
stream.flip();
// Allocate a AsReq Container
AsReqContainer asReqContainer = new AsReqContainer( stream );
-
+
// Decode the AsReq PDU
try
{
@@ -202,22 +202,22 @@ public class AsReqDecoderTest
}
AsReq asReq = asReqContainer.getAsReq();
-
+
assertTrue( asReq instanceof AsReq );
-
+
// Check the encoding
int length = asReq.computeLength();
// Check the length
assertEquals( 0x193, length );
-
+
// Check the encoding
ByteBuffer encodedPdu = ByteBuffer.allocate( length );
-
+
try
{
encodedPdu = asReq.encode( encodedPdu );
-
+
// Check the length
assertEquals( 0x193, encodedPdu.limit() );
}
@@ -226,169 +226,169 @@ public class AsReqDecoderTest
fail();
}
}
-
-
+
+
/**
* Test the decoding of a AsReq message with a bad MsgType
*/
- @Test( expected = DecoderException.class)
+ @Test(expected = DecoderException.class)
public void testDecodeFullAsReqBadMsgType() throws Exception
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x193 );
-
+
stream.put( new byte[]
- {
- 0x6A, (byte)0x82, 0x01, (byte)0x8F,
- 0x30, (byte)0x82, 0x01, (byte)0x8B,
- (byte)0xA1, 0x03,
+ {
+ 0x6A, ( byte ) 0x82, 0x01, ( byte ) 0x8F,
+ 0x30, ( byte ) 0x82, 0x01, ( byte ) 0x8B,
+ ( byte ) 0xA1, 0x03,
0x02, 0x01, 0x05,
- (byte)0xA2, 0x03,
+ ( byte ) 0xA2, 0x03,
0x02, 0x01, 0x0C,
- (byte)0xA3, 0x20,
+ ( byte ) 0xA3, 0x20,
0x30, 0x1E,
- 0x30, 0x0D,
- (byte)0xA1,0x03,
- 0x02, 0x01, 01,
- (byte)0xA2, 0x06,
- 0x04, 0x04, 'a', 'b', 'c', 'd',
- 0x30, 0x0D,
- (byte)0xA1,0x03,
- 0x02, 0x01, 01,
- (byte)0xA2, 0x06,
- 0x04, 0x04, 'e', 'f', 'g', 'h',
- (byte)0xA4, (byte)0x82, 0x01, 0x5B,
- 0x30, (byte)0x82, 0x01, 0x57,
- (byte)0xA0, 0x07,
- 0x03, 0x05,
- 0x00, 0x01, 0x04, 0x00, 0x32,
- (byte)0xA1, 0x13,
- 0x30, 0x11,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x0A,
- (byte)0xA1, 0x0A,
- 0x30, 0x08,
- 0x1B, 0x06,
- 'c', 'l', 'i', 'e', 'n', 't',
- (byte)0xA2, 0x0D,
- 0x1B, 0x0B,
- 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
- (byte)0xA3, 0x13,
- 0x30, 0x11,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x0A,
- (byte)0xA1, 0x0A,
- 0x30, 0x08,
- 0x1B, 0x06,
- 's', 'e', 'r', 'v', 'e', 'r',
- (byte)0xA4, 0x11,
- 0x18, 0x0F,
- '2', '0', '1', '0', '1', '1', '1', '0', '1', '5', '4', '5', '2', '5', 'Z',
- (byte)0xA5, 0x11,
- 0x18, 0x0F,
- '2', '0', '1', '0', '1', '1', '1', '0', '1', '5', '4', '5', '2', '5', 'Z',
- (byte)0xA6, 0x11,
- 0x18, 0x0F,
- '2', '0', '1', '0', '1', '1', '1', '0', '1', '5', '4', '5', '2', '5', 'Z',
- (byte)0xA7, 0x04,
- 0x02, 0x02,
- 0x30, 0x39,
- (byte)0xA8, 0x0B,
- 0x30, 0x09,
- 0x02, 0x01, 0x06,
- 0x02, 0x01, 0x11,
- 0x02, 0x01, 0x12,
- (byte)0xA9, 0x2E,
- 0x30, 0x2C,
- 0x30, 0x14,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x02,
- (byte)0xA1, 0x0D,
- 0x04, 0x0B,
- '1', '9', '2', '.', '1', '6', '8', '.', '0', '.', '1',
- 0x30, 0x14,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x02,
- (byte)0xA1, 0x0D,
- 0x04, 0x0B,
- '1', '9', '2', '.', '1', '6', '8', '.', '0', '.', '2',
- (byte)0xAA, 0x11,
- 0x30, 0x0F,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x11,
- (byte)0xA2, 0x08,
- 0x04, 0x06,
- 'a', 'b', 'c', 'd', 'e', 'f',
- (byte)0xAB, (byte)0x81, (byte)0x83,
- 0x30, (byte)0x81, (byte)0x80,
- 0x61, 0x3E,
- 0x30, 0x3C,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x05,
- (byte)0xA1, 0x0D,
- 0x1B, 0x0B,
- 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
- (byte)0xA2, 0x13,
- 0x30, 0x11,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x01,
- (byte)0xA1, 0x0A,
- 0x30, 0x08,
- 0x1B, 0x06,
- 'c', 'l', 'i', 'e', 'n', 't',
- (byte)0xA3, 0x11,
- 0x30, 0x0F,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x11,
- (byte)0xA2, 0x08,
- 0x04, 0x06,
- 'a', 'b', 'c', 'd', 'e', 'f',
- 0x61, 0x3E,
- 0x30, 0x3C,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x05,
- (byte)0xA1, 0x0D,
- 0x1B, 0x0B,
- 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
- (byte)0xA2, 0x13,
- 0x30, 0x11,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x01,
- (byte)0xA1, 0x0A,
- 0x30, 0x08,
- 0x1B, 0x06,
- 's', 'e', 'r', 'v', 'e', 'r',
- (byte)0xA3, 0x11,
- 0x30, 0x0F,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x11,
- (byte)0xA2, 0x08,
- 0x04, 0x06,
- 'a', 'b', 'c', 'd', 'e', 'f'
- });
+ 0x30, 0x0D,
+ ( byte ) 0xA1, 0x03,
+ 0x02, 0x01, 01,
+ ( byte ) 0xA2, 0x06,
+ 0x04, 0x04, 'a', 'b', 'c', 'd',
+ 0x30, 0x0D,
+ ( byte ) 0xA1, 0x03,
+ 0x02, 0x01, 01,
+ ( byte ) 0xA2, 0x06,
+ 0x04, 0x04, 'e', 'f', 'g', 'h',
+ ( byte ) 0xA4, ( byte ) 0x82, 0x01, 0x5B,
+ 0x30, ( byte ) 0x82, 0x01, 0x57,
+ ( byte ) 0xA0, 0x07,
+ 0x03, 0x05,
+ 0x00, 0x01, 0x04, 0x00, 0x32,
+ ( byte ) 0xA1, 0x13,
+ 0x30, 0x11,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x0A,
+ ( byte ) 0xA1, 0x0A,
+ 0x30, 0x08,
+ 0x1B, 0x06,
+ 'c', 'l', 'i', 'e', 'n', 't',
+ ( byte ) 0xA2, 0x0D,
+ 0x1B, 0x0B,
+ 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
+ ( byte ) 0xA3, 0x13,
+ 0x30, 0x11,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x0A,
+ ( byte ) 0xA1, 0x0A,
+ 0x30, 0x08,
+ 0x1B, 0x06,
+ 's', 'e', 'r', 'v', 'e', 'r',
+ ( byte ) 0xA4, 0x11,
+ 0x18, 0x0F,
+ '2', '0', '1', '0', '1', '1', '1', '0', '1', '5', '4', '5', '2', '5', 'Z',
+ ( byte ) 0xA5, 0x11,
+ 0x18, 0x0F,
+ '2', '0', '1', '0', '1', '1', '1', '0', '1', '5', '4', '5', '2', '5', 'Z',
+ ( byte ) 0xA6, 0x11,
+ 0x18, 0x0F,
+ '2', '0', '1', '0', '1', '1', '1', '0', '1', '5', '4', '5', '2', '5', 'Z',
+ ( byte ) 0xA7, 0x04,
+ 0x02, 0x02,
+ 0x30, 0x39,
+ ( byte ) 0xA8, 0x0B,
+ 0x30, 0x09,
+ 0x02, 0x01, 0x06,
+ 0x02, 0x01, 0x11,
+ 0x02, 0x01, 0x12,
+ ( byte ) 0xA9, 0x2E,
+ 0x30, 0x2C,
+ 0x30, 0x14,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x02,
+ ( byte ) 0xA1, 0x0D,
+ 0x04, 0x0B,
+ '1', '9', '2', '.', '1', '6', '8', '.', '0', '.', '1',
+ 0x30, 0x14,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x02,
+ ( byte ) 0xA1, 0x0D,
+ 0x04, 0x0B,
+ '1', '9', '2', '.', '1', '6', '8', '.', '0', '.', '2',
+ ( byte ) 0xAA, 0x11,
+ 0x30, 0x0F,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x11,
+ ( byte ) 0xA2, 0x08,
+ 0x04, 0x06,
+ 'a', 'b', 'c', 'd', 'e', 'f',
+ ( byte ) 0xAB, ( byte ) 0x81, ( byte ) 0x83,
+ 0x30, ( byte ) 0x81, ( byte ) 0x80,
+ 0x61, 0x3E,
+ 0x30, 0x3C,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x05,
+ ( byte ) 0xA1, 0x0D,
+ 0x1B, 0x0B,
+ 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
+ ( byte ) 0xA2, 0x13,
+ 0x30, 0x11,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x01,
+ ( byte ) 0xA1, 0x0A,
+ 0x30, 0x08,
+ 0x1B, 0x06,
+ 'c', 'l', 'i', 'e', 'n', 't',
+ ( byte ) 0xA3, 0x11,
+ 0x30, 0x0F,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x11,
+ ( byte ) 0xA2, 0x08,
+ 0x04, 0x06,
+ 'a', 'b', 'c', 'd', 'e', 'f',
+ 0x61, 0x3E,
+ 0x30, 0x3C,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x05,
+ ( byte ) 0xA1, 0x0D,
+ 0x1B, 0x0B,
+ 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
+ ( byte ) 0xA2, 0x13,
+ 0x30, 0x11,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x01,
+ ( byte ) 0xA1, 0x0A,
+ 0x30, 0x08,
+ 0x1B, 0x06,
+ 's', 'e', 'r', 'v', 'e', 'r',
+ ( byte ) 0xA3, 0x11,
+ 0x30, 0x0F,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x11,
+ ( byte ) 0xA2, 0x08,
+ 0x04, 0x06,
+ 'a', 'b', 'c', 'd', 'e', 'f'
+ } );
stream.flip();
// Allocate a AsReq Container
AsReqContainer asReqContainer = new AsReqContainer( stream );
-
+
// Decode the AsReq PDU
kerberosDecoder.decode( stream, asReqContainer );
fail();
}
-
-
+
+
/**
* Test the decoding of a AS-REQ with nothing in it
*/
- @Test( expected = DecoderException.class)
+ @Test(expected = DecoderException.class)
public void testAsReqEmpty() throws DecoderException
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x02 );
-
+
stream.put( new byte[]
{ 0x6A, 0x00 } );
@@ -412,129 +412,129 @@ public class AsReqDecoderTest
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x171 );
-
+
stream.put( new byte[]
- {
- 0x6A, (byte)0x82, 0x01, (byte)0x6D,
- 0x30, (byte)0x82, 0x01, (byte)0x69,
- (byte)0xA1, 0x03,
+ {
+ 0x6A, ( byte ) 0x82, 0x01, ( byte ) 0x6D,
+ 0x30, ( byte ) 0x82, 0x01, ( byte ) 0x69,
+ ( byte ) 0xA1, 0x03,
0x02, 0x01, 0x05,
- (byte)0xA2, 0x03,
+ ( byte ) 0xA2, 0x03,
+ 0x02, 0x01, 0x0A,
+ ( byte ) 0xA4, ( byte ) 0x82, 0x01, 0x5B,
+ 0x30, ( byte ) 0x82, 0x01, 0x57,
+ ( byte ) 0xA0, 0x07,
+ 0x03, 0x05,
+ 0x00, 0x01, 0x04, 0x00, 0x32,
+ ( byte ) 0xA1, 0x13,
+ 0x30, 0x11,
+ ( byte ) 0xA0, 0x03,
0x02, 0x01, 0x0A,
- (byte)0xA4, (byte)0x82, 0x01, 0x5B,
- 0x30, (byte)0x82, 0x01, 0x57,
- (byte)0xA0, 0x07,
- 0x03, 0x05,
- 0x00, 0x01, 0x04, 0x00, 0x32,
- (byte)0xA1, 0x13,
- 0x30, 0x11,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x0A,
- (byte)0xA1, 0x0A,
- 0x30, 0x08,
- 0x1B, 0x06,
- 'c', 'l', 'i', 'e', 'n', 't',
- (byte)0xA2, 0x0D,
- 0x1B, 0x0B,
- 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
- (byte)0xA3, 0x13,
- 0x30, 0x11,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x0A,
- (byte)0xA1, 0x0A,
- 0x30, 0x08,
- 0x1B, 0x06,
- 's', 'e', 'r', 'v', 'e', 'r',
- (byte)0xA4, 0x11,
- 0x18, 0x0F,
- '2', '0', '1', '0', '1', '1', '1', '0', '1', '5', '4', '5', '2', '5', 'Z',
- (byte)0xA5, 0x11,
- 0x18, 0x0F,
- '2', '0', '1', '0', '1', '1', '1', '0', '1', '5', '4', '5', '2', '5', 'Z',
- (byte)0xA6, 0x11,
- 0x18, 0x0F,
- '2', '0', '1', '0', '1', '1', '1', '0', '1', '5', '4', '5', '2', '5', 'Z',
- (byte)0xA7, 0x04,
- 0x02, 0x02,
- 0x30, 0x39,
- (byte)0xA8, 0x0B,
- 0x30, 0x09,
- 0x02, 0x01, 0x06,
- 0x02, 0x01, 0x11,
- 0x02, 0x01, 0x12,
- (byte)0xA9, 0x2E,
- 0x30, 0x2C,
- 0x30, 0x14,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x02,
- (byte)0xA1, 0x0D,
- 0x04, 0x0B,
- '1', '9', '2', '.', '1', '6', '8', '.', '0', '.', '1',
- 0x30, 0x14,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x02,
- (byte)0xA1, 0x0D,
- 0x04, 0x0B,
- '1', '9', '2', '.', '1', '6', '8', '.', '0', '.', '2',
- (byte)0xAA, 0x11,
- 0x30, 0x0F,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x11,
- (byte)0xA2, 0x08,
- 0x04, 0x06,
- 'a', 'b', 'c', 'd', 'e', 'f',
- (byte)0xAB, (byte)0x81, (byte)0x83,
- 0x30, (byte)0x81, (byte)0x80,
- 0x61, 0x3E,
- 0x30, 0x3C,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x05,
- (byte)0xA1, 0x0D,
- 0x1B, 0x0B,
- 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
- (byte)0xA2, 0x13,
- 0x30, 0x11,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x01,
- (byte)0xA1, 0x0A,
- 0x30, 0x08,
- 0x1B, 0x06,
- 'c', 'l', 'i', 'e', 'n', 't',
- (byte)0xA3, 0x11,
- 0x30, 0x0F,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x11,
- (byte)0xA2, 0x08,
- 0x04, 0x06,
- 'a', 'b', 'c', 'd', 'e', 'f',
- 0x61, 0x3E,
- 0x30, 0x3C,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x05,
- (byte)0xA1, 0x0D,
- 0x1B, 0x0B,
- 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
- (byte)0xA2, 0x13,
- 0x30, 0x11,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x01,
- (byte)0xA1, 0x0A,
- 0x30, 0x08,
- 0x1B, 0x06,
- 's', 'e', 'r', 'v', 'e', 'r',
- (byte)0xA3, 0x11,
- 0x30, 0x0F,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x11,
- (byte)0xA2, 0x08,
- 0x04, 0x06,
- 'a', 'b', 'c', 'd', 'e', 'f'
- });
+ ( byte ) 0xA1, 0x0A,
+ 0x30, 0x08,
+ 0x1B, 0x06,
+ 'c', 'l', 'i', 'e', 'n', 't',
+ ( byte ) 0xA2, 0x0D,
+ 0x1B, 0x0B,
+ 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
+ ( byte ) 0xA3, 0x13,
+ 0x30, 0x11,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x0A,
+ ( byte ) 0xA1, 0x0A,
+ 0x30, 0x08,
+ 0x1B, 0x06,
+ 's', 'e', 'r', 'v', 'e', 'r',
+ ( byte ) 0xA4, 0x11,
+ 0x18, 0x0F,
+ '2', '0', '1', '0', '1', '1', '1', '0', '1', '5', '4', '5', '2', '5', 'Z',
+ ( byte ) 0xA5, 0x11,
+ 0x18, 0x0F,
+ '2', '0', '1', '0', '1', '1', '1', '0', '1', '5', '4', '5', '2', '5', 'Z',
+ ( byte ) 0xA6, 0x11,
+ 0x18, 0x0F,
+ '2', '0', '1', '0', '1', '1', '1', '0', '1', '5', '4', '5', '2', '5', 'Z',
+ ( byte ) 0xA7, 0x04,
+ 0x02, 0x02,
+ 0x30, 0x39,
+ ( byte ) 0xA8, 0x0B,
+ 0x30, 0x09,
+ 0x02, 0x01, 0x06,
+ 0x02, 0x01, 0x11,
+ 0x02, 0x01, 0x12,
+ ( byte ) 0xA9, 0x2E,
+ 0x30, 0x2C,
+ 0x30, 0x14,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x02,
+ ( byte ) 0xA1, 0x0D,
+ 0x04, 0x0B,
+ '1', '9', '2', '.', '1', '6', '8', '.', '0', '.', '1',
+ 0x30, 0x14,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x02,
+ ( byte ) 0xA1, 0x0D,
+ 0x04, 0x0B,
+ '1', '9', '2', '.', '1', '6', '8', '.', '0', '.', '2',
+ ( byte ) 0xAA, 0x11,
+ 0x30, 0x0F,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x11,
+ ( byte ) 0xA2, 0x08,
+ 0x04, 0x06,
+ 'a', 'b', 'c', 'd', 'e', 'f',
+ ( byte ) 0xAB, ( byte ) 0x81, ( byte ) 0x83,
+ 0x30, ( byte ) 0x81, ( byte ) 0x80,
+ 0x61, 0x3E,
+ 0x30, 0x3C,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x05,
+ ( byte ) 0xA1, 0x0D,
+ 0x1B, 0x0B,
+ 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
+ ( byte ) 0xA2, 0x13,
+ 0x30, 0x11,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x01,
+ ( byte ) 0xA1, 0x0A,
+ 0x30, 0x08,
+ 0x1B, 0x06,
+ 'c', 'l', 'i', 'e', 'n', 't',
+ ( byte ) 0xA3, 0x11,
+ 0x30, 0x0F,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x11,
+ ( byte ) 0xA2, 0x08,
+ 0x04, 0x06,
+ 'a', 'b', 'c', 'd', 'e', 'f',
+ 0x61, 0x3E,
+ 0x30, 0x3C,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x05,
+ ( byte ) 0xA1, 0x0D,
+ 0x1B, 0x0B,
+ 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
+ ( byte ) 0xA2, 0x13,
+ 0x30, 0x11,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x01,
+ ( byte ) 0xA1, 0x0A,
+ 0x30, 0x08,
+ 0x1B, 0x06,
+ 's', 'e', 'r', 'v', 'e', 'r',
+ ( byte ) 0xA3, 0x11,
+ 0x30, 0x0F,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x11,
+ ( byte ) 0xA2, 0x08,
+ 0x04, 0x06,
+ 'a', 'b', 'c', 'd', 'e', 'f'
+ } );
stream.flip();
// Allocate a AsReq Container
AsReqContainer asReqContainer = new AsReqContainer( stream );
-
+
// Decode the AsReq PDU
try
{
@@ -546,18 +546,18 @@ public class AsReqDecoderTest
}
AsReq asReq = asReqContainer.getAsReq();
-
+
assertTrue( asReq instanceof AsReq );
-
+
// Check the encoding
int length = asReq.computeLength();
// Check the length
assertEquals( 0x171, length );
-
+
// Check the encoding
ByteBuffer encodedPdu = ByteBuffer.allocate( length );
-
+
try
{
encodedPdu = asReq.encode( encodedPdu );
Modified: directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/AuthenticatorDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/AuthenticatorDecoderTest.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/AuthenticatorDecoderTest.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/AuthenticatorDecoderTest.java Tue Jan 24 16:15:05 2012
@@ -55,64 +55,161 @@ public class AuthenticatorDecoderTest
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x95 );
-
+
stream.put( new byte[]
- {
- 0x62, (byte)0x81, (byte)0x92,
- 0x30, (byte)0x81, (byte)0x8F,
- (byte)0xA0, 0x03, // authenticator vno
- 0x02, 0x01, 0x05,
- (byte)0xA1, 0x0D, // crealm
- 0x1B, 0x0B,
- 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
- (byte)0xA2, 0x13, // cname
- 0x30, 0x11,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x0A,
- (byte)0xA1, 0x0A,
- 0x30, 0x08,
- 0x1B, 0x06,
- 'c', 'l', 'i', 'e', 'n', 't',
- (byte)0xA3, 0x0F, // cksum
- 0x30, 0x0D,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x01,
- (byte)0xA1, 0x06,
- 0x04, 0x04, 'a', 'b', 'c', 'd',
- (byte)0xA4, 0x03, // cusec
- 0x02, 0x01, 0x7F,
- (byte)0xA5, 0x11, // ctime
- 0x18, 0x0F,
- '2', '0', '1', '0', '1', '1', '1', '0', '1', '5', '4', '5', '2', '5', 'Z',
- (byte)0xA6, 0x0F, // subkey
- 0x30, 0x0D,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x01,
- (byte)0xA1, 0x06,
- 0x04, 0x04, 'A', 'B', 'C', 'D',
- (byte)0xA7, 0x04, // seq-number
- 0x02, 0x02,
- 0x30, 0x39,
- (byte)0xA8, 0x24, // authorization-data
- 0x30, 0x22,
- 0x30, 0x0F,
- (byte)0xA0, 0x03, // ad-type
- 0x02, 0x01, 0x02,
- (byte)0xA1, 0x08, // ad-data
- 0x04, 0x06, 'a', 'b', 'c', 'd', 'e', 'f',
- 0x30, 0x0F,
- (byte)0xA0, 0x03, // ad-type
- 0x02, 0x01, 0x02,
- (byte)0xA1, 0x08, // ad-data
- 0x04, 0x06, 'g', 'h', 'i', 'j', 'k', 'l'
- });
+ {
+ 0x62, ( byte ) 0x81, ( byte ) 0x92,
+ 0x30, ( byte ) 0x81, ( byte ) 0x8F,
+ ( byte ) 0xA0, 0x03, // authenticator vno
+ 0x02,
+ 0x01,
+ 0x05,
+ ( byte ) 0xA1,
+ 0x0D, // crealm
+ 0x1B,
+ 0x0B,
+ 'E',
+ 'X',
+ 'A',
+ 'M',
+ 'P',
+ 'L',
+ 'E',
+ '.',
+ 'C',
+ 'O',
+ 'M',
+ ( byte ) 0xA2,
+ 0x13, // cname
+ 0x30,
+ 0x11,
+ ( byte ) 0xA0,
+ 0x03,
+ 0x02,
+ 0x01,
+ 0x0A,
+ ( byte ) 0xA1,
+ 0x0A,
+ 0x30,
+ 0x08,
+ 0x1B,
+ 0x06,
+ 'c',
+ 'l',
+ 'i',
+ 'e',
+ 'n',
+ 't',
+ ( byte ) 0xA3,
+ 0x0F, // cksum
+ 0x30,
+ 0x0D,
+ ( byte ) 0xA0,
+ 0x03,
+ 0x02,
+ 0x01,
+ 0x01,
+ ( byte ) 0xA1,
+ 0x06,
+ 0x04,
+ 0x04,
+ 'a',
+ 'b',
+ 'c',
+ 'd',
+ ( byte ) 0xA4,
+ 0x03, // cusec
+ 0x02,
+ 0x01,
+ 0x7F,
+ ( byte ) 0xA5,
+ 0x11, // ctime
+ 0x18,
+ 0x0F,
+ '2',
+ '0',
+ '1',
+ '0',
+ '1',
+ '1',
+ '1',
+ '0',
+ '1',
+ '5',
+ '4',
+ '5',
+ '2',
+ '5',
+ 'Z',
+ ( byte ) 0xA6,
+ 0x0F, // subkey
+ 0x30,
+ 0x0D,
+ ( byte ) 0xA0,
+ 0x03,
+ 0x02,
+ 0x01,
+ 0x01,
+ ( byte ) 0xA1,
+ 0x06,
+ 0x04,
+ 0x04,
+ 'A',
+ 'B',
+ 'C',
+ 'D',
+ ( byte ) 0xA7,
+ 0x04, // seq-number
+ 0x02,
+ 0x02,
+ 0x30,
+ 0x39,
+ ( byte ) 0xA8,
+ 0x24, // authorization-data
+ 0x30,
+ 0x22,
+ 0x30,
+ 0x0F,
+ ( byte ) 0xA0,
+ 0x03, // ad-type
+ 0x02,
+ 0x01,
+ 0x02,
+ ( byte ) 0xA1,
+ 0x08, // ad-data
+ 0x04,
+ 0x06,
+ 'a',
+ 'b',
+ 'c',
+ 'd',
+ 'e',
+ 'f',
+ 0x30,
+ 0x0F,
+ ( byte ) 0xA0,
+ 0x03, // ad-type
+ 0x02,
+ 0x01,
+ 0x02,
+ ( byte ) 0xA1,
+ 0x08, // ad-data
+ 0x04,
+ 0x06,
+ 'g',
+ 'h',
+ 'i',
+ 'j',
+ 'k',
+ 'l'
+ } );
- String decodedPdu = Strings.dumpBytes(stream.array());
+ String decodedPdu = Strings.dumpBytes( stream.array() );
stream.flip();
// Allocate a Authenticator Container
Asn1Container authenticatorContainer = new AuthenticatorContainer( stream );
-
+
// Decode the Authenticator PDU
try
{
@@ -123,42 +220,42 @@ public class AuthenticatorDecoderTest
fail( de.getMessage() );
}
- Authenticator authenticator = ((AuthenticatorContainer)authenticatorContainer).getAuthenticator();
-
+ Authenticator authenticator = ( ( AuthenticatorContainer ) authenticatorContainer ).getAuthenticator();
+
// Check the encoding
int length = authenticator.computeLength();
// Check the length
assertEquals( 0x95, length );
-
+
// Check the encoding
ByteBuffer encodedPdu = ByteBuffer.allocate( length );
-
+
try
{
encodedPdu = authenticator.encode( encodedPdu );
-
+
// Check the length
assertEquals( 0x95, encodedPdu.limit() );
- assertEquals( decodedPdu, Strings.dumpBytes(encodedPdu.array()) );
+ assertEquals( decodedPdu, Strings.dumpBytes( encodedPdu.array() ) );
}
catch ( EncoderException ee )
{
fail();
}
}
-
-
+
+
/**
* Test the decoding of a Authenticator with nothing in it
*/
- @Test( expected = DecoderException.class)
+ @Test(expected = DecoderException.class)
public void testAuthenticatorEmpty() throws DecoderException
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x02 );
-
+
stream.put( new byte[]
{ 0x62, 0x00 } );
@@ -171,23 +268,23 @@ public class AuthenticatorDecoderTest
kerberosDecoder.decode( stream, authenticatorContainer );
fail();
}
-
-
+
+
/**
* Test the decoding of a Authenticator with empty sequence
*/
- @Test( expected = DecoderException.class)
+ @Test(expected = DecoderException.class)
public void testKdcReqBodyEmptySequence() throws DecoderException
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x04 );
-
+
stream.put( new byte[]
- {
+ {
0x62, 0x02,
- 0x30, 0x00
- } );
+ 0x30, 0x00
+ } );
stream.flip();
@@ -198,24 +295,24 @@ public class AuthenticatorDecoderTest
kerberosDecoder.decode( stream, authenticatorContainer );
fail();
}
-
-
+
+
/**
* Test the decoding of a Authenticator with empty authenticator-vno tag
*/
- @Test( expected = DecoderException.class)
+ @Test(expected = DecoderException.class)
public void testKdcReqBodyEmptyAuthenticatorTag() throws DecoderException
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x06 );
-
+
stream.put( new byte[]
- {
+ {
0x62, 0x04,
- 0x30, 0x02,
- (byte)0xA0, 0x00
- } );
+ 0x30, 0x02,
+ ( byte ) 0xA0, 0x00
+ } );
stream.flip();
@@ -226,25 +323,25 @@ public class AuthenticatorDecoderTest
kerberosDecoder.decode( stream, authenticatorContainer );
fail();
}
-
-
+
+
/**
* Test the decoding of a Authenticator with empty authenticator-vno value
*/
- @Test( expected = DecoderException.class)
+ @Test(expected = DecoderException.class)
public void testKdcReqBodyEmptyAuthenticatorValue() throws DecoderException
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x08 );
-
+
stream.put( new byte[]
- {
+ {
0x62, 0x06,
- 0x30, 0x04,
- (byte)0xA0, 0x02,
- 0x02, 0x00
- } );
+ 0x30, 0x04,
+ ( byte ) 0xA0, 0x02,
+ 0x02, 0x00
+ } );
stream.flip();
@@ -255,125 +352,125 @@ public class AuthenticatorDecoderTest
kerberosDecoder.decode( stream, authenticatorContainer );
fail();
}
-
-
+
+
/**
* Test the decoding of a Authenticator with no authenticator-vno
*/
- @Test( expected = DecoderException.class)
+ @Test(expected = DecoderException.class)
public void testKdcReqBodyNoOptions() throws DecoderException
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x152 );
-
+
stream.put( new byte[]
- {
- 0x30, (byte)0x82, 0x01, 0x4E,
- (byte)0xA1, 0x13,
- 0x30, 0x11,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x0A,
- (byte)0xA1, 0x0A,
- 0x30, 0x08,
- 0x1B, 0x06,
- 'c', 'l', 'i', 'e', 'n', 't',
- (byte)0xA2, 0x0D,
- 0x1B, 0x0B,
- 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
- (byte)0xA3, 0x13,
- 0x30, 0x11,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x0A,
- (byte)0xA1, 0x0A,
- 0x30, 0x08,
- 0x1B, 0x06,
- 's', 'e', 'r', 'v', 'e', 'r',
- (byte)0xA4, 0x11,
- 0x18, 0x0F,
- '2', '0', '1', '0', '1', '1', '1', '0', '1', '5', '4', '5', '2', '5', 'Z',
- (byte)0xA5, 0x11,
- 0x18, 0x0F,
- '2', '0', '1', '0', '1', '1', '1', '0', '1', '5', '4', '5', '2', '5', 'Z',
- (byte)0xA6, 0x11,
- 0x18, 0x0F,
- '2', '0', '1', '0', '1', '1', '1', '0', '1', '5', '4', '5', '2', '5', 'Z',
- (byte)0xA7, 0x04,
- 0x02, 0x02,
- 0x30, 0x39,
- (byte)0xA8, 0x0B,
- 0x30, 0x09,
- 0x02, 0x01, 0x06,
- 0x02, 0x01, 0x11,
- 0x02, 0x01, 0x12,
- (byte)0xA9, 0x2E,
- 0x30, 0x2C,
- 0x30, 0x14,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x02,
- (byte)0xA1, 0x0D,
- 0x04, 0x0B,
- '1', '9', '2', '.', '1', '6', '8', '.', '0', '.', '1',
- 0x30, 0x14,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x02,
- (byte)0xA1, 0x0D,
- 0x04, 0x0B,
- '1', '9', '2', '.', '1', '6', '8', '.', '0', '.', '2',
- (byte)0xAA, 0x11,
- 0x30, 0x0F,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x11,
- (byte)0xA2, 0x08,
- 0x04, 0x06,
- 'a', 'b', 'c', 'd', 'e', 'f',
- (byte)0xAB, (byte)0x81, (byte)0x83,
- 0x30, (byte)0x81, (byte)0x80,
- 0x61, 0x3E,
- 0x30, 0x3C,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x05,
- (byte)0xA1, 0x0D,
- 0x1B, 0x0B,
- 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
- (byte)0xA2, 0x13,
- 0x30, 0x11,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x01,
- (byte)0xA1, 0x0A,
- 0x30, 0x08,
- 0x1B, 0x06,
- 'c', 'l', 'i', 'e', 'n', 't',
- (byte)0xA3, 0x11,
- 0x30, 0x0F,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x11,
- (byte)0xA2, 0x08,
- 0x04, 0x06,
- 'a', 'b', 'c', 'd', 'e', 'f',
- 0x61, 0x3E,
- 0x30, 0x3C,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x05,
- (byte)0xA1, 0x0D,
- 0x1B, 0x0B,
- 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
- (byte)0xA2, 0x13,
- 0x30, 0x11,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x01,
- (byte)0xA1, 0x0A,
- 0x30, 0x08,
- 0x1B, 0x06,
- 's', 'e', 'r', 'v', 'e', 'r',
- (byte)0xA3, 0x11,
- 0x30, 0x0F,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x11,
- (byte)0xA2, 0x08,
- 0x04, 0x06,
- 'a', 'b', 'c', 'd', 'e', 'f'
- });
+ {
+ 0x30, ( byte ) 0x82, 0x01, 0x4E,
+ ( byte ) 0xA1, 0x13,
+ 0x30, 0x11,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x0A,
+ ( byte ) 0xA1, 0x0A,
+ 0x30, 0x08,
+ 0x1B, 0x06,
+ 'c', 'l', 'i', 'e', 'n', 't',
+ ( byte ) 0xA2, 0x0D,
+ 0x1B, 0x0B,
+ 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
+ ( byte ) 0xA3, 0x13,
+ 0x30, 0x11,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x0A,
+ ( byte ) 0xA1, 0x0A,
+ 0x30, 0x08,
+ 0x1B, 0x06,
+ 's', 'e', 'r', 'v', 'e', 'r',
+ ( byte ) 0xA4, 0x11,
+ 0x18, 0x0F,
+ '2', '0', '1', '0', '1', '1', '1', '0', '1', '5', '4', '5', '2', '5', 'Z',
+ ( byte ) 0xA5, 0x11,
+ 0x18, 0x0F,
+ '2', '0', '1', '0', '1', '1', '1', '0', '1', '5', '4', '5', '2', '5', 'Z',
+ ( byte ) 0xA6, 0x11,
+ 0x18, 0x0F,
+ '2', '0', '1', '0', '1', '1', '1', '0', '1', '5', '4', '5', '2', '5', 'Z',
+ ( byte ) 0xA7, 0x04,
+ 0x02, 0x02,
+ 0x30, 0x39,
+ ( byte ) 0xA8, 0x0B,
+ 0x30, 0x09,
+ 0x02, 0x01, 0x06,
+ 0x02, 0x01, 0x11,
+ 0x02, 0x01, 0x12,
+ ( byte ) 0xA9, 0x2E,
+ 0x30, 0x2C,
+ 0x30, 0x14,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x02,
+ ( byte ) 0xA1, 0x0D,
+ 0x04, 0x0B,
+ '1', '9', '2', '.', '1', '6', '8', '.', '0', '.', '1',
+ 0x30, 0x14,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x02,
+ ( byte ) 0xA1, 0x0D,
+ 0x04, 0x0B,
+ '1', '9', '2', '.', '1', '6', '8', '.', '0', '.', '2',
+ ( byte ) 0xAA, 0x11,
+ 0x30, 0x0F,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x11,
+ ( byte ) 0xA2, 0x08,
+ 0x04, 0x06,
+ 'a', 'b', 'c', 'd', 'e', 'f',
+ ( byte ) 0xAB, ( byte ) 0x81, ( byte ) 0x83,
+ 0x30, ( byte ) 0x81, ( byte ) 0x80,
+ 0x61, 0x3E,
+ 0x30, 0x3C,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x05,
+ ( byte ) 0xA1, 0x0D,
+ 0x1B, 0x0B,
+ 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
+ ( byte ) 0xA2, 0x13,
+ 0x30, 0x11,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x01,
+ ( byte ) 0xA1, 0x0A,
+ 0x30, 0x08,
+ 0x1B, 0x06,
+ 'c', 'l', 'i', 'e', 'n', 't',
+ ( byte ) 0xA3, 0x11,
+ 0x30, 0x0F,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x11,
+ ( byte ) 0xA2, 0x08,
+ 0x04, 0x06,
+ 'a', 'b', 'c', 'd', 'e', 'f',
+ 0x61, 0x3E,
+ 0x30, 0x3C,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x05,
+ ( byte ) 0xA1, 0x0D,
+ 0x1B, 0x0B,
+ 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
+ ( byte ) 0xA2, 0x13,
+ 0x30, 0x11,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x01,
+ ( byte ) 0xA1, 0x0A,
+ 0x30, 0x08,
+ 0x1B, 0x06,
+ 's', 'e', 'r', 'v', 'e', 'r',
+ ( byte ) 0xA3, 0x11,
+ 0x30, 0x0F,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x11,
+ ( byte ) 0xA2, 0x08,
+ 0x04, 0x06,
+ 'a', 'b', 'c', 'd', 'e', 'f'
+ } );
stream.flip();
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=1235326&r1=1235325&r2=1235326&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 Tue Jan 24 16:15:05 2012
@@ -20,6 +20,7 @@
package org.apache.directory.shared.kerberos.codec;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -38,6 +39,7 @@ import org.apache.directory.shared.kerbe
import org.apache.directory.shared.util.Strings;
import org.junit.Test;
+
/**
* Test cases for AuthorizationData decoder.
*
@@ -52,27 +54,46 @@ public class AuthorizationDataDecoderTes
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x21 );
-
+
stream.put( new byte[]
- {
- 0x30, 0x1F,
+ {
+ 0x30, 0x1F,
0x30, 0x0F,
- (byte)0xA0, 0x03, // ad-type
- 0x02, 0x01, 0x02,
- (byte)0xA1, 0x08, // ad-data
- 0x04, 0x06, 'a', 'b', 'c', 'd', 'e', 'f',
- 0x30, 0x0C,
- (byte)0xA0, 0x03, // ad-type
- 0x02, 0x01, 0x02,
- (byte)0xA1, 0x05, // ad-data
- 0x04, 0x03, 'g', 'h', 'i'
- } );
+ ( byte ) 0xA0, 0x03, // ad-type
+ 0x02,
+ 0x01,
+ 0x02,
+ ( byte ) 0xA1,
+ 0x08, // ad-data
+ 0x04,
+ 0x06,
+ 'a',
+ 'b',
+ 'c',
+ 'd',
+ 'e',
+ 'f',
+ 0x30,
+ 0x0C,
+ ( byte ) 0xA0,
+ 0x03, // ad-type
+ 0x02,
+ 0x01,
+ 0x02,
+ ( byte ) 0xA1,
+ 0x05, // ad-data
+ 0x04,
+ 0x03,
+ 'g',
+ 'h',
+ 'i'
+ } );
- String decodedPdu = Strings.dumpBytes(stream.array());
+ String decodedPdu = Strings.dumpBytes( stream.array() );
stream.flip();
AuthorizationDataContainer authDataContainer = new AuthorizationDataContainer();
-
+
// Decode the AuthorizationData PDU
try
{
@@ -84,32 +105,33 @@ public class AuthorizationDataDecoderTes
}
AuthorizationData authData = authDataContainer.getAuthorizationData();
-
+
assertNotNull( authData.getAuthorizationData().size() );
assertEquals( 2, authData.getAuthorizationData().size() );
-
- String[] expected = new String[]{ "abcdef", "ghi" };
+
+ String[] expected = new String[]
+ { "abcdef", "ghi" };
int i = 0;
-
+
for ( AuthorizationDataEntry ad : authData.getAuthorizationData() )
{
assertEquals( AuthorizationType.AD_INTENDED_FOR_SERVER, ad.getAdType() );
- assertTrue( Arrays.equals( Strings.getBytesUtf8(expected[i++]), ad.getAdData() ) );
-
+ assertTrue( Arrays.equals( Strings.getBytesUtf8( expected[i++] ), ad.getAdData() ) );
+
}
// Check the encoding
ByteBuffer bb = ByteBuffer.allocate( authData.computeLength() );
-
+
try
{
bb = authData.encode( bb );
-
+
// Check the length
assertEquals( 0x21, bb.limit() );
-
- String encodedPdu = Strings.dumpBytes(bb.array());
-
+
+ String encodedPdu = Strings.dumpBytes( bb.array() );
+
assertEquals( encodedPdu, decodedPdu );
}
catch ( EncoderException ee )
@@ -117,192 +139,204 @@ public class AuthorizationDataDecoderTes
fail();
}
}
-
-
- @Test( expected = DecoderException.class)
+
+
+ @Test(expected = DecoderException.class)
public void testAuthorizationDataEmptyPdu() throws DecoderException
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x02 );
-
+
stream.put( new byte[]
- {
- 0x30, 0x00,
- } );
+ {
+ 0x30, 0x00,
+ } );
stream.flip();
AuthorizationDataContainer authDataContainer = new AuthorizationDataContainer();
-
+
kerberosDecoder.decode( stream, authDataContainer );
fail();
}
-
- @Test( expected = DecoderException.class)
+
+ @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
- } );
+ {
+ 0x30, 0x02,
+ 0x30, 0x00
+ } );
stream.flip();
AuthorizationDataContainer authDataContainer = new AuthorizationDataContainer();
-
+
kerberosDecoder.decode( stream, authDataContainer );
fail();
}
-
- @Test( expected = DecoderException.class)
+
+ @Test(expected = DecoderException.class)
public void testAuthorizationDataEmptyTypeTag() throws DecoderException
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x06 );
-
+
stream.put( new byte[]
- {
- 0x30, 0x04,
- 0x30, 0x02,
- (byte)0xA0, 0x00 // ad-data
- } );
+ {
+ 0x30, 0x04,
+ 0x30, 0x02,
+ ( byte ) 0xA0, 0x00 // ad-data
+ } );
stream.flip();
AuthorizationDataContainer authDataContainer = new AuthorizationDataContainer();
-
+
kerberosDecoder.decode( stream, authDataContainer );
fail();
}
- @Test( expected = DecoderException.class)
+ @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
- } );
+ {
+ 0x30, 0x06,
+ 0x30, 0x04,
+ ( byte ) 0xA0, 0x02, // ad-data
+ 0x02,
+ 0x00
+ } );
stream.flip();
AuthorizationDataContainer authDataContainer = new AuthorizationDataContainer();
-
+
kerberosDecoder.decode( stream, authDataContainer );
fail();
}
-
-
- @Test( expected = DecoderException.class)
+
+
+ @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'
- } );
+ {
+ 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)
+
+
+ @Test(expected = DecoderException.class)
public void testAuthorizationDataWithoutData() throws DecoderException
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x09 );
-
+
stream.put( new byte[]
- {
- 0x30, 0x07,
- 0x30, 0x05,
- (byte)0xA0, 0x03, // ad-data
- 0x02, 0x01, 0x02
- } );
+ {
+ 0x30, 0x07,
+ 0x30, 0x05,
+ ( byte ) 0xA0, 0x03, // ad-data
+ 0x02,
+ 0x01,
+ 0x02
+ } );
stream.flip();
AuthorizationDataContainer authDataContainer = new AuthorizationDataContainer();
-
+
kerberosDecoder.decode( stream, authDataContainer );
fail();
}
-
- @Test( expected = DecoderException.class)
+
+ @Test(expected = DecoderException.class)
public void testAuthorizationDataWithEmptyDataTag() throws DecoderException
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0xB );
-
+
stream.put( new byte[]
- {
- 0x30, 0x09,
+ {
+ 0x30, 0x09,
0x30, 0x07,
- (byte)0xA0, 0x03, // ad-type
- 0x02, 0x01, 0x02,
- (byte)0xA1, 0x00 // ad-data
- } );
+ ( byte ) 0xA0, 0x03, // ad-type
+ 0x02,
+ 0x01,
+ 0x02,
+ ( byte ) 0xA1,
+ 0x00 // ad-data
+ } );
stream.flip();
AuthorizationDataContainer authDataContainer = new AuthorizationDataContainer();
-
+
kerberosDecoder.decode( stream, authDataContainer );
fail();
}
-
- @Test( expected = DecoderException.class)
+
+ @Test(expected = DecoderException.class)
public void testAuthorizationDataWithEmptyData() throws DecoderException
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0xD );
-
+
stream.put( new byte[]
- {
- 0x30, 0x0B,
+ {
+ 0x30, 0x0B,
0x30, 0x09,
- (byte)0xA0, 0x03, // ad-type
- 0x02, 0x01, 0x02,
- (byte)0xA1, 0x02, // ad-data
- 0x04, 0x00
- } );
+ ( byte ) 0xA0, 0x03, // ad-type
+ 0x02,
+ 0x01,
+ 0x02,
+ ( byte ) 0xA1,
+ 0x02, // ad-data
+ 0x04,
+ 0x00
+ } );
stream.flip();
AuthorizationDataContainer authDataContainer = new AuthorizationDataContainer();
-
+
kerberosDecoder.decode( stream, authDataContainer );
fail();
}
Modified: directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/ChecksumDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/ChecksumDecoderTest.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/ChecksumDecoderTest.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/ChecksumDecoderTest.java Tue Jan 24 16:15:05 2012
@@ -20,6 +20,7 @@
package org.apache.directory.shared.kerberos.codec;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -36,6 +37,7 @@ import org.apache.directory.shared.kerbe
import org.apache.directory.shared.util.Strings;
import org.junit.Test;
+
/**
* Test cases for Checksum codec.
*
@@ -47,23 +49,33 @@ public class ChecksumDecoderTest
public void testDecodeChecksum()
{
Asn1Decoder krbDecoder = new Asn1Decoder();
-
+
ByteBuffer stream = ByteBuffer.allocate( 0x11 );
stream.put( new byte[]
- {
+ {
0x30, 0x0F,
- (byte)0xA0, 0x03, // cksumtype
- 0x02, 0x01, 0x02,
- (byte)0xA1, 0x08, // checksum
- 0x04, 0x06, 'c', 'h', 'k', 's', 'u', 'm'
- } );
-
- String decodedPdu = Strings.dumpBytes(stream.array());
+ ( byte ) 0xA0, 0x03, // cksumtype
+ 0x02,
+ 0x01,
+ 0x02,
+ ( byte ) 0xA1,
+ 0x08, // checksum
+ 0x04,
+ 0x06,
+ 'c',
+ 'h',
+ 'k',
+ 's',
+ 'u',
+ 'm'
+ } );
+
+ String decodedPdu = Strings.dumpBytes( stream.array() );
stream.flip();
ChecksumContainer chkContainer = new ChecksumContainer();
-
+
try
{
krbDecoder.decode( stream, chkContainer );
@@ -74,21 +86,21 @@ public class ChecksumDecoderTest
}
Checksum checksum = chkContainer.getChecksum();
-
+
assertEquals( ChecksumType.getTypeByValue( 2 ), checksum.getChecksumType() );
- assertTrue( Arrays.equals( Strings.getBytesUtf8("chksum"), checksum.getChecksumValue() ) );
-
+ assertTrue( Arrays.equals( Strings.getBytesUtf8( "chksum" ), checksum.getChecksumValue() ) );
+
ByteBuffer bb = ByteBuffer.allocate( checksum.computeLength() );
-
+
try
{
bb = checksum.encode( bb );
-
+
// Check the length
assertEquals( 0x11, bb.limit() );
-
- String encodedPdu = Strings.dumpBytes(bb.array());
-
+
+ String encodedPdu = Strings.dumpBytes( bb.array() );
+
assertEquals( encodedPdu, decodedPdu );
}
catch ( EncoderException ee )
@@ -96,70 +108,79 @@ public class ChecksumDecoderTest
fail();
}
}
-
-
- @Test( expected = DecoderException.class )
+
+
+ @Test(expected = DecoderException.class)
public void testDecodeChecksumWithoutType() throws DecoderException
{
Asn1Decoder krbDecoder = new Asn1Decoder();
-
+
ByteBuffer stream = ByteBuffer.allocate( 0xC );
stream.put( new byte[]
- {
+ {
0x30, 0xA,
- (byte)0xA1, 0x08, // checksum
- 0x04, 0x06, 'c', 'h', 'k', 's', 'u', 'm'
- } );
-
+ ( byte ) 0xA1, 0x08, // checksum
+ 0x04,
+ 0x06,
+ 'c',
+ 'h',
+ 'k',
+ 's',
+ 'u',
+ 'm'
+ } );
+
stream.flip();
ChecksumContainer chkContainer = new ChecksumContainer();
-
+
krbDecoder.decode( stream, chkContainer );
fail();
}
-
-
- @Test( expected = DecoderException.class )
+
+
+ @Test(expected = DecoderException.class)
public void testDecodeChecksumWithoutChecksumValue() throws DecoderException
{
Asn1Decoder krbDecoder = new Asn1Decoder();
-
+
ByteBuffer stream = ByteBuffer.allocate( 0x07 );
stream.put( new byte[]
- {
+ {
0x30, 0x05,
- (byte)0xA0, 0x03, // cksumtype
- 0x02, 0x01, 0x02
- } );
-
+ ( byte ) 0xA0, 0x03, // cksumtype
+ 0x02,
+ 0x01,
+ 0x02
+ } );
+
stream.flip();
ChecksumContainer chkContainer = new ChecksumContainer();
-
+
krbDecoder.decode( stream, chkContainer );
fail();
}
-
-
- @Test( expected = DecoderException.class )
+
+
+ @Test(expected = DecoderException.class)
public void testDecodeChecksumWithEmptySeq() throws DecoderException
{
Asn1Decoder krbDecoder = new Asn1Decoder();
-
+
ByteBuffer stream = ByteBuffer.allocate( 2 );
stream.put( new byte[]
- {
+ {
0x30, 0x0
- } );
-
+ } );
+
stream.flip();
ChecksumContainer chkContainer = new ChecksumContainer();
-
+
krbDecoder.decode( stream, chkContainer );
fail();
}
Modified: directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/ETypeInfo2DecoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/ETypeInfo2DecoderTest.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/ETypeInfo2DecoderTest.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/ETypeInfo2DecoderTest.java Tue Jan 24 16:15:05 2012
@@ -58,23 +58,41 @@ public class ETypeInfo2DecoderTest
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x20 );
-
+
stream.put( new byte[]
- {
- 0x30, 0x1E,
- 0x30, 0x0D,
- (byte)0xA0, 0x03, // etype
- 0x02, 0x01, 0x05,
- (byte)0xA1, 0x06, // salt
- 0x1B, 0x04, 0x31, 0x32, 0x33, 0x34,
+ {
+ 0x30, 0x1E,
0x30, 0x0D,
- (byte)0xA0, 0x03, // etype
- 0x02, 0x01, 0x05,
- (byte)0xA1, 0x06, // salt
- 0x1B, 0x04, 0x35, 0x36, 0x37, 0x38
- } );
+ ( byte ) 0xA0, 0x03, // etype
+ 0x02,
+ 0x01,
+ 0x05,
+ ( byte ) 0xA1,
+ 0x06, // salt
+ 0x1B,
+ 0x04,
+ 0x31,
+ 0x32,
+ 0x33,
+ 0x34,
+ 0x30,
+ 0x0D,
+ ( byte ) 0xA0,
+ 0x03, // etype
+ 0x02,
+ 0x01,
+ 0x05,
+ ( byte ) 0xA1,
+ 0x06, // salt
+ 0x1B,
+ 0x04,
+ 0x35,
+ 0x36,
+ 0x37,
+ 0x38
+ } );
- String decodedPdu = Strings.dumpBytes(stream.array());
+ String decodedPdu = Strings.dumpBytes( stream.array() );
stream.flip();
// Allocate a ETypeInfo2 Container
@@ -95,10 +113,11 @@ public class ETypeInfo2DecoderTest
ETypeInfo2 etypeInfo2 = ( ( ETypeInfo2Container ) etypeInfo2Container ).getETypeInfo2();
assertEquals( 2, etypeInfo2.getETypeInfo2Entries().length );
-
- String[] expected = new String[]{ "1234", "5678" };
+
+ String[] expected = new String[]
+ { "1234", "5678" };
int i = 0;
-
+
for ( ETypeInfo2Entry etypeInfo2Entry : etypeInfo2.getETypeInfo2Entries() )
{
assertEquals( EncryptionType.DES3_CBC_MD5, etypeInfo2Entry.getEType() );
@@ -108,16 +127,16 @@ public class ETypeInfo2DecoderTest
// Check the encoding
ByteBuffer bb = ByteBuffer.allocate( etypeInfo2.computeLength() );
-
+
try
{
bb = etypeInfo2.encode( bb );
-
+
// Check the length
assertEquals( 0x20, bb.limit() );
-
- String encodedPdu = Strings.dumpBytes(bb.array());
-
+
+ String encodedPdu = Strings.dumpBytes( bb.array() );
+
assertEquals( encodedPdu, decodedPdu );
}
catch ( EncoderException ee )
@@ -125,18 +144,18 @@ public class ETypeInfo2DecoderTest
fail();
}
}
-
-
+
+
/**
* Test the decoding of a ETypeInfo2 with nothing in it
*/
- @Test( expected = DecoderException.class)
+ @Test(expected = DecoderException.class)
public void testETypeInfo2Empty() throws DecoderException
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x02 );
-
+
stream.put( new byte[]
{ 0x30, 0x00 } );
@@ -149,23 +168,23 @@ public class ETypeInfo2DecoderTest
kerberosDecoder.decode( stream, etypeInfo2Container );
fail();
}
-
-
+
+
/**
* Test the decoding of a ETypeInfo2 with empty ETypeInfo2Entry in it
*/
- @Test( expected = DecoderException.class)
+ @Test(expected = DecoderException.class)
public void testETypeInfo2NoETypeInfo2Entry() throws DecoderException
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x04 );
-
+
stream.put( new byte[]
- {
- 0x30, 0x02,
- (byte)0x30, 0x00 // empty ETypeInfo2Entry
- } );
+ {
+ 0x30, 0x02,
+ ( byte ) 0x30, 0x00 // empty ETypeInfo2Entry
+ } );
stream.flip();