directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r149028 - /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/KerberosMessageDecoder.java
Date Sat, 29 Jan 2005 11:57:49 GMT
Author: erodriguez
Date: Sat Jan 29 03:57:46 2005
New Revision: 149028

URL: http://svn.apache.org/viewcvs?view=rev&rev=149028
Log:
Authenticator ASN.1 DER decoder refactoring.
Modified:
   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/KerberosMessageDecoder.java

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&rev=149028&p1=incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/AuthenticatorDecoder.java&r1=149027&p2=incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/AuthenticatorDecoder.java&r2=149028
==============================================================================
--- 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
Sat Jan 29 03:57:46 2005
@@ -18,11 +18,18 @@
 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.DERApplicationSpecific;
+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.DERSequence;
+import org.apache.asn1.der.DERTaggedObject;
 import org.apache.kerberos.messages.components.Authenticator;
+import org.apache.kerberos.messages.components.AuthenticatorModifier;
 
 
 public class AuthenticatorDecoder extends KerberosMessageDecoder
@@ -36,6 +43,79 @@
 		DERSequence sequence = (DERSequence) app.getObject();
 		
 		return decodeAuthenticator( sequence );
+	}
+	
+	/**
+	 * -- Unencrypted authenticator
+	 * Authenticator ::=    [APPLICATION 2] SEQUENCE
+	 * {
+	 *                authenticator-vno[0]          INTEGER,
+	 *                crealm[1]                     Realm,
+	 *                cname[2]                      PrincipalName,
+	 *                cksum[3]                      Checksum OPTIONAL,
+	 *                cusec[4]                      INTEGER,
+	 *                ctime[5]                      KerberosTime,
+	 *                subkey[6]                     EncryptionKey OPTIONAL,
+	 *                seq-number[7]                 INTEGER OPTIONAL,
+     *  
+	 *                authorization-data[8]         AuthorizationData OPTIONAL
+	 * }
+	 */
+	private Authenticator decodeAuthenticator( DERSequence sequence )
+	{
+		AuthenticatorModifier modifier = new AuthenticatorModifier();
+		
+		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.setVersionNumber( tag0.intValue() );
+					break;
+				case 1:
+					DERGeneralString tag1 = (DERGeneralString)derObject;
+					modifier.setClientRealm( tag1.getString() );
+					break;
+				case 2:
+					DERSequence tag2 = (DERSequence)derObject;
+					modifier.setClientName( decodePrincipalName( tag2 ) );
+					break;
+				case 3:
+					DERSequence tag3 = (DERSequence)derObject;
+					modifier.setChecksum( decodeChecksum( tag3 ) );
+					break;
+				case 4:
+					DERInteger tag4 = (DERInteger)derObject;
+					modifier.setClientMicroSecond( tag4.intValue() );
+					break;
+				case 5:
+					DERGeneralizedTime tag5 = (DERGeneralizedTime)derObject;
+					modifier.setClientTime( decodeKerberosTime( tag5 ) );
+					break;
+				case 6:
+					DERSequence tag6 = (DERSequence) derObject;
+					modifier.setSubSessionKey( decodeEncryptionKey( tag6 ) );
+					break;
+				case 7:
+					DERInteger tag7 = (DERInteger)derObject;
+					modifier.setSequenceNumber( tag7.intValue() );
+					break;
+				case 8:
+					DERSequence tag8 = (DERSequence)derObject;
+					modifier.setAuthorizationData( decodeAuthorizationData( tag8 ) );
+					break;
+			    default:
+			    	System.out.println( derObject );
+			    	break;
+			}
+		}
+		
+		return modifier.getAuthenticator();
 	}
 }
 

Modified: incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/KerberosMessageDecoder.java
Url: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/KerberosMessageDecoder.java?view=diff&rev=149028&p1=incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/KerberosMessageDecoder.java&r1=149027&p2=incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/KerberosMessageDecoder.java&r2=149028
==============================================================================
--- incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/KerberosMessageDecoder.java
(original)
+++ incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/KerberosMessageDecoder.java
Sat Jan 29 03:57:46 2005
@@ -32,8 +32,6 @@
 import org.apache.asn1.der.DERTaggedObject;
 import org.apache.kerberos.crypto.checksum.ChecksumType;
 import org.apache.kerberos.crypto.encryption.EncryptionType;
-import org.apache.kerberos.messages.components.Authenticator;
-import org.apache.kerberos.messages.components.AuthenticatorModifier;
 import org.apache.kerberos.messages.components.Ticket;
 import org.apache.kerberos.messages.components.TicketModifier;
 import org.apache.kerberos.messages.value.AuthorizationData;
@@ -439,75 +437,6 @@
 			}
 		}
 		return new AuthorizationDataEntry(type, data);
-	}
-	
-	/*
-	-- Unencrypted authenticator
-	Authenticator ::=    [APPLICATION 2] SEQUENCE    {
-	               authenticator-vno[0]          INTEGER,
-	               crealm[1]                     Realm,
-	               cname[2]                      PrincipalName,
-	               cksum[3]                      Checksum OPTIONAL,
-	               cusec[4]                      INTEGER,
-	               ctime[5]                      KerberosTime,
-	               subkey[6]                     EncryptionKey OPTIONAL,
-	               seq-number[7]                 INTEGER OPTIONAL,
-
-	               authorization-data[8]         AuthorizationData OPTIONAL
-	}
-	*/
-	protected Authenticator decodeAuthenticator(DERSequence sequence) {
-		
-		AuthenticatorModifier modifier = new AuthenticatorModifier();
-		
-		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.setVersionNumber(tag0.intValue());
-					break;
-				case 1:
-					DERGeneralString tag1 = (DERGeneralString)derObject;
-					modifier.setClientRealm(tag1.getString());
-					break;
-				case 2:
-					DERSequence tag2 = (DERSequence)derObject;
-					modifier.setClientName(decodePrincipalName(tag2));
-					break;
-				case 3:
-					DERSequence tag3 = (DERSequence)derObject;
-					modifier.setChecksum(decodeChecksum(tag3));
-					break;
-				case 4:
-					DERInteger tag4 = (DERInteger)derObject;
-					modifier.setClientMicroSecond(tag4.intValue());
-					break;
-				case 5:
-					DERGeneralizedTime tag5 = (DERGeneralizedTime)derObject;
-					modifier.setClientTime(decodeKerberosTime(tag5));
-					break;
-				case 6:
-					DERSequence tag6 = (DERSequence) derObject;
-					modifier.setSubSessionKey(decodeEncryptionKey(tag6));
-					break;
-				case 7:
-					DERInteger tag7 = (DERInteger)derObject;
-					modifier.setSequenceNumber(tag7.intValue());
-					break;
-				case 8:
-					DERSequence tag8 = (DERSequence)derObject;
-					modifier.setAuthorizationData(decodeAuthorizationData(tag8));
-					break;
-			    default:
-			    	System.out.println(derObject);
-			    	break;
-			}
-		}
-		return modifier.getAuthenticator();
 	}
 }
 

Mime
View raw message