directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r151128 - incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder
Date Thu, 03 Feb 2005 05:55:49 GMT
Author: erodriguez
Date: Wed Feb  2 21:55:46 2005
New Revision: 151128

URL: http://svn.apache.org/viewcvs?view=rev&rev=151128
Log:
Moved Kerberos decoders to use object composition.

Added:
    incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/ChecksumDecoder.java
    incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncryptionKeyDecoder.java
    incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncryptionTypeDecoder.java
    incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/HostAddressDecoder.java
    incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/KerberosTimeDecoder.java
    incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/LastRequestDecoder.java
    incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/PrincipalNameDecoder.java
    incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/TicketDecoder.java
Removed:
    incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/KerberosMessageDecoder.java
Modified:
    incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/ApplicationRequestDecoder.java
    incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/AuthenticatorDecoder.java
    incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/AuthorizationDataDecoder.java
    incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncKrbPrivPartDecoder.java
    incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncTicketPartDecoder.java
    incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncryptedDataDecoder.java
    incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncryptedTimestampDecoder.java
    incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/KdcRequestDecoder.java
    incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/PrivateMessageDecoder.java

Modified: incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/ApplicationRequestDecoder.java
URL: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/ApplicationRequestDecoder.java?view=diff&r1=151127&r2=151128
==============================================================================
--- incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/ApplicationRequestDecoder.java (original)
+++ incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/ApplicationRequestDecoder.java Wed Feb  2 21:55:46 2005
@@ -32,7 +32,7 @@
 import org.apache.kerberos.messages.value.ApOptions;
 
 
-public class ApplicationRequestDecoder extends KerberosMessageDecoder
+public class ApplicationRequestDecoder
 {
 	public ApplicationRequest decode( byte[] encodedAuthHeader ) throws IOException
 	{
@@ -80,17 +80,15 @@
 					break;
 				case 3:
 					DERApplicationSpecific tag3 = (DERApplicationSpecific)derObject;
-					authHeader.setTicket( decodeTicket( tag3 ) );
+					authHeader.setTicket( TicketDecoder.decode( tag3 ) );
 					break;
 				case 4:
 					DERSequence tag4 = (DERSequence)derObject;
-					authHeader.setEncPart( decodeEncryptedData( tag4 ) );
+					authHeader.setEncPart( EncryptedDataDecoder.decode( tag4 ) );
 					break;
-			    default:
-			    	System.out.println( derObject );
-			    	break;
 			}
 		}
+		
 		return authHeader;
 	}
 }

Modified: incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/AuthenticatorDecoder.java
URL: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/AuthenticatorDecoder.java?view=diff&r1=151127&r2=151128
==============================================================================
--- incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/AuthenticatorDecoder.java (original)
+++ incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/AuthenticatorDecoder.java Wed Feb  2 21:55:46 2005
@@ -32,7 +32,7 @@
 import org.apache.kerberos.messages.components.AuthenticatorModifier;
 
 
-public class AuthenticatorDecoder extends KerberosMessageDecoder
+public class AuthenticatorDecoder
 {
 	public Authenticator decode( byte[] encodedAuthenticator ) throws IOException
 	{
@@ -42,7 +42,7 @@
 		
 		DERSequence sequence = (DERSequence) app.getObject();
 		
-		return decodeAuthenticator( sequence );
+		return decode( sequence );
 	}
 	
 	/**
@@ -61,7 +61,7 @@
 	 *                authorization-data[8]         AuthorizationData OPTIONAL
 	 * }
 	 */
-	private Authenticator decodeAuthenticator( DERSequence sequence )
+	protected static Authenticator decode( DERSequence sequence )
 	{
 		AuthenticatorModifier modifier = new AuthenticatorModifier();
 		
@@ -83,11 +83,11 @@
 					break;
 				case 2:
 					DERSequence tag2 = (DERSequence)derObject;
-					modifier.setClientName( decodePrincipalName( tag2 ) );
+					modifier.setClientName( PrincipalNameDecoder.decode( tag2 ) );
 					break;
 				case 3:
 					DERSequence tag3 = (DERSequence)derObject;
-					modifier.setChecksum( decodeChecksum( tag3 ) );
+					modifier.setChecksum( ChecksumDecoder.decode( tag3 ) );
 					break;
 				case 4:
 					DERInteger tag4 = (DERInteger)derObject;
@@ -95,11 +95,11 @@
 					break;
 				case 5:
 					DERGeneralizedTime tag5 = (DERGeneralizedTime)derObject;
-					modifier.setClientTime( decodeKerberosTime( tag5 ) );
+					modifier.setClientTime( KerberosTimeDecoder.decode( tag5 ) );
 					break;
 				case 6:
 					DERSequence tag6 = (DERSequence) derObject;
-					modifier.setSubSessionKey( decodeEncryptionKey( tag6 ) );
+					modifier.setSubSessionKey( EncryptionKeyDecoder.decode( tag6 ) );
 					break;
 				case 7:
 					DERInteger tag7 = (DERInteger)derObject;
@@ -107,11 +107,8 @@
 					break;
 				case 8:
 					DERSequence tag8 = (DERSequence)derObject;
-					modifier.setAuthorizationData( decodeAuthorizationData( tag8 ) );
+					modifier.setAuthorizationData( AuthorizationDataDecoder.decodeSequence( tag8 ) );
 					break;
-			    default:
-			    	System.out.println( derObject );
-			    	break;
 			}
 		}
 		

Modified: incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/AuthorizationDataDecoder.java
URL: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/AuthorizationDataDecoder.java?view=diff&r1=151127&r2=151128
==============================================================================
--- incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/AuthorizationDataDecoder.java (original)
+++ incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/AuthorizationDataDecoder.java Wed Feb  2 21:55:46 2005
@@ -18,13 +18,20 @@
 package org.apache.kerberos.io.decoder;
 
 import java.io.IOException;
+import java.util.Enumeration;
 
 import org.apache.asn1.der.ASN1InputStream;
+import org.apache.asn1.der.DEREncodable;
+import org.apache.asn1.der.DERInteger;
+import org.apache.asn1.der.DEROctetString;
 import org.apache.asn1.der.DERSequence;
+import org.apache.asn1.der.DERTaggedObject;
 import org.apache.kerberos.messages.value.AuthorizationData;
+import org.apache.kerberos.messages.value.AuthorizationDataEntry;
+import org.apache.kerberos.messages.value.AuthorizationType;
 
 
-public class AuthorizationDataDecoder extends KerberosMessageDecoder
+public class AuthorizationDataDecoder
 {
 	public AuthorizationData decode( byte[] encodedAuthData ) throws IOException
 	{
@@ -32,7 +39,54 @@
 
 		DERSequence sequence = (DERSequence) ais.readObject();
 		
-		return decodeAuthorizationData( sequence );
+		return decodeSequence( sequence );
+	}
+	
+	/**
+	 * AuthorizationData ::=   SEQUENCE OF SEQUENCE {
+     *     ad-type[0]               INTEGER,
+     *     ad-data[1]               OCTET STRING
+     * }
+     */
+	protected static AuthorizationData decodeSequence( DERSequence sequence )
+	{
+		AuthorizationData authData = new AuthorizationData();
+		
+		for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+		{
+			DERSequence object = (DERSequence) e.nextElement();
+			AuthorizationDataEntry entry = decodeAuthorizationEntry( object );
+			authData.add( entry );
+		}
+		
+		return authData;
+	}
+	
+	protected static AuthorizationDataEntry decodeAuthorizationEntry( DERSequence sequence )
+	{
+		AuthorizationType type = AuthorizationType.NULL;
+		byte[] data = null;
+		
+		for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+		{
+			DERTaggedObject object = (DERTaggedObject) e.nextElement();
+			int tag = object.getTagNo();
+			DEREncodable derObject = object.getObject();
+			
+			switch ( tag )
+			{
+				case 0:
+					DERInteger tag0 = (DERInteger)derObject;
+					type = AuthorizationType.getTypeByOrdinal( tag0.intValue() );
+					break;
+				case 1:
+					DEROctetString tag1 = (DEROctetString)derObject;
+					data = tag1.getOctets();
+					break;
+			}
+		}
+		
+		return new AuthorizationDataEntry( type, data );
 	}
 }
 

Added: incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/ChecksumDecoder.java
URL: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/ChecksumDecoder.java?view=auto&rev=151128
==============================================================================
--- incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/ChecksumDecoder.java (added)
+++ incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/ChecksumDecoder.java Wed Feb  2 21:55:46 2005
@@ -0,0 +1,66 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+
+package org.apache.kerberos.io.decoder;
+
+import java.util.Enumeration;
+
+import org.apache.asn1.der.DEREncodable;
+import org.apache.asn1.der.DERInteger;
+import org.apache.asn1.der.DEROctetString;
+import org.apache.asn1.der.DERSequence;
+import org.apache.asn1.der.DERTaggedObject;
+import org.apache.kerberos.crypto.checksum.ChecksumType;
+import org.apache.kerberos.messages.value.Checksum;
+
+
+public class ChecksumDecoder
+{
+	/**
+	 * Checksum ::=   SEQUENCE {
+     *          cksumtype[0]   INTEGER,
+     *          checksum[1]    OCTET STRING
+     * }
+	 */
+	protected static Checksum decode( DERSequence sequence )
+	{
+		ChecksumType type = ChecksumType.NULL;
+		byte[] data = null;
+		
+		for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+		{
+			DERTaggedObject object = (DERTaggedObject) e.nextElement();
+			int tag = object.getTagNo();
+			DEREncodable derObject = object.getObject();
+			
+			switch ( tag )
+			{
+				case 0:
+					DERInteger tag0 = (DERInteger)derObject;
+					type = ChecksumType.getTypeByOrdinal( tag0.intValue() );
+					break;
+				case 1:
+					DEROctetString tag1 = (DEROctetString)derObject;
+					data = tag1.getOctets();
+					break;
+			}
+		}
+		
+		return new Checksum( type, data );
+	}
+}
+

Modified: incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncKrbPrivPartDecoder.java
URL: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncKrbPrivPartDecoder.java?view=diff&r1=151127&r2=151128
==============================================================================
--- incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncKrbPrivPartDecoder.java (original)
+++ incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncKrbPrivPartDecoder.java Wed Feb  2 21:55:46 2005
@@ -32,7 +32,7 @@
 import org.apache.kerberos.messages.components.EncKrbPrivPartModifier;
 
 
-public class EncKrbPrivPartDecoder extends KerberosMessageDecoder
+public class EncKrbPrivPartDecoder
 {
 	public EncKrbPrivPart decode( byte[] encodedPrivatePart ) throws IOException
 	{
@@ -62,7 +62,7 @@
 					break;
 				case 1:
 					DERGeneralizedTime tag1 = (DERGeneralizedTime) derObject;
-					modifier.setTimestamp( decodeKerberosTime( tag1 ) );
+					modifier.setTimestamp( KerberosTimeDecoder.decode( tag1 ) );
 					break;
 				case 2:
 					DERInteger tag2 = (DERInteger)derObject;
@@ -74,15 +74,12 @@
 					break;
 				case 4:
 					DERSequence tag4 = (DERSequence)derObject;
-					modifier.setSenderAddress( decodeHostAddress( tag4 ) );
+					modifier.setSenderAddress( HostAddressDecoder.decode( tag4 ) );
 					break;
 				case 5:
 					DERSequence tag5 = (DERSequence)derObject;
-					modifier.setRecipientAddress( decodeHostAddress( tag5 ) );
+					modifier.setRecipientAddress( HostAddressDecoder.decode( tag5 ) );
 					break;
-			    default:
-			    	System.out.println( derObject );
-			    	break;
 			}
 		}
 		return modifier.getEncKrbPrivPart();

Modified: incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncTicketPartDecoder.java
URL: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncTicketPartDecoder.java?view=diff&r1=151127&r2=151128
==============================================================================
--- incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncTicketPartDecoder.java (original)
+++ incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncTicketPartDecoder.java Wed Feb  2 21:55:46 2005
@@ -26,14 +26,18 @@
 import org.apache.asn1.der.DEREncodable;
 import org.apache.asn1.der.DERGeneralString;
 import org.apache.asn1.der.DERGeneralizedTime;
+import org.apache.asn1.der.DERInteger;
+import org.apache.asn1.der.DEROctetString;
 import org.apache.asn1.der.DERSequence;
 import org.apache.asn1.der.DERTaggedObject;
 import org.apache.kerberos.messages.components.EncTicketPart;
 import org.apache.kerberos.messages.components.EncTicketPartModifier;
 import org.apache.kerberos.messages.value.TicketFlags;
+import org.apache.kerberos.messages.value.TransitedEncoding;
+import org.apache.kerberos.messages.value.TransitedEncodingType;
 
 
-public class EncTicketPartDecoder extends KerberosMessageDecoder
+public class EncTicketPartDecoder
 {
 	public EncTicketPart decode( byte[] encodedTicket ) throws IOException
 	{
@@ -61,23 +65,25 @@
 	                      caddr[9]             HostAddresses OPTIONAL,
 	                      authorization-data[10]   AuthorizationData OPTIONAL
 	}*/
-	private EncTicketPart decodeEncTicketPartSequence( DERSequence sequence ) {
-		
+	private EncTicketPart decodeEncTicketPartSequence( DERSequence sequence )
+	{
 		EncTicketPartModifier modifier = new EncTicketPartModifier();
 		
-		for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); ) {
+		for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+		{
 			DERTaggedObject object = (DERTaggedObject) e.nextElement();
 			int tag = object.getTagNo();
 			DEREncodable derObject = object.getObject();
 			
-			switch ( tag ) {
+			switch ( tag )
+			{
 				case 0:
 					DERBitString tag0 = (DERBitString)derObject;
 					modifier.setFlags( new TicketFlags( tag0.getOctets() ) );
 					break;
 				case 1:
 					DERSequence tag1 = (DERSequence) derObject;
-					modifier.setSessionKey( decodeEncryptionKey( tag1 ) );
+					modifier.setSessionKey( EncryptionKeyDecoder.decode( tag1 ) );
 					break;
 				case 2:
 					DERGeneralString tag2 = (DERGeneralString)derObject;
@@ -85,7 +91,7 @@
 					break;
 				case 3:
 					DERSequence tag3 = (DERSequence)derObject;
-					modifier.setClientName( decodePrincipalName( tag3 ) );
+					modifier.setClientName( PrincipalNameDecoder.decode( tag3 ) );
 					break;
 				case 4:
 					DERSequence tag4 = (DERSequence)derObject;
@@ -93,34 +99,62 @@
 					break;
 				case 5:
 					DERGeneralizedTime tag5 = (DERGeneralizedTime)derObject;
-					modifier.setAuthTime( decodeKerberosTime( tag5 ) );
+					modifier.setAuthTime( KerberosTimeDecoder.decode( tag5 ) );
 					break;
 				case 6:
 					DERGeneralizedTime tag6 = (DERGeneralizedTime)derObject;
-					modifier.setStartTime( decodeKerberosTime( tag6 ) );
+					modifier.setStartTime( KerberosTimeDecoder.decode( tag6 ) );
 					break;
 				case 7:
 					DERGeneralizedTime tag7 = (DERGeneralizedTime)derObject;
-					modifier.setEndTime( decodeKerberosTime( tag7 ) );
+					modifier.setEndTime( KerberosTimeDecoder.decode( tag7 ) );
 					break;
 				case 8:
 					DERGeneralizedTime tag8 = (DERGeneralizedTime)derObject;
-					modifier.setRenewTill( decodeKerberosTime( tag8 ) );
+					modifier.setRenewTill( KerberosTimeDecoder.decode( tag8 ) );
 					break;
 				case 9:
 					DERSequence tag9 = (DERSequence)derObject;
-					modifier.setClientAddresses( decodeHostAddresses( tag9 ) );
+					modifier.setClientAddresses( HostAddressDecoder.decodeSequence( tag9 ) );
 					break;
 				case 10:
 					DERSequence tag10 = (DERSequence)derObject;
-					modifier.setAuthorizationData( decodeAuthorizationData( tag10 ) );
+					modifier.setAuthorizationData( AuthorizationDataDecoder.decodeSequence( tag10 ) );
 					break;
-			    default:
-			    	System.out.println( derObject );
-			    	break;
 			}
 		}
 		return modifier.getEncTicketPart();
+	}
+	
+	/*
+	 * TransitedEncoding ::= SEQUENCE { tr-type[0] INTEGER, -- must be
+	 * registered contents[1] OCTET STRING }
+	 */
+	protected TransitedEncoding decodeTransitedEncoding( DERSequence sequence )
+	{
+		TransitedEncodingType type = TransitedEncodingType.NULL;
+		byte[] contents = null;
+
+		for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+		{
+			DERTaggedObject object = (DERTaggedObject) e.nextElement();
+			int tag = object.getTagNo();
+			DEREncodable derObject = object.getObject();
+			
+			switch ( tag )
+			{
+				case 0:
+					DERInteger tag0 = (DERInteger) derObject;
+					type = TransitedEncodingType.getTypeByOrdinal( tag0.intValue() );
+					break;
+				case 1:
+					DEROctetString tag1 = (DEROctetString) derObject;
+					contents = tag1.getOctets();
+					break;
+			}
+		}
+		
+		return new TransitedEncoding( type, contents );
 	}
 }
 

Modified: incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncryptedDataDecoder.java
URL: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncryptedDataDecoder.java?view=diff&r1=151127&r2=151128
==============================================================================
--- incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncryptedDataDecoder.java (original)
+++ incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncryptedDataDecoder.java Wed Feb  2 21:55:46 2005
@@ -18,21 +18,65 @@
 package org.apache.kerberos.io.decoder;
 
 import java.io.IOException;
+import java.util.Enumeration;
 
 import org.apache.asn1.der.ASN1InputStream;
+import org.apache.asn1.der.DEREncodable;
+import org.apache.asn1.der.DERInteger;
+import org.apache.asn1.der.DEROctetString;
 import org.apache.asn1.der.DERSequence;
+import org.apache.asn1.der.DERTaggedObject;
+import org.apache.kerberos.crypto.encryption.EncryptionType;
 import org.apache.kerberos.messages.value.EncryptedData;
+import org.apache.kerberos.messages.value.EncryptedDataModifier;
 
 
-public class EncryptedDataDecoder extends KerberosMessageDecoder
+public class EncryptedDataDecoder
 {
-	public EncryptedData decode( byte[] encodedEncryptedData ) throws IOException
+	public static EncryptedData decode( byte[] encodedEncryptedData ) throws IOException
 	{
 		ASN1InputStream ais = new ASN1InputStream( encodedEncryptedData );
 		
 		DERSequence sequence = (DERSequence) ais.readObject();
 		
-		return decodeEncryptedData( sequence );
+		return decode( sequence );
+	}
+	
+	/**
+	 * EncryptedData ::=   SEQUENCE {
+	 *             etype[0]     INTEGER, -- EncryptionEngine
+	 *             kvno[1]      INTEGER OPTIONAL,
+	 *             cipher[2]    OCTET STRING -- ciphertext
+	 * }
+	 */
+	protected static EncryptedData decode( DERSequence sequence )
+	{
+		EncryptedDataModifier modifier = new EncryptedDataModifier();
+		
+		for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+		{
+			DERTaggedObject object = (DERTaggedObject) e.nextElement();
+			int tag = object.getTagNo();
+			DEREncodable derObject = object.getObject();
+			
+			switch ( tag )
+			{
+				case 0:
+					DERInteger etype = (DERInteger)derObject;
+					modifier.setEncryptionType( EncryptionType.getTypeByOrdinal( etype.intValue() ) );
+					break;
+				case 1:
+					DERInteger kvno = (DERInteger)derObject;
+					modifier.setKeyVersion( kvno.intValue() );
+					break;
+				case 2:
+					DEROctetString cipher = (DEROctetString)derObject;
+					modifier.setCipherText( cipher.getOctets() );
+					break;
+			}
+		}
+		
+		return modifier.getEncryptedData();
 	}
 }
 

Modified: incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncryptedTimestampDecoder.java
URL: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncryptedTimestampDecoder.java?view=diff&r1=151127&r2=151128
==============================================================================
--- incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncryptedTimestampDecoder.java (original)
+++ incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncryptedTimestampDecoder.java Wed Feb  2 21:55:46 2005
@@ -38,7 +38,7 @@
  *         pausec[1]                    INTEGER OPTIONAL
  * }
  */
-public class EncryptedTimestampDecoder extends KerberosMessageDecoder
+public class EncryptedTimestampDecoder
 {
 	public EncryptedTimeStamp decode( byte[] encodedEncryptedTimestamp ) throws IOException
 	{
@@ -63,15 +63,12 @@
 			{
 				case 0:
 					DERGeneralizedTime tag0 = (DERGeneralizedTime)derObject;
-					modifier.setKerberosTime( decodeKerberosTime( tag0 ) );
+					modifier.setKerberosTime( KerberosTimeDecoder.decode( tag0 ) );
 					break;
 				case 1:
 					DERInteger tag1 = (DERInteger)derObject;
 					modifier.setMicroSecond( tag1.intValue() );
 					break;
-			    default:
-			    	System.out.println( object.getObject() );
-			    	break;
 			}
 		}
 		

Added: incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncryptionKeyDecoder.java
URL: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncryptionKeyDecoder.java?view=auto&rev=151128
==============================================================================
--- incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncryptionKeyDecoder.java (added)
+++ incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncryptionKeyDecoder.java Wed Feb  2 21:55:46 2005
@@ -0,0 +1,66 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+
+package org.apache.kerberos.io.decoder;
+
+import java.util.Enumeration;
+
+import org.apache.asn1.der.DEREncodable;
+import org.apache.asn1.der.DERInteger;
+import org.apache.asn1.der.DEROctetString;
+import org.apache.asn1.der.DERSequence;
+import org.apache.asn1.der.DERTaggedObject;
+import org.apache.kerberos.crypto.encryption.EncryptionType;
+import org.apache.kerberos.messages.value.EncryptionKey;
+
+
+public class EncryptionKeyDecoder
+{
+	/**
+     * EncryptionKey ::=   SEQUENCE {
+     *     keytype[0]    INTEGER,
+     *     keyvalue[1]   OCTET STRING
+     * }
+     */
+	protected static EncryptionKey decode( DERSequence sequence )
+	{
+		EncryptionType type = EncryptionType.NULL;
+		byte[] data = null;
+		
+		for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+		{
+			DERTaggedObject object = (DERTaggedObject) e.nextElement();
+			int tag = object.getTagNo();
+			DEREncodable derObject = object.getObject();
+			
+			switch ( tag )
+			{
+				case 0:
+					DERInteger tag0 = (DERInteger)derObject;
+					type = EncryptionType.getTypeByOrdinal( tag0.intValue() );
+					break;
+				case 1:
+					DEROctetString tag1 = (DEROctetString)derObject;
+					data = tag1.getOctets();
+					break;
+			}
+		}
+		
+		return new EncryptionKey( type, data );
+	}
+}
+

Added: incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncryptionTypeDecoder.java
URL: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncryptionTypeDecoder.java?view=auto&rev=151128
==============================================================================
--- incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncryptionTypeDecoder.java (added)
+++ incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncryptionTypeDecoder.java Wed Feb  2 21:55:46 2005
@@ -0,0 +1,48 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+
+package org.apache.kerberos.io.decoder;
+
+import java.util.Enumeration;
+
+import org.apache.asn1.der.DERInteger;
+import org.apache.asn1.der.DERSequence;
+import org.apache.kerberos.crypto.encryption.EncryptionType;
+
+
+public class EncryptionTypeDecoder
+{
+	/**
+     * etype[8]             SEQUENCE OF INTEGER, -- EncryptionEngine,
+     *             -- in preference order
+     */
+	protected static EncryptionType[] decode( DERSequence sequence )
+	{
+		EncryptionType[] eTypes = new EncryptionType[ sequence.size() ];
+		
+		int ii = 0;
+		for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+		{
+			DERInteger object = (DERInteger) e.nextElement();
+			eTypes[ii] = EncryptionType.getTypeByOrdinal( object.intValue() );
+			ii++;
+		}
+		
+		return eTypes;
+	}
+}
+

Added: incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/HostAddressDecoder.java
URL: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/HostAddressDecoder.java?view=auto&rev=151128
==============================================================================
--- incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/HostAddressDecoder.java (added)
+++ incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/HostAddressDecoder.java Wed Feb  2 21:55:46 2005
@@ -0,0 +1,89 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+
+package org.apache.kerberos.io.decoder;
+
+import java.util.Enumeration;
+
+import org.apache.asn1.der.DEREncodable;
+import org.apache.asn1.der.DERInteger;
+import org.apache.asn1.der.DEROctetString;
+import org.apache.asn1.der.DERSequence;
+import org.apache.asn1.der.DERTaggedObject;
+import org.apache.kerberos.messages.value.HostAddress;
+import org.apache.kerberos.messages.value.HostAddressType;
+import org.apache.kerberos.messages.value.HostAddresses;
+
+
+public class HostAddressDecoder
+{
+	/**
+	 * HostAddress ::=     SEQUENCE  {
+     *                     addr-type[0]             INTEGER,
+     *                     address[1]               OCTET STRING
+     * }
+     */
+	protected static HostAddress decode( DERSequence sequence )
+	{
+		HostAddressType type = HostAddressType.NULL;
+		byte[] value = null;
+		
+		for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+		{
+			DERTaggedObject object = (DERTaggedObject) e.nextElement();
+			int tag = object.getTagNo();
+			DEREncodable derObject = object.getObject();
+			
+			switch ( tag )
+			{
+				case 0:
+					DERInteger addressType = (DERInteger)derObject;
+					type = HostAddressType.getTypeByOrdinal( addressType.intValue() );
+					break;
+				case 1:
+					DEROctetString address = (DEROctetString)derObject;
+					value = address.getOctets();
+					break;
+			}
+		}
+		
+		return new HostAddress( type, value );
+	}
+	
+	/**
+	 * HostAddresses ::=   SEQUENCE OF SEQUENCE {
+	 *                     addr-type[0]             INTEGER,
+	 *                     address[1]               OCTET STRING
+	 * }
+	 */
+	protected static HostAddresses decodeSequence( DERSequence sequence )
+	{
+		HostAddress[] addresses = new HostAddress[ sequence.size() ];
+		
+		int ii = 0;
+		for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+		{
+			DERSequence object = (DERSequence) e.nextElement();
+			HostAddress address = decode( object );
+			addresses[ii] = address;
+			ii++;
+		}
+		
+		return new HostAddresses( addresses );
+	}
+}
+

Modified: incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/KdcRequestDecoder.java
URL: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/KdcRequestDecoder.java?view=diff&r1=151127&r2=151128
==============================================================================
--- incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/KdcRequestDecoder.java (original)
+++ incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/KdcRequestDecoder.java Wed Feb  2 21:55:46 2005
@@ -32,14 +32,13 @@
 import org.apache.asn1.der.DERTaggedObject;
 import org.apache.kerberos.messages.KdcRequest;
 import org.apache.kerberos.messages.MessageType;
-import org.apache.kerberos.messages.components.Ticket;
 import org.apache.kerberos.messages.value.KdcOptions;
 import org.apache.kerberos.messages.value.PreAuthenticationData;
 import org.apache.kerberos.messages.value.RequestBody;
 import org.apache.kerberos.messages.value.RequestBodyModifier;
 
 
-public class KdcRequestDecoder extends KerberosMessageDecoder
+public class KdcRequestDecoder
 {
 	public KdcRequest decode( ByteBuffer in ) throws IOException
 	{
@@ -62,27 +61,29 @@
 	           padata[3]             SEQUENCE OF PA-DATA OPTIONAL,
 	           req-body[4]           KDC-REQ-BODY
 	}*/
-	private KdcRequest decodeKdcRequestSequence(DERSequence sequence) throws IOException {
-		
+	private KdcRequest decodeKdcRequestSequence( DERSequence sequence ) throws IOException
+	{
 		int pvno = 5;
 		MessageType msgType = MessageType.NULL;
 		
 		PreAuthenticationData[] paData = null;
 		RequestBody requestBody = null;
 		
-		for (Enumeration e = sequence.getObjects(); e.hasMoreElements();) {
-			DERTaggedObject object = ((DERTaggedObject) e.nextElement());
+		for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+		{
+			DERTaggedObject object = (DERTaggedObject) e.nextElement();
 			int tag = object.getTagNo();
 			DEREncodable derObject = object.getObject();
 			
-			switch (tag) {
+			switch ( tag )
+			{
 				case 1:
 					DERInteger tag1 = (DERInteger)derObject;
 					pvno = tag1.intValue();
 					break;
 				case 2:
 					DERInteger tag2 = (DERInteger)derObject;
-					msgType = MessageType.getTypeByOrdinal(tag2.intValue());
+					msgType = MessageType.getTypeByOrdinal( tag2.intValue() );
 					break;
 				case 3:
 					DERSequence tag3 = (DERSequence)derObject;
@@ -90,15 +91,12 @@
 					break;
 				case 4:
 					DERSequence tag4 = (DERSequence)derObject;
-					requestBody = decodeRequestBody(tag4);
+					requestBody = decodeRequestBody( tag4 );
 					break;
-			    default:
-			    	System.out.println(derObject);
-			    	break;
 			}
 		}
 		
-		return new KdcRequest(pvno, msgType, paData, requestBody);
+		return new KdcRequest( pvno, msgType, paData, requestBody );
 	}
 	
 	/*
@@ -120,83 +118,70 @@
 	                         -- Encrypted AuthorizationData encoding
 	            additional-tickets[11]       SEQUENCE OF Ticket OPTIONAL
 	}*/
-	private RequestBody decodeRequestBody(DERSequence sequence) throws IOException {
-		
+	private RequestBody decodeRequestBody( DERSequence sequence ) throws IOException
+	{
 		RequestBodyModifier modifier = new RequestBodyModifier();
 		
-		for (Enumeration e = sequence.getObjects(); e.hasMoreElements();) {
-			DERTaggedObject object = ((DERTaggedObject) e.nextElement());
+		for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+		{
+			DERTaggedObject object = (DERTaggedObject) e.nextElement();
 			int tag = object.getTagNo();
 			DEREncodable derObject = object.getObject();
 			
-			switch (tag) {
+			switch ( tag )
+			{
 				case 0:
 					DERBitString kdcOptions = (DERBitString)derObject;
-					modifier.setKdcOptions(new KdcOptions(kdcOptions.getOctets()));
+					modifier.setKdcOptions( new KdcOptions( kdcOptions.getOctets() ) );
 					break;
 				case 1:
 					DERSequence cName = (DERSequence)derObject;
-					modifier.setClientName(decodePrincipalName(cName));
+					modifier.setClientName( PrincipalNameDecoder.decode( cName ) );
 					break;
 				case 2:
 					DERGeneralString realm = (DERGeneralString)derObject;
-					modifier.setRealm(realm.getString());
+					modifier.setRealm( realm.getString() );
 					break;
 				case 3:
 					DERSequence sname = (DERSequence)derObject;
-					modifier.setServerName(decodePrincipalName(sname));
+					modifier.setServerName( PrincipalNameDecoder.decode( sname ) );
 					break;
 				case 4:
 					DERGeneralizedTime from = (DERGeneralizedTime)derObject;
-					modifier.setFrom(decodeKerberosTime(from));
+					modifier.setFrom( KerberosTimeDecoder.decode( from ) );
 					break;
 				case 5:
 					DERGeneralizedTime till = (DERGeneralizedTime)derObject;
-					modifier.setTill(decodeKerberosTime(till));
+					modifier.setTill( KerberosTimeDecoder.decode( till ) );
 					break;
 				case 6:
 					DERGeneralizedTime rtime = (DERGeneralizedTime)derObject;
-					modifier.setRtime(decodeKerberosTime(rtime));
+					modifier.setRtime( KerberosTimeDecoder.decode( rtime ) );
 					break;
 				case 7:
 					DERInteger nonce = (DERInteger)derObject;
-					modifier.setNonce(nonce.intValue());
+					modifier.setNonce( nonce.intValue() );
 					break;
 				case 8:
 					DERSequence etype = (DERSequence)derObject;
-					modifier.setEType(decodeEncryptionType(etype));
+					modifier.setEType( EncryptionTypeDecoder.decode( etype ) );
 					break;
 				case 9:
 					DERSequence hostAddresses = (DERSequence)derObject;
-					modifier.setAddresses(decodeHostAddresses(hostAddresses));
+					modifier.setAddresses( HostAddressDecoder.decodeSequence( hostAddresses ) );
 					break;
 				case 10:
 					DERSequence encryptedData = (DERSequence)derObject;
-					modifier.setEncAuthorizationData(decodeEncryptedData(encryptedData));
+					modifier.setEncAuthorizationData( EncryptedDataDecoder.decode( encryptedData ) );
 					break;
 				case 11:
 					DERSequence tag11 = (DERSequence)derObject;
-					modifier.setAdditionalTickets(decodeTickets(tag11));
+					modifier.setAdditionalTickets( TicketDecoder.decodeSequence( tag11 ) );
 					break;
-			    default:
-			    	System.out.println(derObject);
-			    	break;
 			}
 		}
 		
 		return modifier.getRequestBody();
-	}
-	
-	protected Ticket[] decodeTickets(DERSequence sequence) throws IOException {
-		
-		Ticket[] tickets = new Ticket[sequence.size()];
-		
-		int i = 0;
-		for (Enumeration e = sequence.getObjects(); e.hasMoreElements();) {
-			DERApplicationSpecific object = ((DERApplicationSpecific) e.nextElement());
-			tickets[i] = decodeTicket(object);
-		}
-		return tickets;
 	}
 }
 

Added: incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/KerberosTimeDecoder.java
URL: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/KerberosTimeDecoder.java?view=auto&rev=151128
==============================================================================
--- incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/KerberosTimeDecoder.java (added)
+++ incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/KerberosTimeDecoder.java Wed Feb  2 21:55:46 2005
@@ -0,0 +1,49 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+
+package org.apache.kerberos.io.decoder;
+
+import java.text.ParseException;
+import java.util.Date;
+
+import org.apache.asn1.der.DERGeneralizedTime;
+import org.apache.kerberos.messages.value.KerberosTime;
+
+
+public class KerberosTimeDecoder
+{
+	/**
+	 * KerberosTime ::=   GeneralizedTime
+	 *             -- Specifying UTC time zone (Z)
+	 */
+	protected static KerberosTime decode( DERGeneralizedTime time )
+	{
+		Date date = null;
+		
+		try
+		{
+			date = time.getDate();
+		}
+		catch (ParseException pe)
+		{
+			pe.printStackTrace();
+		}
+		
+		return new KerberosTime( date );
+	}
+}
+

Added: incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/LastRequestDecoder.java
URL: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/LastRequestDecoder.java?view=auto&rev=151128
==============================================================================
--- incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/LastRequestDecoder.java (added)
+++ incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/LastRequestDecoder.java Wed Feb  2 21:55:46 2005
@@ -0,0 +1,84 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+
+package org.apache.kerberos.io.decoder;
+
+import java.util.Enumeration;
+
+import org.apache.asn1.der.DEREncodable;
+import org.apache.asn1.der.DERGeneralizedTime;
+import org.apache.asn1.der.DERInteger;
+import org.apache.asn1.der.DERSequence;
+import org.apache.asn1.der.DERTaggedObject;
+import org.apache.kerberos.messages.value.KerberosTime;
+import org.apache.kerberos.messages.value.LastRequest;
+import org.apache.kerberos.messages.value.LastRequestEntry;
+import org.apache.kerberos.messages.value.LastRequestType;
+
+
+public class LastRequestDecoder
+{
+	/**
+	 * LastReq ::=   SEQUENCE OF SEQUENCE {
+	 * lr-type[0]               INTEGER,
+	 * lr-value[1]              KerberosTime
+	 * }
+	 */
+	protected LastRequest decodeSequence( DERSequence sequence )
+	{
+		LastRequestEntry[] entries = new LastRequestEntry[ sequence.size() ];
+		
+		int ii = 0;
+		for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+		{
+			DERSequence object = (DERSequence) e.nextElement();
+			LastRequestEntry entry = decode( object );
+			entries[ii] = entry;
+			ii++;
+		}
+		
+		return new LastRequest( entries );
+	}
+	
+	protected LastRequestEntry decode( DERSequence sequence )
+	{
+		LastRequestType type = LastRequestType.NONE;
+		KerberosTime value = null;
+		
+		for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+		{
+			DERTaggedObject object = (DERTaggedObject) e.nextElement();
+			int tag = object.getTagNo();
+			DEREncodable derObject = object.getObject();
+			
+			switch ( tag )
+			{
+				case 0:
+					DERInteger tag0 = (DERInteger)derObject;
+					type = LastRequestType.getTypeByOrdinal( tag0.intValue() );
+					break;
+				case 1:
+					DERGeneralizedTime tag1 = (DERGeneralizedTime)derObject;
+					value = KerberosTimeDecoder.decode( tag1 );
+					break;
+			}
+		}
+		
+		return new LastRequestEntry( type, value );
+	}
+}
+

Added: incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/PrincipalNameDecoder.java
URL: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/PrincipalNameDecoder.java?view=auto&rev=151128
==============================================================================
--- incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/PrincipalNameDecoder.java (added)
+++ incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/PrincipalNameDecoder.java Wed Feb  2 21:55:46 2005
@@ -0,0 +1,74 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+
+package org.apache.kerberos.io.decoder;
+
+import java.util.Enumeration;
+
+import org.apache.asn1.der.DEREncodable;
+import org.apache.asn1.der.DERGeneralString;
+import org.apache.asn1.der.DERInteger;
+import org.apache.asn1.der.DERSequence;
+import org.apache.asn1.der.DERTaggedObject;
+import org.apache.kerberos.messages.value.PrincipalName;
+import org.apache.kerberos.messages.value.PrincipalNameModifier;
+
+
+public class PrincipalNameDecoder
+{
+	/**
+	 * PrincipalName ::=   SEQUENCE {
+	 *               name-type[0]     INTEGER,
+	 *               name-string[1]   SEQUENCE OF GeneralString
+	 * }
+	 */
+	public static PrincipalName decode( DERSequence sequence )
+	{
+		PrincipalNameModifier modifier = new PrincipalNameModifier();
+		
+		for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+		{
+			DERTaggedObject object = (DERTaggedObject) e.nextElement();
+			int tag = object.getTagNo();
+			DEREncodable derObject = object.getObject();
+			
+			switch ( tag )
+			{
+				case 0:
+					DERInteger nameType = (DERInteger)derObject;
+					modifier.setType( nameType.intValue() );
+					break;
+				case 1:
+					DERSequence nameString = (DERSequence)derObject;
+					decodeNameString( nameString, modifier );
+					break;
+			}
+		}
+		
+		return modifier.getPrincipalName();
+	}
+	
+	private static void decodeNameString( DERSequence sequence, PrincipalNameModifier modifier )
+	{
+		for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+		{
+			DERGeneralString object = (DERGeneralString) e.nextElement();
+			modifier.addName( object.getString() );
+		}
+	}
+}
+

Modified: incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/PrivateMessageDecoder.java
URL: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/PrivateMessageDecoder.java?view=diff&r1=151127&r2=151128
==============================================================================
--- incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/PrivateMessageDecoder.java (original)
+++ incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/PrivateMessageDecoder.java Wed Feb  2 21:55:46 2005
@@ -30,7 +30,7 @@
 import org.apache.kerberos.messages.application.PrivateMessage;
 
 
-public class PrivateMessageDecoder extends KerberosMessageDecoder
+public class PrivateMessageDecoder
 {
 	public PrivateMessage decode( byte[] encodedPrivateMessage ) throws IOException
 	{
@@ -43,7 +43,7 @@
 		return decodePrivateMessageSequence( privateMessage );
 	}
 	
-	private PrivateMessage decodePrivateMessageSequence(DERSequence sequence)
+	private PrivateMessage decodePrivateMessageSequence( DERSequence sequence )
 	{
 		PrivateMessage message = new PrivateMessage();
 		
@@ -53,7 +53,8 @@
 			int tag = object.getTagNo();
 			DEREncodable derObject = object.getObject();
 			
-			switch ( tag ) {
+			switch ( tag )
+			{
 				case 0:
 					DERInteger tag0 = (DERInteger) derObject;
 					message.setProtocolVersionNumber( tag0.intValue() );
@@ -64,11 +65,8 @@
 					break;
 				case 3:
 					DERSequence tag3 = (DERSequence)derObject;
-					message.setEncryptedPart( decodeEncryptedData( tag3 ) );
+					message.setEncryptedPart( EncryptedDataDecoder.decode( tag3 ) );
 					break;
-			    default:
-			    	System.out.println( derObject );
-			    	break;
 			}
 		}
 		

Added: incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/TicketDecoder.java
URL: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/TicketDecoder.java?view=auto&rev=151128
==============================================================================
--- incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/TicketDecoder.java (added)
+++ incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/TicketDecoder.java Wed Feb  2 21:55:46 2005
@@ -0,0 +1,93 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+
+package org.apache.kerberos.io.decoder;
+
+import java.io.IOException;
+import java.util.Enumeration;
+
+import org.apache.asn1.der.DERApplicationSpecific;
+import org.apache.asn1.der.DEREncodable;
+import org.apache.asn1.der.DERGeneralString;
+import org.apache.asn1.der.DERInteger;
+import org.apache.asn1.der.DERSequence;
+import org.apache.asn1.der.DERTaggedObject;
+import org.apache.kerberos.messages.components.Ticket;
+import org.apache.kerberos.messages.components.TicketModifier;
+
+
+public class TicketDecoder
+{
+	public static Ticket[] decodeSequence( DERSequence sequence ) throws IOException
+	{
+		Ticket[] tickets = new Ticket[ sequence.size() ];
+		
+		int ii = 0;
+		for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+		{
+			DERApplicationSpecific object = (DERApplicationSpecific) e.nextElement();
+			tickets[ii] = decode( object );
+		}
+		
+		return tickets;
+	}
+	
+	/**
+	 * Ticket ::=                    [APPLICATION 1] SEQUENCE {
+     *     tkt-vno[0]                   INTEGER,
+     *     realm[1]                     Realm,
+     *     sname[2]                     PrincipalName,
+     *     enc-part[3]                  EncryptedData
+     * }
+     */
+	protected static Ticket decode( DERApplicationSpecific app ) throws IOException
+	{
+		DERSequence sequence = (DERSequence) app.getObject();
+		
+		TicketModifier modifier = new TicketModifier();
+		
+		for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+		{
+			DERTaggedObject object = (DERTaggedObject) e.nextElement();
+			int tag = object.getTagNo();
+			DEREncodable derObject = object.getObject();
+			
+			switch ( tag )
+			{
+				case 0:
+					DERInteger tag0 = (DERInteger)derObject;
+					modifier.setTicketVersionNumber( tag0.intValue() );
+					break;
+				case 1:
+					DERGeneralString tag1 = (DERGeneralString)derObject;
+					modifier.setServerRealm( tag1.getString() );
+					break;
+				case 2:
+					DERSequence tag2 = (DERSequence)derObject;
+					modifier.setServerName( PrincipalNameDecoder.decode( tag2 ) );
+					break;
+				case 3:
+					DERSequence tag3 = (DERSequence)derObject;
+					modifier.setEncPart( EncryptedDataDecoder.decode( tag3 ) );
+					break;
+			}
+		}
+		
+		return modifier.getTicket();
+	}
+}
+



Mime
View raw message