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 [22/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/TgsReqDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/TgsReqDecoderTest.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/TgsReqDecoderTest.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/TgsReqDecoderTest.java Tue Jan 24 16:15:05 2012
@@ -55,142 +55,142 @@ public class TgsReqDecoderTest
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x193 );
-
+
stream.put( new byte[]
- {
- 0x6C, (byte)0x82, 0x01, (byte)0x8F,
- 0x30, (byte)0x82, 0x01, (byte)0x8B,
- (byte)0xA1, 0x03,
+ {
+ 0x6C, ( 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 TgsReq Container
TgsReqContainer tgsReqContainer = new TgsReqContainer( stream );
-
+
// Decode the TgsReq PDU
try
{
@@ -202,22 +202,22 @@ public class TgsReqDecoderTest
}
TgsReq tgsReq = tgsReqContainer.getTgsReq();
-
+
assertTrue( tgsReq instanceof TgsReq );
-
+
// Check the encoding
int length = tgsReq.computeLength();
// Check the length
assertEquals( 0x193, length );
-
+
// Check the encoding
ByteBuffer encodedPdu = ByteBuffer.allocate( length );
-
+
try
{
encodedPdu = tgsReq.encode( encodedPdu );
-
+
// Check the length
assertEquals( 0x193, encodedPdu.limit() );
}
@@ -226,169 +226,169 @@ public class TgsReqDecoderTest
fail();
}
}
-
-
+
+
/**
* Test the decoding of a TgsReq message with a bad MsgType
*/
- @Test( expected = DecoderException.class)
+ @Test(expected = DecoderException.class)
public void testDecodeFullTgsReqBadMsgType() throws Exception
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x193 );
-
+
stream.put( new byte[]
- {
- 0x6C, (byte)0x82, 0x01, (byte)0x8F,
- 0x30, (byte)0x82, 0x01, (byte)0x8B,
- (byte)0xA1, 0x03,
+ {
+ 0x6C, ( 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, 0x0A,
- (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, 0x0A,
+ ( 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 TgsReq Container
TgsReqContainer tgsReqContainer = new TgsReqContainer( stream );
-
+
// Decode the TgsReq PDU
kerberosDecoder.decode( stream, tgsReqContainer );
fail();
}
-
-
+
+
/**
* Test the decoding of a TGS-REQ with nothing in it
*/
- @Test( expected = DecoderException.class)
+ @Test(expected = DecoderException.class)
public void testTgsReqEmpty() throws DecoderException
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x02 );
-
+
stream.put( new byte[]
{ 0x6C, 0x00 } );
Modified: directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/TicketDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/TicketDecoderTest.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/TicketDecoderTest.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/TicketDecoderTest.java Tue Jan 24 16:15:05 2012
@@ -61,33 +61,80 @@ public class TicketDecoderTest
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x46 );
-
+
stream.put( new byte[]
- { 0x61, 0x44, // Ticket
- 0x30, 0x42,
- (byte)0xA0, 0x03, // tkt-vno
- 0x02, 0x01, 0x05,
- (byte)0xA1, 0x0D, // realm
- 0x1B, 0x0B, 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
- (byte)0xA2, 0x14, // sname
- 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)0xA3, 0x16, // enc-part
- 0x030, 0x14,
- (byte)0xA0, 0x03, // etype
- 0x02, 0x01, 0x12,
- (byte)0xA1, 0x03, // kvno
- 0x02, 0x01, 0x05,
- (byte)0xA2, 0x08, // cipher
- 0x04, 0x06,
- 'a', 'b', 'c', 'd', 'e', 'f'
- } );
+ { 0x61, 0x44, // Ticket
+ 0x30,
+ 0x42,
+ ( byte ) 0xA0,
+ 0x03, // tkt-vno
+ 0x02,
+ 0x01,
+ 0x05,
+ ( byte ) 0xA1,
+ 0x0D, // realm
+ 0x1B,
+ 0x0B,
+ 'E',
+ 'X',
+ 'A',
+ 'M',
+ 'P',
+ 'L',
+ 'E',
+ '.',
+ 'C',
+ 'O',
+ 'M',
+ ( byte ) 0xA2,
+ 0x14, // sname
+ 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 ) 0xA3,
+ 0x16, // enc-part
+ 0x030,
+ 0x14,
+ ( byte ) 0xA0,
+ 0x03, // etype
+ 0x02,
+ 0x01,
+ 0x12,
+ ( byte ) 0xA1,
+ 0x03, // kvno
+ 0x02,
+ 0x01,
+ 0x05,
+ ( byte ) 0xA2,
+ 0x08, // cipher
+ 0x04,
+ 0x06,
+ 'a',
+ 'b',
+ 'c',
+ 'd',
+ 'e',
+ 'f'
+ } );
- String decodedPdu = Strings.dumpBytes(stream.array());
+ String decodedPdu = Strings.dumpBytes( stream.array() );
stream.flip();
// Allocate a Ticket Container
@@ -104,23 +151,23 @@ public class TicketDecoderTest
}
// Check the decoded BindRequest
- Ticket ticket = ( ( TicketContainer ) ticketContainer).getTicket();
+ Ticket ticket = ( ( TicketContainer ) ticketContainer ).getTicket();
assertEquals( 5, ticket.getTktVno() );
assertEquals( "EXAMPLE.COM", ticket.getRealm() );
-
+
PrincipalName principalName = ticket.getSName();
assertNotNull( principalName );
assertEquals( PrincipalNameType.KRB_NT_PRINCIPAL, principalName.getNameType() );
assertTrue( principalName.getNames().contains( "hnelson" ) );
-
+
EncryptedData encryptedData = ticket.getEncPart();
-
+
assertNotNull( encryptedData );
assertEquals( EncryptionType.AES256_CTS_HMAC_SHA1_96, encryptedData.getEType() );
assertEquals( 5, encryptedData.getKvno() );
- assertTrue( Arrays.equals( Strings.getBytesUtf8("abcdef"), encryptedData.getCipher() ) );
+ assertTrue( Arrays.equals( Strings.getBytesUtf8( "abcdef" ), encryptedData.getCipher() ) );
// Check the encoding
try
@@ -130,7 +177,7 @@ public class TicketDecoderTest
// Check the length
assertEquals( 0x46, bb.limit() );
- String encodedPdu = Strings.dumpBytes(bb.array());
+ String encodedPdu = Strings.dumpBytes( bb.array() );
assertEquals( encodedPdu, decodedPdu );
}
@@ -145,15 +192,15 @@ public class TicketDecoderTest
/**
* Test the decoding of an empty Ticket message
*/
- @Test( expected=DecoderException.class)
+ @Test(expected = DecoderException.class)
public void testDecodeTicketEmpty() throws Exception
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x02 );
-
+
stream.put( new byte[]
- { 0x61, 0x00 });
+ { 0x61, 0x00 } );
stream.flip();
@@ -168,18 +215,18 @@ public class TicketDecoderTest
/**
* Test the decoding of an empty Ticket sequence
*/
- @Test( expected=DecoderException.class)
+ @Test(expected = DecoderException.class)
public void testDecodeTicketEmptySEQ() throws Exception
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x04 );
-
+
stream.put( new byte[]
- {
+ {
0x61, 0x02,
- 0x30, 0x00
- });
+ 0x30, 0x00
+ } );
stream.flip();
@@ -194,19 +241,19 @@ public class TicketDecoderTest
/**
* Test the decoding of an empty tktvno tag
*/
- @Test( expected=DecoderException.class)
+ @Test(expected = DecoderException.class)
public void testDecodeTicketEmptyTktVnoTag() throws Exception
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x06 );
-
+
stream.put( new byte[]
- {
+ {
0x61, 0x04,
- 0x30, 0x02,
- (byte)0xA0, 0x00
- });
+ 0x30, 0x02,
+ ( byte ) 0xA0, 0x00
+ } );
stream.flip();
@@ -221,20 +268,20 @@ public class TicketDecoderTest
/**
* Test the decoding of an empty tktvno value
*/
- @Test( expected=DecoderException.class)
+ @Test(expected = DecoderException.class)
public void testDecodeTicketEmptyTktVnoValue() throws Exception
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x08 );
-
+
stream.put( new byte[]
- {
+ {
0x61, 0x06,
- 0x30, 0x04,
- (byte)0xA0, 0x02,
- 0x02, 0x00
- });
+ 0x30, 0x04,
+ ( byte ) 0xA0, 0x02,
+ 0x02, 0x00
+ } );
stream.flip();
@@ -249,20 +296,20 @@ public class TicketDecoderTest
/**
* Test the decoding of an bad tktvno value
*/
- @Test( expected=DecoderException.class)
+ @Test(expected = DecoderException.class)
public void testDecodeTicketBadTktVnoValue() throws Exception
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x09 );
-
+
stream.put( new byte[]
- {
+ {
0x61, 0x07,
- 0x30, 0x05,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x02
- });
+ 0x30, 0x05,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x02
+ } );
stream.flip();
@@ -277,20 +324,20 @@ public class TicketDecoderTest
/**
* Test the decoding of a ticket with no realm
*/
- @Test( expected=DecoderException.class)
+ @Test(expected = DecoderException.class)
public void testDecodeTicketNoRealm() throws Exception
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x09 );
-
+
stream.put( new byte[]
- {
+ {
0x61, 0x07,
- 0x30, 0x05,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x05
- });
+ 0x30, 0x05,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x05
+ } );
stream.flip();
@@ -305,21 +352,21 @@ public class TicketDecoderTest
/**
* Test the decoding of an empty realm tag
*/
- @Test( expected=DecoderException.class)
+ @Test(expected = DecoderException.class)
public void testDecodeTicketEmptyRealmTag() throws Exception
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x0B );
-
+
stream.put( new byte[]
- {
+ {
0x61, 0x09,
- 0x30, 0x07,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x05,
- (byte)0xA1, 0x00
- });
+ 0x30, 0x07,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x05,
+ ( byte ) 0xA1, 0x00
+ } );
stream.flip();
@@ -334,22 +381,22 @@ public class TicketDecoderTest
/**
* Test the decoding of an empty realm value
*/
- @Test( expected=DecoderException.class)
+ @Test(expected = DecoderException.class)
public void testDecodeTicketEmptyRealmValue() throws Exception
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x0D );
-
+
stream.put( new byte[]
- {
+ {
0x61, 0x0B,
- 0x30, 0x09,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x05,
- (byte)0xA1, 0x02,
- 0x1B, 0x00
- });
+ 0x30, 0x09,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x05,
+ ( byte ) 0xA1, 0x02,
+ 0x1B, 0x00
+ } );
stream.flip();
@@ -364,22 +411,22 @@ public class TicketDecoderTest
/**
* Test the decoding of a ticket with no sname
*/
- @Test( expected=DecoderException.class)
+ @Test(expected = DecoderException.class)
public void testDecodeTicketNoSname() throws Exception
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x18 );
-
+
stream.put( new byte[]
- {
+ {
0x61, 0x16,
- 0x30, 0x14,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x05,
- (byte)0xA1, 0x0D,
- 0x1B, 0x0B, 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
- });
+ 0x30, 0x14,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x05,
+ ( byte ) 0xA1, 0x0D,
+ 0x1B, 0x0B, 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
+ } );
stream.flip();
@@ -394,23 +441,23 @@ public class TicketDecoderTest
/**
* Test the decoding of a ticket with an empty sname tag
*/
- @Test( expected=DecoderException.class)
+ @Test(expected = DecoderException.class)
public void testDecodeTicketEmptySnameTag() throws Exception
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x1A );
-
+
stream.put( new byte[]
- {
+ {
0x61, 0x18,
- 0x30, 0x16,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x05,
- (byte)0xA1, 0x0D,
- 0x1B, 0x0B, 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
- (byte)0xA2, 0x00
- });
+ 0x30, 0x16,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x05,
+ ( byte ) 0xA1, 0x0D,
+ 0x1B, 0x0B, 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
+ ( byte ) 0xA2, 0x00
+ } );
stream.flip();
@@ -425,24 +472,24 @@ public class TicketDecoderTest
/**
* Test the decoding of a ticket with an empty sname value
*/
- @Test( expected=DecoderException.class)
+ @Test(expected = DecoderException.class)
public void testDecodeTicketEmptySnameValue() throws Exception
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x1C );
-
+
stream.put( new byte[]
- {
+ {
0x61, 0x1A,
- 0x30, 0x18,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x05,
- (byte)0xA1, 0x0D,
- 0x1B, 0x0B, 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
- (byte)0xA2, 0x02,
- 0x30, 0x00
- });
+ 0x30, 0x18,
+ ( byte ) 0xA0, 0x03,
+ 0x02, 0x01, 0x05,
+ ( byte ) 0xA1, 0x0D,
+ 0x1B, 0x0B, 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
+ ( byte ) 0xA2, 0x02,
+ 0x30, 0x00
+ } );
stream.flip();
@@ -457,26 +504,47 @@ public class TicketDecoderTest
/**
* Test the decoding of a ticket with a bad principalName
*/
- @Test( expected=DecoderException.class)
+ @Test(expected = DecoderException.class)
public void testDecodeTicketBadSName() throws Exception
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x20 );
-
+
stream.put( new byte[]
- {
- 0x61, 0x1E, // Ticket
- 0x30, 0x1C,
- (byte)0xA0, 0x03, // tkt-vno
- 0x02, 0x01, 0x05,
- (byte)0xA1, 0x0D, // realm
- 0x1B, 0x0B, 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
- (byte)0xA2, 0x06, // sname
- 0x30, 0x04,
- (byte)0xA0, 0x02, // name-type
- 0x02, 0x00
- });
+ {
+ 0x61, 0x1E, // Ticket
+ 0x30,
+ 0x1C,
+ ( byte ) 0xA0,
+ 0x03, // tkt-vno
+ 0x02,
+ 0x01,
+ 0x05,
+ ( byte ) 0xA1,
+ 0x0D, // realm
+ 0x1B,
+ 0x0B,
+ 'E',
+ 'X',
+ 'A',
+ 'M',
+ 'P',
+ 'L',
+ 'E',
+ '.',
+ 'C',
+ 'O',
+ 'M',
+ ( byte ) 0xA2,
+ 0x06, // sname
+ 0x30,
+ 0x04,
+ ( byte ) 0xA0,
+ 0x02, // name-type
+ 0x02,
+ 0x00
+ } );
stream.flip();
@@ -491,29 +559,61 @@ public class TicketDecoderTest
/**
* Test the decoding of a ticket with no enc-part
*/
- @Test( expected=DecoderException.class)
+ @Test(expected = DecoderException.class)
public void testDecodeTicketNoEncPart() throws Exception
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x2E );
-
+
stream.put( new byte[]
- {
- 0x61, 0x2C, // Ticket
- 0x30, 0x2A,
- (byte)0xA0, 0x03, // tkt-vno
- 0x02, 0x01, 0x05,
- (byte)0xA1, 0x0D, // realm
- 0x1B, 0x0B, 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
- (byte)0xA2, 0x14, // sname
- 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',
- });
+ {
+ 0x61, 0x2C, // Ticket
+ 0x30,
+ 0x2A,
+ ( byte ) 0xA0,
+ 0x03, // tkt-vno
+ 0x02,
+ 0x01,
+ 0x05,
+ ( byte ) 0xA1,
+ 0x0D, // realm
+ 0x1B,
+ 0x0B,
+ 'E',
+ 'X',
+ 'A',
+ 'M',
+ 'P',
+ 'L',
+ 'E',
+ '.',
+ 'C',
+ 'O',
+ 'M',
+ ( byte ) 0xA2,
+ 0x14, // sname
+ 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',
+ } );
stream.flip();
@@ -528,30 +628,63 @@ public class TicketDecoderTest
/**
* Test the decoding of a ticket with an empty enc-part tag
*/
- @Test(expected=DecoderException.class)
+ @Test(expected = DecoderException.class)
public void testDecodeTicketEmptyEncPartTag() throws Exception
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x30 );
-
+
stream.put( new byte[]
- {
- 0x61, 0x2E, // Ticket
- 0x30, 0x2C,
- (byte)0xA0, 0x03, // tkt-vno
- 0x02, 0x01, 0x05,
- (byte)0xA1, 0x0D, // realm
- 0x1B, 0x0B, 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
- (byte)0xA2, 0x14, // sname
- 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)0xA3, 0x00
- });
+ {
+ 0x61, 0x2E, // Ticket
+ 0x30,
+ 0x2C,
+ ( byte ) 0xA0,
+ 0x03, // tkt-vno
+ 0x02,
+ 0x01,
+ 0x05,
+ ( byte ) 0xA1,
+ 0x0D, // realm
+ 0x1B,
+ 0x0B,
+ 'E',
+ 'X',
+ 'A',
+ 'M',
+ 'P',
+ 'L',
+ 'E',
+ '.',
+ 'C',
+ 'O',
+ 'M',
+ ( byte ) 0xA2,
+ 0x14, // sname
+ 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 ) 0xA3,
+ 0x00
+ } );
stream.flip();
@@ -566,31 +699,65 @@ public class TicketDecoderTest
/**
* Test the decoding of a ticket with an empty enc-part
*/
- @Test(expected=DecoderException.class)
+ @Test(expected = DecoderException.class)
public void testDecodeTicketEmptyEncPart() throws Exception
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x32 );
-
+
stream.put( new byte[]
- {
- 0x61, 0x30, // Ticket
- 0x30, 0x2E,
- (byte)0xA0, 0x03, // tkt-vno
- 0x02, 0x01, 0x05,
- (byte)0xA1, 0x0D, // realm
- 0x1B, 0x0B, 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
- (byte)0xA2, 0x14, // sname
- 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)0xA3, 0x02,
- 0x30, 0x00
- });
+ {
+ 0x61, 0x30, // Ticket
+ 0x30,
+ 0x2E,
+ ( byte ) 0xA0,
+ 0x03, // tkt-vno
+ 0x02,
+ 0x01,
+ 0x05,
+ ( byte ) 0xA1,
+ 0x0D, // realm
+ 0x1B,
+ 0x0B,
+ 'E',
+ 'X',
+ 'A',
+ 'M',
+ 'P',
+ 'L',
+ 'E',
+ '.',
+ 'C',
+ 'O',
+ 'M',
+ ( byte ) 0xA2,
+ 0x14, // sname
+ 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 ) 0xA3,
+ 0x02,
+ 0x30,
+ 0x00
+ } );
stream.flip();
@@ -605,32 +772,67 @@ public class TicketDecoderTest
/**
* Test the decoding of a ticket with a bad enc-part
*/
- @Test(expected=DecoderException.class)
+ @Test(expected = DecoderException.class)
public void testDecodeTicketBadEncPart() throws Exception
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x34 );
-
+
stream.put( new byte[]
- {
- 0x61, 0x32, // Ticket
- 0x30, 0x30,
- (byte)0xA0, 0x03, // tkt-vno
- 0x02, 0x01, 0x05,
- (byte)0xA1, 0x0D, // realm
- 0x1B, 0x0B, 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
- (byte)0xA2, 0x14, // sname
- 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)0xA3, 0x04,
- 0x30, 0x02,
- 0x01, 0x02
- });
+ {
+ 0x61, 0x32, // Ticket
+ 0x30,
+ 0x30,
+ ( byte ) 0xA0,
+ 0x03, // tkt-vno
+ 0x02,
+ 0x01,
+ 0x05,
+ ( byte ) 0xA1,
+ 0x0D, // realm
+ 0x1B,
+ 0x0B,
+ 'E',
+ 'X',
+ 'A',
+ 'M',
+ 'P',
+ 'L',
+ 'E',
+ '.',
+ 'C',
+ 'O',
+ 'M',
+ ( byte ) 0xA2,
+ 0x14, // sname
+ 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 ) 0xA3,
+ 0x04,
+ 0x30,
+ 0x02,
+ 0x01,
+ 0x02
+ } );
stream.flip();
Modified: directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/TransitedEncodingDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/TransitedEncodingDecoderTest.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/TransitedEncodingDecoderTest.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/TransitedEncodingDecoderTest.java Tue Jan 24 16:15:05 2012
@@ -60,16 +60,26 @@ public class TransitedEncodingDecoderTes
int len = 0x11;
ByteBuffer stream = ByteBuffer.allocate( len );
-
+
stream.put( new byte[]
{ 0x30, 0x0F,
- (byte)0xA0, 0x03, // tr-type
- 0x02, 0x01, 0x01, //
- (byte)0xA1, 0x08, // contents
- 0x04, 0x06, 'a', 'b', 'c', 'd', 'e', 'f'
- } );
+ ( byte ) 0xA0, 0x03, // tr-type
+ 0x02,
+ 0x01,
+ 0x01, //
+ ( byte ) 0xA1,
+ 0x08, // contents
+ 0x04,
+ 0x06,
+ 'a',
+ 'b',
+ 'c',
+ 'd',
+ 'e',
+ 'f'
+ } );
- String decodedPdu = Strings.dumpBytes(stream.array());
+ String decodedPdu = Strings.dumpBytes( stream.array() );
stream.flip();
// Allocate a TransitedEncoding Container
@@ -86,23 +96,24 @@ public class TransitedEncodingDecoderTes
}
// Check the decoded TransitedEncoding
- TransitedEncoding transitedEncoding = ( ( TransitedEncodingContainer ) transitedEncodingContainer ).getTransitedEncoding();
+ TransitedEncoding transitedEncoding = ( ( TransitedEncodingContainer ) transitedEncodingContainer )
+ .getTransitedEncoding();
assertEquals( TransitedEncodingType.DOMAIN_X500_COMPRESS, transitedEncoding.getTrType() );
- assertTrue( Arrays.equals( Strings.getBytesUtf8("abcdef"), transitedEncoding.getContents() ) );
+ assertTrue( Arrays.equals( Strings.getBytesUtf8( "abcdef" ), transitedEncoding.getContents() ) );
// Check the encoding
ByteBuffer bb = ByteBuffer.allocate( transitedEncoding.computeLength() );
-
+
try
{
bb = transitedEncoding.encode( bb );
-
+
// Check the length
assertEquals( len, bb.limit() );
-
- String encodedPdu = Strings.dumpBytes(bb.array());
-
+
+ String encodedPdu = Strings.dumpBytes( bb.array() );
+
assertEquals( encodedPdu, decodedPdu );
}
catch ( EncoderException ee )
@@ -110,18 +121,18 @@ public class TransitedEncodingDecoderTes
fail();
}
}
-
-
+
+
/**
* Test the decoding of a TransitedEncoding with nothing in it
*/
- @Test( expected = DecoderException.class)
+ @Test(expected = DecoderException.class)
public void testTransitedEncodingEmpty() throws DecoderException
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x02 );
-
+
stream.put( new byte[]
{ 0x30, 0x00 } );
@@ -134,22 +145,22 @@ public class TransitedEncodingDecoderTes
kerberosDecoder.decode( stream, transitedEncodingContainer );
fail();
}
-
-
+
+
/**
* Test the decoding of a TransitedEncoding with an empty tr-type tag
*/
- @Test( expected = DecoderException.class)
+ @Test(expected = DecoderException.class)
public void testTransitedEncodingEmptyTrTypeTag() throws DecoderException
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x04 );
-
+
stream.put( new byte[]
{ 0x30, 0x02,
- (byte)0xA0, 0x00 // tr-type
- } );
+ ( byte ) 0xA0, 0x00 // tr-type
+ } );
stream.flip();
@@ -160,23 +171,24 @@ public class TransitedEncodingDecoderTes
kerberosDecoder.decode( stream, transitedEncodingContainer );
fail();
}
-
-
+
+
/**
* Test the decoding of a TransitedEncoding with no type
*/
- @Test( expected = DecoderException.class)
+ @Test(expected = DecoderException.class)
public void testTransitedEncodingNoTrType() throws DecoderException
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x06 );
-
+
stream.put( new byte[]
{ 0x30, 0x04,
- (byte)0xA0, 0x02, // tr-type
- 0x02, 0x00
- } );
+ ( byte ) 0xA0, 0x02, // tr-type
+ 0x02,
+ 0x00
+ } );
stream.flip();
@@ -187,23 +199,24 @@ public class TransitedEncodingDecoderTes
kerberosDecoder.decode( stream, transitedEncodingContainer );
fail();
}
-
-
+
+
/**
* Test the decoding of a TransitedEncoding with no tr-type tag
*/
- @Test( expected = DecoderException.class)
+ @Test(expected = DecoderException.class)
public void testTransitedEncodingNoTrTypeTag() throws DecoderException
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x06 );
-
+
stream.put( new byte[]
{ 0x30, 0x04,
- (byte)0xA1, 0x02, // contents
- 0x04, 0x00
- } );
+ ( byte ) 0xA1, 0x02, // contents
+ 0x04,
+ 0x00
+ } );
stream.flip();
@@ -214,24 +227,27 @@ public class TransitedEncodingDecoderTes
kerberosDecoder.decode( stream, transitedEncodingContainer );
fail();
}
-
-
+
+
/**
* Test the decoding of a TransitedEncoding with an empty contents tag
*/
- @Test( expected = DecoderException.class)
+ @Test(expected = DecoderException.class)
public void testTransitedEncodingEmptyContentsTag() throws DecoderException
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x09 );
-
+
stream.put( new byte[]
{ 0x30, 0x07,
- (byte)0xA0, 0x03, // tr-type
- 0x02, 0x01, 0x01, //
- (byte)0xA1, 0x00 // contents
- } );
+ ( byte ) 0xA0, 0x03, // tr-type
+ 0x02,
+ 0x01,
+ 0x01, //
+ ( byte ) 0xA1,
+ 0x00 // contents
+ } );
stream.flip();
@@ -242,24 +258,29 @@ public class TransitedEncodingDecoderTes
kerberosDecoder.decode( stream, transitedEncodingContainer );
fail();
}
-
-
+
+
/**
* Test the decoding of a TransitedEncoding with something else than a contents
*/
- @Test( expected = DecoderException.class )
+ @Test(expected = DecoderException.class)
public void testTransitedEncodingBadTag() throws DecoderException
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x0C );
-
+
stream.put( new byte[]
{ 0x30, 0x0A,
- (byte)0xA0, 0x03, // tr-type
- 0x02, 0x01, 0x01, //
- (byte)0xA2, 0x03, // ???
- 0x02, 0x01, 0x01, //
+ ( byte ) 0xA0, 0x03, // tr-type
+ 0x02,
+ 0x01,
+ 0x01, //
+ ( byte ) 0xA2,
+ 0x03, // ???
+ 0x02,
+ 0x01,
+ 0x01, //
} );
stream.flip();
Modified: directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/TypedDataDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/TypedDataDecoderTest.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/TypedDataDecoderTest.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/TypedDataDecoderTest.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;
@@ -36,6 +37,7 @@ import org.apache.directory.shared.kerbe
import org.apache.directory.shared.util.Strings;
import org.junit.Test;
+
/**
* Test cases for TypedData decoder.
*
@@ -50,27 +52,46 @@ public class TypedDataDecoderTest
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x21 );
-
+
stream.put( new byte[]
- {
- 0x30, 0x1F,
+ {
+ 0x30, 0x1F,
0x30, 0x0F,
- (byte)0xA0, 0x03, // data-type
- 0x02, 0x01, 0x02,
- (byte)0xA1, 0x08, // data-value
- 0x04, 0x06, 'a', 'b', 'c', 'd', 'e', 'f',
- 0x30, 0x0C,
- (byte)0xA0, 0x03, // data-type
- 0x02, 0x01, 0x02,
- (byte)0xA1, 0x05, // data-value
- 0x04, 0x03, 'g', 'h', 'i'
- } );
+ ( byte ) 0xA0, 0x03, // data-type
+ 0x02,
+ 0x01,
+ 0x02,
+ ( byte ) 0xA1,
+ 0x08, // data-value
+ 0x04,
+ 0x06,
+ 'a',
+ 'b',
+ 'c',
+ 'd',
+ 'e',
+ 'f',
+ 0x30,
+ 0x0C,
+ ( byte ) 0xA0,
+ 0x03, // data-type
+ 0x02,
+ 0x01,
+ 0x02,
+ ( byte ) 0xA1,
+ 0x05, // data-value
+ 0x04,
+ 0x03,
+ 'g',
+ 'h',
+ 'i'
+ } );
- String decodedPdu = Strings.dumpBytes(stream.array());
+ String decodedPdu = Strings.dumpBytes( stream.array() );
stream.flip();
TypedDataContainer typedDataContainer = new TypedDataContainer();
-
+
// Decode the TypedData PDU
try
{
@@ -82,31 +103,32 @@ public class TypedDataDecoderTest
}
TypedData typedData = typedDataContainer.getTypedData();
-
+
assertNotNull( typedData.getTypedData().size() );
assertEquals( 2, typedData.getTypedData().size() );
-
- String[] expected = new String[]{ "abcdef", "ghi" };
+
+ String[] expected = new String[]
+ { "abcdef", "ghi" };
int i = 0;
-
+
for ( TypedData.TD td : typedData.getTypedData() )
{
assertEquals( 2, td.getDataType() );
- assertTrue( Arrays.equals( Strings.getBytesUtf8(expected[i++]), td.getDataValue() ) );
+ assertTrue( Arrays.equals( Strings.getBytesUtf8( expected[i++] ), td.getDataValue() ) );
}
// Check the encoding
ByteBuffer bb = ByteBuffer.allocate( typedData.computeLength() );
-
+
try
{
bb = typedData.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 )
@@ -114,127 +136,140 @@ public class TypedDataDecoderTest
fail();
}
}
-
-
- @Test( expected = DecoderException.class)
+
+
+ @Test(expected = DecoderException.class)
public void testTypedDataWithoutType() throws DecoderException
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x09 );
-
+
stream.put( new byte[]
{ 0x30, 0x7,
0x30, 0x5,
- (byte)0xA1, 0x03, // data-value
- 0x04, 0x01, 'a'
- } );
+ ( byte ) 0xA1, 0x03, // data-value
+ 0x04,
+ 0x01,
+ 'a'
+ } );
stream.flip();
TypedDataContainer typedDataContainer = new TypedDataContainer();
-
+
kerberosDecoder.decode( stream, typedDataContainer );
fail();
}
-
+
+
@Test
public void testTypedDataWithoutData() throws DecoderException
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x09 );
-
+
stream.put( new byte[]
{ 0x30, 0x7,
0x30, 0x05,
- (byte)0xA0, 0x03, // data-value
- 0x02, 0x01, 0x02
- } );
+ ( byte ) 0xA0, 0x03, // data-value
+ 0x02,
+ 0x01,
+ 0x02
+ } );
stream.flip();
TypedDataContainer typedDataContainer = new TypedDataContainer();
-
+
kerberosDecoder.decode( stream, typedDataContainer );
-
+
TypedData typedData = typedDataContainer.getTypedData();
-
+
assertNotNull( typedData.getTypedData() );
assertEquals( 1, typedData.getTypedData().size() );
assertEquals( 2, typedData.getCurrentTD().getDataType() );
}
-
- @Test( expected = DecoderException.class)
+
+ @Test(expected = DecoderException.class)
public void testTypedDataWithIncorrectPdu() throws DecoderException
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0x04 );
-
+
stream.put( new byte[]
{
- 0x30, 0x2,
- 0x30, 0x0
- } );
+ 0x30, 0x2,
+ 0x30, 0x0
+ } );
stream.flip();
TypedDataContainer typedDataContainer = new TypedDataContainer();
-
+
kerberosDecoder.decode( stream, typedDataContainer );
fail();
}
-
- @Test( expected = DecoderException.class)
+
+ @Test(expected = DecoderException.class)
public void testTypedDataWithEmptyData() throws DecoderException
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0xD );
-
+
stream.put( new byte[]
- {
- 0x30, 0x0B,
+ {
+ 0x30, 0x0B,
0x30, 0x09,
- (byte)0xA0, 0x03, // data-type
- 0x02, 0x01, 0x02,
- (byte)0xA1, 0x02, // data-value
- 0x04, 0x00
- } );
+ ( byte ) 0xA0, 0x03, // data-type
+ 0x02,
+ 0x01,
+ 0x02,
+ ( byte ) 0xA1,
+ 0x02, // data-value
+ 0x04,
+ 0x00
+ } );
stream.flip();
TypedDataContainer typedDataContainer = new TypedDataContainer();
-
+
kerberosDecoder.decode( stream, typedDataContainer );
fail();
}
-
- @Test( expected = DecoderException.class)
+
+ @Test(expected = DecoderException.class)
public void testTypedDataWithEmptyType() throws DecoderException
{
Asn1Decoder kerberosDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate( 0xD );
-
+
stream.put( new byte[]
- {
- 0x30, 0x0B,
+ {
+ 0x30, 0x0B,
0x30, 0x09,
- (byte)0xA0, 0x02, // data-type
- 0x02, 0x00,
- (byte)0xA1, 0x03, // data-value
- 0x04, 0x01, 0x02
- } );
+ ( byte ) 0xA0, 0x02, // data-type
+ 0x02,
+ 0x00,
+ ( byte ) 0xA1,
+ 0x03, // data-value
+ 0x04,
+ 0x01,
+ 0x02
+ } );
stream.flip();
TypedDataContainer typedDataContainer = new TypedDataContainer();
-
+
kerberosDecoder.decode( stream, typedDataContainer );
fail();
}
Modified: directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/flags/TicketFlagsTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/flags/TicketFlagsTest.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/flags/TicketFlagsTest.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/flags/TicketFlagsTest.java Tue Jan 24 16:15:05 2012
@@ -19,6 +19,7 @@
*/
package org.apache.directory.shared.kerberos.codec.flags;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -41,13 +42,13 @@ public class TicketFlagsTest
public void testTicketFlags()
{
TicketFlags flags = new TicketFlags();
-
+
assertFalse( flags.isForwardable() );
flags.setFlag( TicketFlag.FORWARDABLE );
-
+
assertTrue( flags.isForwardable() );
assertTrue( flags.toString().startsWith( TicketFlag.FORWARDABLE.toString() ) );
-
+
assertFalse( flags.isRenewable() );
flags.setFlag( TicketFlag.RENEWABLE );
assertTrue( flags.isRenewable() );
@@ -59,8 +60,9 @@ public class TicketFlagsTest
flags.clearFlag( TicketFlag.FORWARDABLE );
assertTrue( flags.isRenewable() );
assertFalse( flags.isForwardable() );
-
+
byte[] bytes = flags.getData();
- assertTrue( Arrays.equals( new byte[]{ 0x00, 0x00, (byte)0x80, 0x00, 0x00}, bytes ) );
+ assertTrue( Arrays.equals( new byte[]
+ { 0x00, 0x00, ( byte ) 0x80, 0x00, 0x00 }, bytes ) );
}
}
Modified: directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/options/OptionsTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/options/OptionsTest.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/options/OptionsTest.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/options/OptionsTest.java Tue Jan 24 16:15:05 2012
@@ -19,6 +19,7 @@
*/
package org.apache.directory.shared.kerberos.codec.options;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -26,6 +27,7 @@ import static org.junit.Assert.fail;
import org.junit.Test;
+
/**
* Test the Options class
*
@@ -42,13 +44,15 @@ public class OptionsTest
}
}
+
@Test
public void testAddBytes()
{
MyOptions myOptions = new MyOptions();
// Set the bits 10-0100 1010-1100 0000-0110
- myOptions.setBytes( new byte[]{ 0x02, (byte)0x92, (byte)0xB0, 0x18} );
+ myOptions.setBytes( new byte[]
+ { 0x02, ( byte ) 0x92, ( byte ) 0xB0, 0x18 } );
assertEquals( "1001001010110000000110", myOptions.toString() );
assertFalse( myOptions.get( 21 ) );
Modified: directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/AbstractKerberosITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/AbstractKerberosITest.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/AbstractKerberosITest.java (original)
+++ directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/AbstractKerberosITest.java Tue Jan 24 16:15:05 2012
@@ -113,18 +113,18 @@ public class AbstractKerberosITest exten
*/
protected void testObtainTickets( ObtainTicketParameters parameters ) throws Exception
{
- setupEnv(parameters);
+ setupEnv( parameters );
try
{
Subject subject = new Subject();
-
+
KerberosTestUtils.obtainTGT( subject, USER_UID, USER_PASSWORD );
-
+
assertEquals( 1, subject.getPrivateCredentials().size() );
assertEquals( 0, subject.getPublicCredentials().size() );
-
+
KerberosTestUtils.obtainServiceTickets( subject, USER_UID, LDAP_SERVICE_NAME, HOSTNAME );
-
+
assertEquals( 2, subject.getPrivateCredentials().size() );
assertEquals( 0, subject.getPublicCredentials().size() );
for ( KerberosTicket kt : subject.getPrivateCredentials( KerberosTicket.class ) )
@@ -158,12 +158,12 @@ public class AbstractKerberosITest exten
// Then set it to -1/1 to force UDP/TCP.
parameters.oldUdpPrefLimit = getUdpPrefLimit();
setUdpPrefLimit( parameters.transport == TcpTransport.class ? 1 : -1 );
-
+
// Save current value of sun.security.krb5.Checksum.CKSUMTYPE_DEFAULT field.
// Then set it to the required checksum value
parameters.oldCksumtypeDefault = getCksumtypeDefault();
setCksumtypeDefault( parameters.checksumType.getValue() );
-
+
// create krb5.conf with proper encryption type
String krb5confPath = createKrb5Conf( parameters.encryptionType );
System.setProperty( "java.security.krb5.conf", krb5confPath );
@@ -182,7 +182,8 @@ public class AbstractKerberosITest exten
createPrincipal( "uid=ldap", "Service", "LDAP Service",
"ldap", "randall", servicePrincipal );
}
-
+
+
protected void resetEnv( ObtainTicketParameters parameters )
throws Exception
{
@@ -190,6 +191,7 @@ public class AbstractKerberosITest exten
setCksumtypeDefault( parameters.oldCksumtypeDefault );
}
+
private static Integer getUdpPrefLimit() throws Exception
{
Field udpPrefLimitField = getUdpPrefLimitField();
@@ -210,10 +212,10 @@ public class AbstractKerberosITest exten
{
String clazz = "sun.security.krb5.KrbKdcReq";
Class<?> krbKdcReqClass = Class.forName( clazz );
-
+
// Absolutely ugly fix to get this method working with the latest JVM on Mac (1.6.0_29)
Field udpPrefLimitField = null;
-
+
try
{
udpPrefLimitField = krbKdcReqClass.getDeclaredField( "udpPrefLimit" );
@@ -222,27 +224,28 @@ public class AbstractKerberosITest exten
{
udpPrefLimitField = krbKdcReqClass.getDeclaredField( "defaultUdpPrefLimit" );
}
-
+
udpPrefLimitField.setAccessible( true );
return udpPrefLimitField;
}
-
+
+
private static Integer getCksumtypeDefault() throws Exception
{
Field cksumtypeDefaultField = getCksumtypeDefaultField();
Object value = cksumtypeDefaultField.get( null );
return ( Integer ) value;
}
-
-
+
+
private static void setCksumtypeDefault( int limit ) throws Exception
{
Field cksumtypeDefaultField = getCksumtypeDefaultField();
cksumtypeDefaultField.setAccessible( true );
cksumtypeDefaultField.set( null, limit );
}
-
-
+
+
private static Field getCksumtypeDefaultField() throws ClassNotFoundException, NoSuchFieldException
{
String clazz = "sun.security.krb5.Checksum";
@@ -252,6 +255,7 @@ public class AbstractKerberosITest exten
return cksumtypeDefaultField;
}
+
/**
* Creates the krb5.conf file for the test.
*
@@ -290,10 +294,10 @@ public class AbstractKerberosITest exten
data += "default_tkt_enctypes = " + encryptionType.getName() + SystemUtils.LINE_SEPARATOR;
data += "default_tgs_enctypes = " + encryptionType.getName() + SystemUtils.LINE_SEPARATOR;
data += "permitted_enctypes = " + encryptionType.getName() + SystemUtils.LINE_SEPARATOR;
-// data += "default_checksum = " + checksumType.getName() + SystemUtils.LINE_SEPARATOR;
-// data += "ap_req_checksum_type = " + checksumType.getName() + SystemUtils.LINE_SEPARATOR;
-// data += "checksum_type = " + checksumType.getName() + SystemUtils.LINE_SEPARATOR;
-
+ // data += "default_checksum = " + checksumType.getName() + SystemUtils.LINE_SEPARATOR;
+ // data += "ap_req_checksum_type = " + checksumType.getName() + SystemUtils.LINE_SEPARATOR;
+ // data += "checksum_type = " + checksumType.getName() + SystemUtils.LINE_SEPARATOR;
+
data += "[realms]" + SystemUtils.LINE_SEPARATOR;
data += REALM + " = {" + SystemUtils.LINE_SEPARATOR;
data += "kdc = " + HOSTNAME + ":" + kdcServer.getTransports()[0].getPort() + SystemUtils.LINE_SEPARATOR;
Modified: directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosTcpITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosTcpITest.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosTcpITest.java (original)
+++ directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosTcpITest.java Tue Jan 24 16:15:05 2012
@@ -52,25 +52,25 @@ Project</a>
@RunWith(FrameworkRunner.class)
@CreateDS(name = "KerberosTcpIT-class",
partitions =
- {
- @CreatePartition(
- name = "example",
- suffix = "dc=example,dc=com")
- },
- additionalInterceptors =
- {
- KeyDerivationInterceptor.class
- })
+ {
+ @CreatePartition(
+ name = "example",
+ suffix = "dc=example,dc=com")
+ },
+ additionalInterceptors =
+ {
+ KeyDerivationInterceptor.class
+ })
@CreateLdapServer(
transports =
- {
- @CreateTransport(protocol = "LDAP")
- })
+ {
+ @CreateTransport(protocol = "LDAP")
+ })
@CreateKdcServer(
transports =
- {
- @CreateTransport(protocol = "TCP")
- })
+ {
+ @CreateTransport(protocol = "TCP")
+ })
@ApplyLdifFiles("org/apache/directory/server/kerberos/kdc/KerberosIT.ldif")
public class KerberosTcpITest extends AbstractKerberosITest
{
Modified: directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosTestUtils.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosTestUtils.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosTestUtils.java (original)
+++ directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosTestUtils.java Tue Jan 24 16:15:05 2012
@@ -291,7 +291,7 @@ public class KerberosTestUtils
// Obtain TGT
LoginContext lc = new LoginContext( KerberosUdpITest.class.getName(), subject, new
- CallbackHandlerBean( userName, password ) );
+ CallbackHandlerBean( userName, password ) );
lc.login();
}
@@ -379,15 +379,15 @@ public class KerberosTestUtils
GSSManager manager = GSSManager.getInstance();
GSSName clientName = manager.createName( userName, GSSName.NT_USER_NAME );
GSSCredential clientCred = manager.createCredential( clientName,
- 8 * 3600,
- createKerberosOid(),
- GSSCredential.INITIATE_ONLY );
+ 8 * 3600,
+ createKerberosOid(),
+ GSSCredential.INITIATE_ONLY );
GSSName serverName = manager.createName( serviceName + "@" + hostName, GSSName.NT_HOSTBASED_SERVICE );
GSSContext context = manager.createContext( serverName,
- createKerberosOid(),
- clientCred,
- GSSContext.DEFAULT_LIFETIME );
+ createKerberosOid(),
+ clientCred,
+ GSSContext.DEFAULT_LIFETIME );
context.requestMutualAuth( true );
context.requestConf( true );
context.requestInteg( true );
Modified: directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosUdpITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosUdpITest.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosUdpITest.java (original)
+++ directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosUdpITest.java Tue Jan 24 16:15:05 2012
@@ -51,25 +51,25 @@ import org.junit.runner.RunWith;
@RunWith(FrameworkRunner.class)
@CreateDS(name = "KerberosUdpIT-class",
partitions =
- {
- @CreatePartition(
- name = "example",
- suffix = "dc=example,dc=com")
- },
- additionalInterceptors =
- {
- KeyDerivationInterceptor.class
- })
+ {
+ @CreatePartition(
+ name = "example",
+ suffix = "dc=example,dc=com")
+ },
+ additionalInterceptors =
+ {
+ KeyDerivationInterceptor.class
+ })
@CreateLdapServer(
transports =
- {
- @CreateTransport(protocol = "LDAP")
- })
+ {
+ @CreateTransport(protocol = "LDAP")
+ })
@CreateKdcServer(
transports =
- {
- @CreateTransport(protocol = "UDP")
- })
+ {
+ @CreateTransport(protocol = "UDP")
+ })
@ApplyLdifFiles("org/apache/directory/server/kerberos/kdc/KerberosIT.ldif")
public class KerberosUdpITest extends AbstractKerberosITest
{
@@ -82,7 +82,7 @@ public class KerberosUdpITest extends Ab
public void testObtainTickets_DES_CBC_MD5() throws Exception
{
// TODO: RFC3961, Section 6.2.1: des-cbc-md5 + rsa-md5-des
- ObtainTicketParameters parameters = new ObtainTicketParameters( UdpTransport.class,
+ ObtainTicketParameters parameters = new ObtainTicketParameters( UdpTransport.class,
EncryptionType.DES_CBC_MD5, ChecksumType.RSA_MD5 );
testObtainTickets( parameters );
}