directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: rev 51858 - incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages
Date Sun, 03 Oct 2004 23:48:48 GMT
Author: erodriguez
Date: Sun Oct  3 16:48:46 2004
New Revision: 51858

Added:
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/KdcReply.java
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/KdcRequest.java
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/KerberosMessage.java
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/MessageType.java
Log:
kerberos message base classes

Added: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/KdcReply.java
==============================================================================
--- (empty file)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/KdcReply.java
Sun Oct  3 16:48:46 2004
@@ -0,0 +1,161 @@
+/*
+ *   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;
+
+import org.apache.kerberos.kdc.*;
+import org.apache.kerberos.messages.components.*;
+import org.apache.kerberos.messages.value.*;
+
+public class KdcReply extends KerberosMessage {
+
+	private PreAuthenticationData[] _paData;  //optional
+	private Realm                   _crealm;
+	private PrincipalName           _cname;
+	private Ticket                  _ticket;
+	
+	private EncKdcRepPart _encKDCRepPart = new EncKdcRepPart();
+	private EncryptedData _encPart       = new EncryptedData();
+
+	public KdcReply(MessageType msgType) {
+		super(LocalConfig.PVNO, msgType);
+	}
+	
+	public KdcReply(PreAuthenticationData[] paData, Realm crealm, PrincipalName cname,
+			Ticket ticket, EncryptedData encPart, MessageType msgType) {
+		
+		this(msgType);
+		_paData  = paData;
+		_crealm  = crealm;
+		_cname   = cname;
+		_ticket  = ticket;
+		_encPart = encPart;
+	}
+	
+	// getters
+	public PrincipalName getCname() {
+		return _cname;
+	}
+	public Realm getCrealm() {
+		return _crealm;
+	}
+	public EncryptedData getEncPart() {
+		return _encPart;
+	}
+	public PreAuthenticationData[] getPaData() {
+		return _paData;
+	}
+	public Ticket getTicket() {
+		return _ticket;
+	}
+	
+	// setters
+	public void setCname(PrincipalName cname) {
+		_cname = cname;
+	}
+	public void setCrealm(Realm crealm) {
+		_crealm = crealm;
+	}
+	public void setEncKDCRepPart(EncKdcRepPart repPart) {
+		_encKDCRepPart = repPart;
+	}
+	public void setEncPart(EncryptedData part) {
+		_encPart = part;
+	}
+	public void setPaData(PreAuthenticationData[] data) {
+		_paData = data;
+	}
+	public void setTicket(Ticket ticket) {
+		_ticket = ticket;
+	}
+	
+	// EncKdcRepPart delegate getters
+	public KerberosTime getAuthTime() {
+		return _encKDCRepPart.getAuthTime();
+	}
+	public HostAddresses getClientAddresses() {
+		return _encKDCRepPart.getClientAddresses();
+	}
+	public KerberosTime getEndTime() {
+		return _encKDCRepPart.getEndTime();
+	}
+	public TicketFlags getFlags() {
+		return _encKDCRepPart.getFlags();
+	}
+	public EncryptionKey getKey() {
+		return _encKDCRepPart.getKey();
+	}
+	public KerberosTime getKeyExpiration() {
+		return _encKDCRepPart.getKeyExpiration();
+	}
+	public LastRequest getLastRequest() {
+		return _encKDCRepPart.getLastRequest();
+	}
+	public int getNonce() {
+		return _encKDCRepPart.getNonce();
+	}
+	public KerberosTime getRenewTill() {
+		return _encKDCRepPart.getRenewTill();
+	}
+	public PrincipalName getServerName() {
+		return _encKDCRepPart.getServerName();
+	}
+	public Realm getServerRealm() {
+		return _encKDCRepPart.getServerRealm();
+	}
+	public KerberosTime getStartTime() {
+		return _encKDCRepPart.getStartTime();
+	}
+	
+	// EncKdcRepPart delegate setters
+	public void setAuthTime(KerberosTime time) {
+		_encKDCRepPart.setAuthTime(time);
+	}
+	public void setClientAddresses(HostAddresses addresses) {
+		_encKDCRepPart.setClientAddresses(addresses);
+	}
+	public void setEndTime(KerberosTime time) {
+		_encKDCRepPart.setEndTime(time);
+	}
+	public void setFlags(TicketFlags flags) {
+		_encKDCRepPart.setFlags(flags);
+	}
+	public void setKey(EncryptionKey key) {
+		_encKDCRepPart.setKey(key);
+	}
+	public void setKeyExpiration(KerberosTime expiration) {
+		_encKDCRepPart.setKeyExpiration(expiration);
+	}
+	public void setLastRequest(LastRequest request) {
+		_encKDCRepPart.setLastRequest(request);
+	}
+	public void setNonce(int nonce) {
+		_encKDCRepPart.setNonce(nonce);
+	}
+	public void setRenewTill(KerberosTime till) {
+		_encKDCRepPart.setRenewTill(till);
+	}
+	public void setServerName(PrincipalName name) {
+		_encKDCRepPart.setServerName(name);
+	}
+	public void setServerRealm(Realm realm) {
+		_encKDCRepPart.setServerRealm(realm);
+	}
+	public void setStartTime(KerberosTime time) {
+		_encKDCRepPart.setStartTime(time);
+	}
+}
+

Added: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/KdcRequest.java
==============================================================================
--- (empty file)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/KdcRequest.java
Sun Oct  3 16:48:46 2004
@@ -0,0 +1,97 @@
+/*
+ *   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;
+
+import org.apache.kerberos.crypto.encryption.*;
+import org.apache.kerberos.messages.components.*;
+import org.apache.kerberos.messages.value.*;
+
+public class KdcRequest extends KerberosMessage {
+
+	private PreAuthenticationData[] _preAuthData; //optional
+	private KdcReqBody              _requestBody;
+
+	/**
+	 * Class constructor
+	 */
+	public KdcRequest(int pvno, MessageType msgType, PreAuthenticationData[] paData, KdcReqBody
reqBody) {
+		super(pvno, msgType);
+		_preAuthData = paData;
+		_requestBody = reqBody;
+	}
+
+	public PreAuthenticationData[] getPaData() {
+		return _preAuthData;
+	}
+	public void setPaData(PreAuthenticationData[] paData) {
+		_preAuthData = paData;
+	}
+	
+	// KdcReqBody delegate methods
+	public Ticket[] getAdditionalTickets() {
+		return _requestBody.getAdditionalTickets();
+	}
+	public HostAddresses getAddresses() {
+		return _requestBody.getAddresses();
+	}
+	public PrincipalName getCname() {
+		return _requestBody.getCname();
+	}
+	public Realm getRealm() {
+		return _requestBody.getRealm();
+	}
+	public EncryptedData getEncAuthorizationData() {
+		return _requestBody.getEncAuthorizationData();
+	}
+	public EncryptionType[] getEType() {
+		return _requestBody.getEType();
+	}
+	public KerberosTime getFrom() {
+		return _requestBody.getFrom();
+	}
+	public KdcOptions getKdcOptions() {
+		return _requestBody.getKdcOptions();
+	}
+	public int getNonce() {
+		return _requestBody.getNonce();
+	}
+	public KerberosTime getRtime() {
+		return _requestBody.getRtime();
+	}
+	public PrincipalName getSname() {
+		return _requestBody.getSname();
+	}
+	public KerberosTime getTill() {
+		return _requestBody.getTill();
+	}
+	
+	public void setRtime(KerberosTime rtime) {
+		_requestBody.setRtime(rtime);
+	}
+	
+	// KdcReqBody KdcOptions delegate accesors
+	public boolean getOption(int option) {
+		return _requestBody.getKdcOptions().get(option);
+	}
+	public void setOption(int option) {
+		_requestBody.getKdcOptions().set(option);
+	}
+	public void clearOption(int option) {
+		_requestBody.getKdcOptions().clear(option);
+	}
+}
+

Added: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/KerberosMessage.java
==============================================================================
--- (empty file)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/KerberosMessage.java
Sun Oct  3 16:48:46 2004
@@ -0,0 +1,42 @@
+/*
+ *   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;
+
+public class KerberosMessage {
+	
+	private int         _protocolVersionNumber;
+	private MessageType _messageType;
+	
+	public KerberosMessage(int versionNumber, MessageType type) {
+		_protocolVersionNumber = versionNumber;
+		_messageType           = type;
+	}
+	
+	public MessageType getMessageType() {
+		return _messageType;
+	}
+	public void setMessageType(MessageType type) {
+		_messageType = type;
+	}
+	public int getProtocolVersionNumber() {
+		return _protocolVersionNumber;
+	}
+	public void setProtocolVersionNumber(int versionNumber) {
+		_protocolVersionNumber = versionNumber;
+	}
+}
+

Added: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/MessageType.java
==============================================================================
--- (empty file)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/MessageType.java
Sun Oct  3 16:48:46 2004
@@ -0,0 +1,79 @@
+/*
+ *   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;
+
+import java.util.*;
+
+public final class MessageType implements Comparable {
+
+	/**
+	 * Enumeration elements are constructed once upon class loading.
+	 * Order of appearance here determines the order of compareTo.
+	 */
+	public static final MessageType NULL        = new MessageType(0,  "null");
+	public static final MessageType KRB_AS_REQ  = new MessageType(10, "initial authentication
request");
+	public static final MessageType KRB_AS_REP  = new MessageType(11, "initial authentication
response");
+	public static final MessageType KRB_TGS_REQ = new MessageType(12, "request for authentication
based on TGT");
+	public static final MessageType KRB_TGS_REP = new MessageType(13, "response to authentication
based on TGT");
+	public static final MessageType KRB_AP_REQ  = new MessageType(14, "application request");
+	public static final MessageType KRB_AP_REP  = new MessageType(15, "application response");
+	public static final MessageType KRB_SAFE    = new MessageType(20, "safe (checksummed) application
message");
+	public static final MessageType KRB_PRIV    = new MessageType(21, "private (encrypted) application
message");
+	public static final MessageType KRB_CRED    = new MessageType(22, "private (encrypted) message
to forward credentials");
+	public static final MessageType KRB_ERROR   = new MessageType(30, "error response");
+
+	public String toString() {
+		return _fName + " (" + _fOrdinal + ")";
+	}
+
+	public int compareTo(Object that) {
+		return _fOrdinal - ((MessageType) that)._fOrdinal;
+	}
+
+	public static MessageType 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 MessageType(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 MessageType[] fValues = {NULL, KRB_AS_REQ, KRB_AS_REP, KRB_TGS_REQ,
+			KRB_TGS_REP, KRB_AP_REQ, KRB_AP_REP, KRB_SAFE, KRB_PRIV, KRB_CRED, KRB_ERROR};
+	// VALUES needs to be located here, otherwise illegal forward reference
+	public static final List VALUES = Collections.unmodifiableList(Arrays.asList(fValues));
+
+}
+

Mime
View raw message