directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r151113 - in incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder: KdcRequestDecoder.java PreAuthenticationDataDecoder.java
Date Thu, 03 Feb 2005 03:30:47 GMT
Author: erodriguez
Date: Wed Feb  2 19:30:46 2005
New Revision: 151113

URL: http://svn.apache.org/viewcvs?view=rev&rev=151113
Log:
Split pre-authentication decoder out into its own decoder so it could be reused.

Added:
    incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/PreAuthenticationDataDecoder.java
Modified:
    incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/KdcRequestDecoder.java

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=151112&r2=151113
==============================================================================
--- 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 19:30:46 2005
@@ -28,7 +28,6 @@
 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.KdcRequest;
@@ -36,8 +35,6 @@
 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.PreAuthenticationDataModifier;
-import org.apache.kerberos.messages.value.PreAuthenticationDataType;
 import org.apache.kerberos.messages.value.RequestBody;
 import org.apache.kerberos.messages.value.RequestBodyModifier;
 
@@ -89,7 +86,7 @@
 					break;
 				case 3:
 					DERSequence tag3 = (DERSequence)derObject;
-					paData = decodePaData(tag3);
+					paData = PreAuthenticationDataDecoder.decodeSequence( tag3 );
 					break;
 				case 4:
 					DERSequence tag4 = (DERSequence)derObject;
@@ -103,54 +100,7 @@
 		
 		return new KdcRequest(pvno, msgType, paData, requestBody);
 	}
-
-	/*
-	PA-DATA ::=        SEQUENCE {
-	           padata-type[1]        INTEGER,
-	           padata-value[2]       OCTET STRING,
-	                         -- might be encoded AP-REQ
-	}*/
-	private PreAuthenticationData[] decodePaData(DERSequence sequence) {
-
-		PreAuthenticationData[] paDataSequence = new PreAuthenticationData[sequence.size()];
-		int i = 0;
-
-		for (Enumeration e = sequence.getObjects(); e.hasMoreElements();) {
-			DERSequence object = (DERSequence) e.nextElement();
-			PreAuthenticationData paData = decodePreAuthenticationData(object);
-			paDataSequence[i] = paData;
-			i++;
-		}
-		return paDataSequence;
-	}
 	
-	private PreAuthenticationData decodePreAuthenticationData(DERSequence sequence) {
-		
-		PreAuthenticationDataModifier modifier = new PreAuthenticationDataModifier();
-		
-		for (Enumeration e = sequence.getObjects(); e.hasMoreElements();) {
-			DERTaggedObject object = ((DERTaggedObject) e.nextElement());
-			int tag = object.getTagNo();
-			DEREncodable derObject = object.getObject();
-			
-			switch (tag) {
-				case 1:
-					DERInteger padataType = (DERInteger) derObject;
-					PreAuthenticationDataType type = PreAuthenticationDataType.getTypeByOrdinal(padataType.intValue());
-					modifier.setDataType(type);
-					break;
-				case 2:
-					DEROctetString padataValue = (DEROctetString) derObject;
-					modifier.setDataValue(padataValue.getOctets());
-					break;
-				default:
-					System.out.println(derObject);
-					break;
-			}
-		}
-		return modifier.getPreAuthenticationData();
-	}
-
 	/*
 	KDC-REQ-BODY ::=   SEQUENCE {
 	            kdc-options[0]       KdcOptions,

Added: incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/PreAuthenticationDataDecoder.java
URL: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/PreAuthenticationDataDecoder.java?view=auto&rev=151113
==============================================================================
--- incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/PreAuthenticationDataDecoder.java
(added)
+++ incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/PreAuthenticationDataDecoder.java
Wed Feb  2 19:30:46 2005
@@ -0,0 +1,92 @@
+/*
+ *   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.PreAuthenticationData;
+import org.apache.kerberos.messages.value.PreAuthenticationDataModifier;
+import org.apache.kerberos.messages.value.PreAuthenticationDataType;
+
+
+public class PreAuthenticationDataDecoder
+{
+    /**
+     * KDC-REQ ::=        SEQUENCE {
+	 *            pvno[1]               INTEGER,
+	 *            msg-type[2]           INTEGER,
+	 *            padata[3]             SEQUENCE OF PA-DATA OPTIONAL,
+	 *            req-body[4]           KDC-REQ-BODY
+	 * }
+	 */
+	public static PreAuthenticationData[] decodeSequence( DERSequence sequence )
+	{
+		PreAuthenticationData[] paDataSequence = new PreAuthenticationData[ sequence.size() ];
+		int ii = 0;
+
+		for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+		{
+			DERSequence object = (DERSequence) e.nextElement();
+			PreAuthenticationData paData = PreAuthenticationDataDecoder.decode( object );
+			paDataSequence[ii] = paData;
+			ii++;
+		}
+		
+		return paDataSequence;
+	}
+    
+	/**
+	 * PA-DATA ::=        SEQUENCE {
+	 *            padata-type[1]        INTEGER,
+	 *            padata-value[2]       OCTET STRING,
+	 *                          -- might be encoded AP-REQ
+	 * }
+	 */
+	public static PreAuthenticationData decode( DERSequence sequence )
+	{
+		PreAuthenticationDataModifier modifier = new PreAuthenticationDataModifier();
+		
+		for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+		{
+			DERTaggedObject object = (DERTaggedObject) e.nextElement();
+			int tag = object.getTagNo();
+			DEREncodable derObject = object.getObject();
+			
+			switch ( tag )
+			{
+				case 1:
+					DERInteger padataType = (DERInteger) derObject;
+					PreAuthenticationDataType type = PreAuthenticationDataType.getTypeByOrdinal( padataType.intValue()
);
+					modifier.setDataType( type );
+					break;
+				case 2:
+					DEROctetString padataValue = (DEROctetString) derObject;
+					modifier.setDataValue( padataValue.getOctets() );
+					break;
+			}
+		}
+		
+		return modifier.getPreAuthenticationData();
+	}
+}
+



Mime
View raw message