directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: rev 53816 - incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/components
Date Tue, 05 Oct 2004 18:25:02 GMT
Author: erodriguez
Date: Tue Oct  5 11:24:56 2004
New Revision: 53816

Added:
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/components/Authenticator.java
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/components/MessageComponentType.java
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/components/Ticket.java
Log:
primary kerberos message components

Added: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/components/Authenticator.java
==============================================================================
--- (empty file)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/components/Authenticator.java
Tue Oct  5 11:24:56 2004
@@ -0,0 +1,110 @@
+/*
+ *   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.components;
+
+import org.apache.kerberos.kdc.*;
+import org.apache.kerberos.messages.value.*;
+
+public class Authenticator {
+	
+	private int               _versionNumber;
+	private Realm             _clientRealm;
+	private PrincipalName     _clientName;
+	private Checksum          _checksum;
+	private int               _clientMicroSecond;
+	private KerberosTime      _clientTime;
+	private EncryptionKey     _subSessionKey;
+	private int               _sequenceNumber;
+	private AuthorizationData _authorizationData;
+	
+	public Authenticator() {
+		// TODO - probably temp
+	}
+
+	public Authenticator(Realm crealm, PrincipalName cname, Checksum cksum,	int cusec,
+			KerberosTime ctime, EncryptionKey subKey, int seqNumber,
+			AuthorizationData authorizationData) {
+		
+		_versionNumber     = LocalConfig.AUTHENTICATOR_VNO;
+		_clientRealm       = crealm;
+		_clientName        = cname;
+		_checksum          = cksum;
+		_clientMicroSecond = cusec;
+		_clientTime        = ctime;
+		_subSessionKey     = subKey;
+		_sequenceNumber    = seqNumber;
+		_authorizationData = authorizationData;
+	}
+	
+	public PrincipalName getClientName() {
+		return _clientName;
+	}
+	public Realm getClientRealm() {
+		return _clientRealm;
+	}
+	public KerberosTime getClientTime() {
+		return _clientTime;
+	}
+	public int getClientMicroSecond() {
+		return _clientMicroSecond;
+	}
+	public AuthorizationData getAuthorizationData() {
+		return _authorizationData;
+	}
+	public Checksum getChecksum() {
+		return _checksum;
+	}
+	public int getSequenceNumber() {
+		return _sequenceNumber;
+	}
+	public EncryptionKey getSubSessionKey() {
+		return _subSessionKey;
+	}
+	public int getVersionNumber() {
+		return _versionNumber;
+	}
+	
+	// setters
+	public void setAuthorizationData(AuthorizationData data) {
+		_authorizationData = data;
+	}
+	public void setChecksum(Checksum checksum) {
+		_checksum = checksum;
+	}
+	public void setClientMicroSecond(int microSecond) {
+		_clientMicroSecond = microSecond;
+	}
+	public void setClientName(PrincipalName name) {
+		_clientName = name;
+	}
+	public void setClientRealm(Realm realm) {
+		_clientRealm = realm;
+	}
+	public void setClientTime(KerberosTime time) {
+		_clientTime = time;
+	}
+	public void setSequenceNumber(int number) {
+		_sequenceNumber = number;
+	}
+	public void setSubSessionKey(EncryptionKey sessionKey) {
+		_subSessionKey = sessionKey;
+	}
+	public void setVersionNumber(int number) {
+		_versionNumber = number;
+	}
+}
+

Added: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/components/MessageComponentType.java
==============================================================================
--- (empty file)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/components/MessageComponentType.java
Tue Oct  5 11:24:56 2004
@@ -0,0 +1,80 @@
+/*
+ *   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.components;
+
+import java.util.*;
+
+/**
+ * Type-safe enumerator for message component types
+ */
+public class MessageComponentType implements Comparable {
+	/**
+	 * Enumeration elements are constructed once upon class loading.
+	 * Order of appearance here determines the order of compareTo.
+	 */
+	public static final MessageComponentType NULL                  = new MessageComponentType(0,
 "null");
+	public static final MessageComponentType KRB_TKT               = new MessageComponentType(1,
 "ticket");
+	public static final MessageComponentType KRB_AUTHENTICATOR     = new MessageComponentType(2,
 "authenticator");
+	public static final MessageComponentType KRB_ENC_TKT_PART      = new MessageComponentType(3,
 "encrypted ticket part");
+	public static final MessageComponentType KRB_ENC_AS_REP_PART   = new MessageComponentType(25,
"encrypted initial authentication part");
+	public static final MessageComponentType KRB_ENC_TGS_REP_PART  = new MessageComponentType(26,
"encrypted TGS request part");
+	public static final MessageComponentType KRB_ENC_AP_REP_PART   = new MessageComponentType(27,
"encrypted application request part");
+	public static final MessageComponentType KRB_ENC_KRB_PRIV_PART = new MessageComponentType(28,
"encrypted application message part");
+	public static final MessageComponentType KRB_ENC_KRB_CRED_PART = new MessageComponentType(29,
"encrypted credentials forward part");
+
+	public String toString() {
+		return _fName + " (" + _fOrdinal + ")";
+	}
+
+	public int compareTo(Object that) {
+		return _fOrdinal - ((MessageComponentType) that)._fOrdinal;
+	}
+
+	public static MessageComponentType 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 MessageComponentType(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 MessageComponentType[] fValues = {NULL, KRB_TKT, KRB_AUTHENTICATOR,
+			KRB_ENC_TKT_PART, KRB_ENC_AS_REP_PART, KRB_ENC_TGS_REP_PART, KRB_ENC_AP_REP_PART,
+			KRB_ENC_KRB_PRIV_PART, KRB_ENC_KRB_CRED_PART};
+	// VALUES needs to be located here, otherwise illegal forward reference
+	public static final List VALUES = Collections.unmodifiableList(Arrays.asList(fValues));
+
+}
+

Added: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/components/Ticket.java
==============================================================================
--- (empty file)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/components/Ticket.java
Tue Oct  5 11:24:56 2004
@@ -0,0 +1,158 @@
+/*
+ *   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.components;
+
+import org.apache.kerberos.kdc.*;
+import org.apache.kerberos.messages.value.*;
+
+/**
+ * Ticket message component as handed out by the ticket granting service
+ */
+public class Ticket {
+
+	private int           _ticketVersionNumber;
+	private Realm         _realm;
+	private PrincipalName _serverName;
+	
+	private EncTicketPart _encTicketPart = new EncTicketPart();
+	private EncryptedData _encPart       = new EncryptedData();
+	
+	public Ticket() {
+		_ticketVersionNumber = LocalConfig.TICKET_VNO;
+		// used to generate new Tickets during reply construction
+	}
+
+	public Ticket(Realm realm, PrincipalName serverName, EncryptedData encPart) {
+		_ticketVersionNumber = LocalConfig.TICKET_VNO;
+		_realm               = realm;
+		_serverName          = serverName;
+		_encPart             = encPart;
+	}
+	
+	// getters
+	public EncryptedData getEncPart() {
+		return _encPart;
+	}
+	public Realm getRealm() {
+		return _realm;
+	}
+	public PrincipalName getServerName() {
+		return _serverName;
+	}
+	public int getTicketVersionNumber() {
+		return _ticketVersionNumber;
+	}
+	
+	// setters
+	public void setEncTicketPart(EncTicketPart part) {
+		_encTicketPart = part;
+	}
+	public void setEncPart(EncryptedData part) {
+		_encPart = part;
+	}
+	public void setRealm(Realm _realm) {
+		this._realm = _realm;
+	}
+	public void setServerName(PrincipalName name) {
+		_serverName = name;
+	}
+	public void setTicketVersionNumber(int versionNumber) {
+		_ticketVersionNumber = versionNumber;
+	}
+	
+	// EncTicketPart delegate getters
+	public AuthorizationData getAuthorizationData() {
+		return _encTicketPart.getAuthorizationData();
+	}
+	public KerberosTime getAuthtime() {
+		return _encTicketPart.getAuthtime();
+	}
+	public HostAddresses getClientAddresses() {
+		return _encTicketPart.getClientAddresses();
+	}
+	public PrincipalName getClientName() {
+		return _encTicketPart.getClientName();
+	}
+	public Realm getClientRealm() {
+		return _encTicketPart.getClientRealm();
+	}
+	public KerberosTime getEndTime() {
+		return _encTicketPart.getEndTime();
+	}
+	public TicketFlags getFlags() {
+		return _encTicketPart.getFlags();
+	}
+	public KerberosTime getRenewTill() {
+		return _encTicketPart.getRenewTill();
+	}
+	public EncryptionKey getSessionKey() {
+		return _encTicketPart.getSessionKey();
+	}
+	public KerberosTime getStartTime() {
+		return _encTicketPart.getStartTime();
+	}
+	public TransitedEncoding getTransitedEncoding() {
+		return _encTicketPart.getTransitedEncoding();
+	}
+	
+	// EncTicketPart TicketFlag delegates 
+	public boolean getFlag(int flag) {
+		return _encTicketPart.getFlags().get(flag);
+	}
+	public void setFlag(int flag) {
+		_encTicketPart.getFlags().set(flag);
+	}
+	public void clearFlag(int flag) {
+		_encTicketPart.getFlags().clear(flag);
+	}
+	
+	// EncTicketPart delegate setters 
+	public void setAuthorizationData(AuthorizationData data) {
+		_encTicketPart.setAuthorizationData(data);
+	}
+	public void setAuthtime(KerberosTime authtime) {
+		_encTicketPart.setAuthtime(authtime);
+	}
+	public void setClientAddresses(HostAddresses addresses) {
+		_encTicketPart.setClientAddresses(addresses);
+	}
+	public void setClientName(PrincipalName name) {
+		_encTicketPart.setClientName(name);
+	}
+	public void setClientRealm(Realm realm) {
+		_encTicketPart.setClientRealm(realm);
+	}
+	public void setEndTime(KerberosTime time) {
+		_encTicketPart.setEndTime(time);
+	}
+	public void setFlags(TicketFlags flags) {
+		_encTicketPart.setFlags(flags);
+	}
+	public void setRenewTill(KerberosTime till) {
+		_encTicketPart.setRenewTill(till);
+	}
+	public void setSessionKey(EncryptionKey key) {
+		_encTicketPart.setSessionKey(key);
+	}
+	public void setStartTime(KerberosTime time) {
+		_encTicketPart.setStartTime(time);
+	}
+	public void setTransitedEncoding(TransitedEncoding encoding) {
+		_encTicketPart.setTransitedEncoding(encoding);
+	}
+}
+

Mime
View raw message