directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: rev 54008 - incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/value
Date Thu, 07 Oct 2004 19:41:15 GMT
Author: erodriguez
Date: Thu Oct  7 12:41:14 2004
New Revision: 54008

Added:
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/value/ApOptions.java
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/value/KdcOptions.java
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/value/Options.java
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/value/TicketFlags.java
Log:
kerberos options and flags

Added: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/value/ApOptions.java
==============================================================================
--- (empty file)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/value/ApOptions.java
Thu Oct  7 12:41:14 2004
@@ -0,0 +1,56 @@
+/*
+ *   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 ApOptions extends Options {
+    // AP Request option - reserved
+	public static final int RESERVED        = 0;
+    // AP Request option - use session key
+	public static final int USE_SESSION_KEY = 1;
+    // AP Request option - mutual authentication required
+	public static final int MUTUAL_REQUIRED = 2;
+	
+    // AP Request option - maximum value
+	public static final int MAX_VALUE       = 32;
+	
+    /**
+     * Class constructors
+     */
+	public ApOptions() {
+		super(MAX_VALUE);
+	}
+	
+	public ApOptions(byte[] options) {
+		super(MAX_VALUE);
+		setBytes(options);
+	}
+	
+	/**
+	 * Converts the object to a printable string
+	 */
+	public String toString() {
+		StringBuffer result = new StringBuffer();
+		if (get(MUTUAL_REQUIRED))
+			result.append("MUTUAL_REQUIRED ");
+		if (get(RESERVED))
+			result.append("RESERVED ");
+		if (get(USE_SESSION_KEY))
+			result.append("USE_SESSION_KEY ");
+		return result.toString().trim();
+	}
+}
+

Added: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/value/KdcOptions.java
==============================================================================
--- (empty file)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/value/KdcOptions.java
Thu Oct  7 12:41:14 2004
@@ -0,0 +1,108 @@
+/*
+ *   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 KdcOptions extends Options {
+    // KDC option - reserved
+	public static final int RESERVED                    = 0;
+    // KDC option - forwardable
+	public static final int FORWARDABLE                 = 1;
+    // KDC option - forwarded
+	public static final int FORWARDED                   = 2;
+    // KDC option - proxiable
+	public static final int PROXIABLE                   = 3;
+    // KDC option - proxy
+	public static final int PROXY                       = 4;
+    // KDC option - allow postdate
+	public static final int ALLOW_POSTDATE              = 5;
+    // KDC option - postdated
+	public static final int POSTDATED                   = 6;
+    // KDC option - unused7
+	public static final int UNUSED7                     = 7;
+    // KDC option - renewable
+	public static final int RENEWABLE                   = 8;
+    // KDC option - unused9
+	public static final int UNUSED9                     = 9;
+    // KDC option - unused10
+	public static final int UNUSED10                    = 10;
+    // KDC option - unused11
+	public static final int UNUSED11                    = 11;
+    // KDC option - unused12
+	public static final int UNUSED12                    = 12;
+    // KDC option - unused13
+	public static final int UNUSED13                    = 13;
+    // KDC option - disable transisted checked
+	public static final int DISABLE_TRANSISTED_CHECKED  = 26;
+    // KDC option - renewable is ok
+	public static final int RENEWABLE_OK                = 27;
+    // KDC option - encrypted key in skey
+	public static final int ENC_TKT_IN_SKEY             = 28;
+    // KDC option - renew
+	public static final int RENEW                       = 30;
+    // KDC option - validate
+	public static final int VALIDATE                    = 31;
+	
+    // KDC option - maximum value
+	public static final int MAX_VALUE                   = 32;
+	
+	/**
+	 * Class constructors
+	 */
+	public KdcOptions() {
+		super(MAX_VALUE);
+	}
+	
+	public KdcOptions(byte[] bytes) {
+		super(MAX_VALUE);
+		setBytes(bytes);
+	}
+	
+	/**
+	 * Converts the object to a printable string
+	 */
+	public String toString() {
+		StringBuffer result = new StringBuffer();
+		if (get(ALLOW_POSTDATE))
+			result.append("ALLOW_POSTDATE ");
+		if (get(DISABLE_TRANSISTED_CHECKED))
+			result.append("DISABLE_TRANSISTED_CHECKED ");
+		if (get(ENC_TKT_IN_SKEY))
+			result.append("ENC_TKT_IN_SKEY ");
+		if (get(FORWARDABLE))
+			result.append("FORWARDABLE ");
+		if (get(FORWARDED))
+			result.append("FORWARDED ");
+		if (get(POSTDATED))
+			result.append("POSTDATED ");
+		if (get(PROXIABLE))
+			result.append("PROXIABLE ");
+		if (get(PROXY))
+			result.append("PROXY ");
+		if (get(RENEW))
+			result.append("RENEW ");
+		if (get(RENEWABLE))
+			result.append("RENEWABLE ");
+		if (get(RENEWABLE_OK))
+			result.append("RENEWABLE_OK ");
+		if (get(RESERVED))
+			result.append("RESERVED ");
+		if (get(VALIDATE))
+			result.append("VALIDATE ");
+		return result.toString().trim();
+	}
+}
+

Added: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/value/Options.java
==============================================================================
--- (empty file)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/value/Options.java
Thu Oct  7 12:41:14 2004
@@ -0,0 +1,74 @@
+/*
+ *   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 abstract class Options {
+	
+	private BitSet _options;
+	private int    _maxSize;
+	
+	protected Options(int maxSize) {
+		_maxSize = maxSize;
+		_options = new BitSet(_maxSize);
+	}
+	
+	public boolean match(Options options, int option) {
+		return options.get(option) == this.get(option);
+	}
+	
+	public boolean get(int index) {
+		return _options.get(index);
+	}
+	
+	public void set(int index) {
+		_options.set(index);
+	}
+	
+	public void clear(int index) {
+		_options.clear(index);
+	}
+	
+	/*
+	 * Byte-reversing methods are an anomaly of the BouncyCastle
+	 * DERBitString endianness.  Thes methods can be removed if the
+	 * Apache Directory Snickers codecs operate differently.
+	 */
+    public byte[] getBytes() {
+        byte[] bytes = new byte[_maxSize/8];
+        for (int i=0; i<_maxSize; i++) {
+            if (_options.get(reversePosition(i))) {
+                bytes[bytes.length-i/8-1] |= 1<<(i%8);
+            }
+        }
+        return bytes;
+    }
+	
+    protected void setBytes(byte[] bytes) {
+	    for (int i=0; i<bytes.length*8; i++) {
+	        if ((bytes[bytes.length-i/8-1]&(1<<(i%8))) > 0) {
+	            _options.set(reversePosition(i));
+	        }
+	    }
+    }
+    
+	private int reversePosition(int position) {
+		return _maxSize - 1 - position;
+	}
+}
+

Added: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/value/TicketFlags.java
==============================================================================
--- (empty file)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/value/TicketFlags.java
Thu Oct  7 12:41:14 2004
@@ -0,0 +1,98 @@
+/*
+ *   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 TicketFlags extends Options {
+	// Ticket flag - reserved
+	public static final int RESERVED                 = 0;
+	// Ticket flag - forwardable
+	public static final int FORWARDABLE              = 1;
+	// Ticket flag - forwarded
+	public static final int FORWARDED                = 2;
+	// Ticket flag - proxiable
+	public static final int PROXIABLE                = 3;
+	// Ticket flag - proxy
+	public static final int PROXY                    = 4;
+	// Ticket flag - may be postdated
+	public static final int MAY_POSTDATE             = 5;
+	// Ticket flag - postdated
+	public static final int POSTDATED                = 6;
+	// Ticket flag - invalid
+	public static final int INVALID                  = 7;
+	// Ticket flag - renewable
+	public static final int RENEWABLE                = 8;
+	// Ticket flag - initial
+	public static final int INITIAL                  = 9;
+	// Ticket flag - pre-authentication
+	public static final int PRE_AUTHENT              = 10;
+	// Ticket flag - hardware authentication
+	public static final int HW_AUTHENT               = 11;
+	// Ticket flag - transitedEncoding policy checked
+	public static final int TRANSITED_POLICY_CHECKED = 12;
+	// Ticket flag - OK as delegate
+	public static final int OK_AS_DELEGATE           = 13;
+	
+	// Ticket flag - maximum value
+	public static final int MAX_VALUE                = 32;
+
+	/**
+	 * Class constructor
+	 */
+	public TicketFlags() {
+		super(MAX_VALUE);
+	}
+	
+	public TicketFlags(byte[] options) {
+		super(MAX_VALUE);
+		setBytes(options);
+	}
+
+	/**
+	 * Converts the object to a printable string
+	 */
+	public String toString() {
+		StringBuffer result = new StringBuffer();
+		if (get(FORWARDABLE))
+			result.append("FORWARDABLE ");
+		if (get(FORWARDED))
+			result.append("FORWARDED ");
+		if (get(PROXIABLE))
+			result.append("PROXIABLE ");
+		if (get(PROXY))
+			result.append("PROXY ");
+		if (get(MAY_POSTDATE))
+			result.append("MAY_POSTDATE ");
+		if (get(POSTDATED))
+			result.append("POSTDATED ");
+		if (get(INVALID))
+			result.append("INVALID ");
+		if (get(RENEWABLE))
+			result.append("RENEWABLE ");
+		if (get(INITIAL))
+			result.append("INITIAL ");
+		if (get(PRE_AUTHENT))
+			result.append("PRE_AUTHENT ");
+		if (get(HW_AUTHENT))
+			result.append("HW_AUTHENT ");
+		if (get(TRANSITED_POLICY_CHECKED))
+			result.append("TRANSITED_POLICY_CHECKED ");
+		if (get(OK_AS_DELEGATE))
+			result.append("OPTS_OK_AS_DELEGATE ");
+		return result.toString().trim();
+	}
+}
+

Mime
View raw message