You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by er...@apache.org on 2004/10/30 07:01:20 UTC

svn commit: rev 56021 - in incubator/directory/kerberos/trunk/source/main/org/apache/kerberos: io/encoder messages/value

Author: erodriguez
Date: Fri Oct 29 22:01:20 2004
New Revision: 56021

Added:
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/value/LastRequest.java
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/value/LastRequestEntry.java
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/value/LastRequestType.java
Modified:
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/io/encoder/KerberosMessageEncoder.java
Log:
Implementation of LastRequest structure, with ASN.1 encoder update.

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	Fri Oct 29 22:01:20 2004
@@ -186,7 +186,7 @@
 		ASN1EncodableVector outerVector = new ASN1EncodableVector();
 		for (int i = 0; i < entries.length; i++) {
 			ASN1EncodableVector vector = new ASN1EncodableVector();
-			vector.add(new DERTaggedObject(0, new DERInteger(entries[i].getLastRequestType())));
+			vector.add(new DERTaggedObject(0, new DERInteger(entries[i].getLastRequestType().getOrdinal())));
 			vector.add(new DERTaggedObject(1, new DERGeneralizedTime(entries[i].getLastRequestValue().toDate())));
 			outerVector.add(new DERSequence(vector));
 			}

Added: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/value/LastRequest.java
==============================================================================
--- (empty file)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/value/LastRequest.java	Fri Oct 29 22:01:20 2004
@@ -0,0 +1,31 @@
+/*
+ *   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 LastRequest {
+	
+	private LastRequestEntry[] _entries = new LastRequestEntry[1];
+	
+	public LastRequest() {
+		_entries[0] = new LastRequestEntry(LastRequestType.NONE, new KerberosTime());
+	}
+	
+	public LastRequestEntry[] getEntries() {
+		return _entries;
+	}
+}
+

Added: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/value/LastRequestEntry.java
==============================================================================
--- (empty file)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/value/LastRequestEntry.java	Fri Oct 29 22:01:20 2004
@@ -0,0 +1,36 @@
+/*
+ *   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 LastRequestEntry {
+
+	private LastRequestType _lastRequestType;
+	private KerberosTime    _lastRequestValue;
+	
+	public LastRequestEntry(LastRequestType type, KerberosTime value) {
+		_lastRequestType  = type;
+		_lastRequestValue = value;
+	}
+	
+	public LastRequestType getLastRequestType() {
+		return _lastRequestType;
+	}
+	public KerberosTime getLastRequestValue() {
+		return _lastRequestValue;
+	}
+}
+

Added: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/value/LastRequestType.java
==============================================================================
--- (empty file)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/value/LastRequestType.java	Fri Oct 29 22:01:20 2004
@@ -0,0 +1,75 @@
+/*
+ *   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 LastRequestType implements Comparable {
+
+	/**
+	 * Enumeration elements are constructed once upon class loading.
+	 * Order of appearance here determines the order of compareTo.
+	 */
+	public static final LastRequestType NONE                 = new LastRequestType(0, "none");
+	public static final LastRequestType TIME_OF_INITIAL_TGT  = new LastRequestType(1, "time of initial ticket");
+	public static final LastRequestType TIME_OF_INITIAL_REQ  = new LastRequestType(2, "time of initial request");
+	public static final LastRequestType TIME_OF_NEWEST_TGT   = new LastRequestType(3, "time of newest ticket");
+	public static final LastRequestType TIME_OF_LAST_RENEWAL = new LastRequestType(4, "time of last renewal");
+	public static final LastRequestType TIME_OF_LAST_REQ     = new LastRequestType(5, "time of last request");
+	public static final LastRequestType TIME_OF_PASSWORD_EXP = new LastRequestType(6, "time of password expiration");
+	
+	public String toString() {
+		return _fName + " (" + _fOrdinal + ")";
+	}
+
+	public int compareTo(Object that) {
+		return _fOrdinal - ((LastRequestType) that)._fOrdinal;
+	}
+
+	public static LastRequestType getTypeByOrdinal(int type) {
+		for (int i = 0; i < fValues.length; i++)
+			if (fValues[i]._fOrdinal == type)
+				return fValues[i];
+		return NONE;
+	}
+	
+	public int getOrdinal() {
+		return _fOrdinal;
+	}
+
+	/// PRIVATE /////
+	private final String _fName;
+	private final int    _fOrdinal;
+
+	/**
+	 * Private constructor prevents construction outside of this class.
+	 */
+	private LastRequestType(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 LastRequestType[] fValues = {NONE, TIME_OF_INITIAL_TGT,
+			TIME_OF_INITIAL_REQ, TIME_OF_NEWEST_TGT, TIME_OF_LAST_RENEWAL,
+			TIME_OF_LAST_REQ, TIME_OF_PASSWORD_EXP};
+	// VALUES needs to be located here, otherwise illegal forward reference
+	public static final List VALUES = Collections.unmodifiableList(Arrays.asList(fValues));
+}
+