directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: rev 54955 - in incubator/directory/kerberos/trunk/source/main/org/apache/kerberos: io/decoder io/encoder messages/value
Date Sun, 17 Oct 2004 11:45:10 GMT
Author: erodriguez
Date: Sun Oct 17 04:45:09 2004
New Revision: 54955

Added:
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/value/AuthorizationData.java
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/value/AuthorizationDataEntry.java
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/value/AuthorizationType.java
Modified:
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/io/decoder/KerberosMessageDecoder.java
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/io/encoder/KerberosMessageEncoder.java
Log:
Authorization Data implementation, with ASN.1 codec updates resulting from type-safety.

Modified: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/io/decoder/KerberosMessageDecoder.java
==============================================================================
--- incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/io/decoder/KerberosMessageDecoder.java
(original)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/io/decoder/KerberosMessageDecoder.java
Sun Oct 17 04:45:09 2004
@@ -347,7 +347,7 @@
 	
 	protected AuthorizationDataEntry decodeAuthorizationEntry(DERSequence sequence) {
 		
-		int type = 0;
+		AuthorizationType type = AuthorizationType.NULL;
 		byte[] data = null;
 		
 		for (Enumeration e = sequence.getObjects(); e.hasMoreElements();) {
@@ -358,7 +358,7 @@
 			switch (tag) {
 				case 0:
 					DERInteger tag0 = (DERInteger)derObject;
-					type = tag0.getValue().intValue();
+					type = AuthorizationType.getTypeByOrdinal(tag0.getValue().intValue());
 					break;
 				case 1:
 					DEROctetString tag1 = (DEROctetString)derObject;

Modified: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/io/encoder/KerberosMessageEncoder.java
==============================================================================
--- incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/io/encoder/KerberosMessageEncoder.java
(original)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/io/encoder/KerberosMessageEncoder.java
Sun Oct 17 04:45:09 2004
@@ -277,7 +277,7 @@
 		while (it.hasNext()) {
 			AuthorizationDataEntry entry = (AuthorizationDataEntry)it.next();
 			ASN1EncodableVector vector = new ASN1EncodableVector();
-			vector.add(new DERTaggedObject(0, new DERInteger(entry.getAuthorizationDataType())));
+			vector.add(new DERTaggedObject(0, new DERInteger(entry.getAuthorizationDataType().getOrdinal())));
 			vector.add(new DERTaggedObject(1, new DEROctetString(entry.getAuthorizationData())));
 			outerVector.add(new DERSequence(vector));
 		}

Added: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/value/AuthorizationData.java
==============================================================================
--- (empty file)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/value/AuthorizationData.java
Sun Oct 17 04:45:09 2004
@@ -0,0 +1,44 @@
+/*
+ *   Copyright 2004 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.messages.value;
+
+import java.util.*;
+
+public class AuthorizationData {
+	
+	private List _entries = new ArrayList();
+
+	/**
+	 * Class constructor
+	 */
+	public AuthorizationData() {
+		// used by ASN.1 decoder
+	}
+	
+	public void add(AuthorizationData data) {
+		_entries.addAll(data._entries);
+	}
+	
+	public void add(AuthorizationDataEntry entry) {
+		_entries.add(entry);
+	}
+	
+	public Iterator iterator() {
+		return _entries.iterator();
+	}
+}
+

Added: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/value/AuthorizationDataEntry.java
==============================================================================
--- (empty file)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/value/AuthorizationDataEntry.java
Sun Oct 17 04:45:09 2004
@@ -0,0 +1,39 @@
+/*
+ *   Copyright 2004 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.messages.value;
+
+public class AuthorizationDataEntry {
+
+	private AuthorizationType _authorizationDataType;
+	private byte[]            _authorizationData;
+
+	/**
+	 * Class constructor
+	 */
+	public AuthorizationDataEntry(AuthorizationType adType, byte[] adData) {
+		_authorizationDataType = adType;
+		_authorizationData     = adData;
+	}
+
+	public byte[] getAuthorizationData() {
+		return _authorizationData;
+	}
+	public AuthorizationType getAuthorizationDataType() {
+		return _authorizationDataType;
+	}
+}
+

Added: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/value/AuthorizationType.java
==============================================================================
--- (empty file)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/value/AuthorizationType.java
Sun Oct 17 04:45:09 2004
@@ -0,0 +1,78 @@
+/*
+ *   Copyright 2004 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.messages.value;
+
+import java.util.*;
+
+public final class AuthorizationType implements Comparable {
+
+	/**
+	 * Enumeration elements are constructed once upon class loading.
+	 * Order of appearance here determines the order of compareTo.
+	 */
+	public static final AuthorizationType NULL                = new AuthorizationType(0, "null");
+	public static final AuthorizationType IF_RELEVANT         = new AuthorizationType(1, "if
relevant");
+	public static final AuthorizationType INTENDED_FOR_SERVER = new AuthorizationType(2, "intended
for server");
+	public static final AuthorizationType INTENDED_FOR_APPLICATION_CLASS = new AuthorizationType(3,
"intended for application class");
+	public static final AuthorizationType KDC_ISSUED          = new AuthorizationType(4, "kdc
issued");
+	public static final AuthorizationType OR                  = new AuthorizationType(5, "or");
+	public static final AuthorizationType MANDATORY_TICKET_EXTENSIONS    = new AuthorizationType(6,
"mandatory ticket extensions");
+	public static final AuthorizationType IN_TICKET_EXTENSIONS           = new AuthorizationType(7,
"in ticket extensions");
+	public static final AuthorizationType OSF_DCE             = new AuthorizationType(64, "OSF
DCE");
+	public static final AuthorizationType SESAME              = new AuthorizationType(65, "sesame");
+	
+	public String toString() {
+		return _fName + " (" + _fOrdinal + ")";
+	}
+
+	public int compareTo(Object that) {
+		return _fOrdinal - ((AuthorizationType) that)._fOrdinal;
+	}
+
+	public static AuthorizationType getTypeByOrdinal(int type) {
+		for (int i = 0; i < fValues.length; i++)
+			if (fValues[i]._fOrdinal == type)
+				return fValues[i];
+		return NULL;
+	}
+	
+	public int getOrdinal() {
+		return _fOrdinal;
+	}
+
+	/// PRIVATE /////
+	private final String _fName;
+	private final int    _fOrdinal;
+
+	/**
+	 * Private constructor prevents construction outside of this class.
+	 */
+	private AuthorizationType(int ordinal, String name) {
+		_fOrdinal = ordinal;
+		_fName    = name;
+	}
+
+	/**
+	 * These two lines are all that's necessary to export a List of VALUES.
+	 */
+	private static final AuthorizationType[] fValues = {NULL, IF_RELEVANT, INTENDED_FOR_SERVER,
+			INTENDED_FOR_APPLICATION_CLASS, KDC_ISSUED, OR, MANDATORY_TICKET_EXTENSIONS,
+			IN_TICKET_EXTENSIONS, OSF_DCE, SESAME};
+	// VALUES needs to be located here, otherwise illegal forward reference
+	public static final List VALUES = Collections.unmodifiableList(Arrays.asList(fValues));
+}
+

Mime
View raw message