directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: rev 55694 - in incubator/directory/kerberos/trunk/source/main/org/apache/kerberos: io/decoder messages messages/value
Date Wed, 27 Oct 2004 13:04:25 GMT
Author: erodriguez
Date: Wed Oct 27 06:04:24 2004
New Revision: 55694

Added:
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/value/RequestBody.java
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/value/RequestBodyModifier.java
Modified:
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/io/decoder/KdcRequestDecoder.java
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/KdcRequest.java
Log:
Request body implementation, with decoder updates.

Modified: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/io/decoder/KdcRequestDecoder.java
==============================================================================
--- incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/io/decoder/KdcRequestDecoder.java
(original)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/io/decoder/KdcRequestDecoder.java
Wed Oct 27 06:04:24 2004
@@ -52,7 +52,7 @@
 		MessageType msgType = MessageType.NULL;
 		
 		PreAuthenticationData[] paData = null;
-		KdcReqBody reqBody = null;
+		RequestBody requestBody = null;
 		
 		for (Enumeration e = sequence.getObjects(); e.hasMoreElements();) {
 			DERTaggedObject object = ((DERTaggedObject) e.nextElement());
@@ -73,7 +73,7 @@
 					break;
 				case 4:
 					DERSequence tag4 = (DERSequence)derObject;
-					reqBody = decodeKdcRequestBody(tag4);
+					requestBody = decodeRequestBody(tag4);
 					break;
 			    default:
 			    	System.out.println(derObject);
@@ -81,7 +81,7 @@
 			}
 		}
 		
-		return new KdcRequest(pvno, msgType, paData, reqBody);
+		return new KdcRequest(pvno, msgType, paData, requestBody);
 	}
 
 	/*
@@ -143,9 +143,9 @@
 	                         -- Encrypted AuthorizationData encoding
 	            additional-tickets[11]       SEQUENCE OF Ticket OPTIONAL
 	}*/
-	private KdcReqBody decodeKdcRequestBody(DERSequence sequence) throws IOException {
+	private RequestBody decodeRequestBody(DERSequence sequence) throws IOException {
 		
-		KdcReqBody reqBody = new KdcReqBody();
+		RequestBodyModifier requestBodyModifier = new RequestBodyModifier();
 		
 		for (Enumeration e = sequence.getObjects(); e.hasMoreElements();) {
 			DERTaggedObject object = ((DERTaggedObject) e.nextElement());
@@ -154,59 +154,59 @@
 			switch (tag) {
 				case 0:
 					DERBitString kdcOptions = (DERBitString)derObject;
-					reqBody.setKdcOptions(new KdcOptions(kdcOptions.getBytes()));
+					requestBodyModifier.setKdcOptions(new KdcOptions(kdcOptions.getBytes()));
 					break;
 				case 1:
 					DERSequence cName = (DERSequence)derObject;
-					reqBody.setCname(decodePrincipalName(cName));
+					requestBodyModifier.setCname(decodePrincipalName(cName));
 					break;
 				case 2:
 					DERGeneralString realm = (DERGeneralString)derObject;
-					reqBody.setRealm(new Realm(realm.getString()));
+					requestBodyModifier.setRealm(new Realm(realm.getString()));
 					break;
 				case 3:
 					DERSequence sname = (DERSequence)derObject;
-					reqBody.setSname(decodePrincipalName(sname));
+					requestBodyModifier.setSname(decodePrincipalName(sname));
 					break;
 				case 4:
 					DERGeneralizedTime from = (DERGeneralizedTime)derObject;
-					reqBody.setFrom(decodeKerberosTime(from));
+					requestBodyModifier.setFrom(decodeKerberosTime(from));
 					break;
 				case 5:
 					DERGeneralizedTime till = (DERGeneralizedTime)derObject;
-					reqBody.setTill(decodeKerberosTime(till));
+					requestBodyModifier.setTill(decodeKerberosTime(till));
 					break;
 				case 6:
 					DERGeneralizedTime rtime = (DERGeneralizedTime)derObject;
-					reqBody.setRtime(decodeKerberosTime(rtime));
+					requestBodyModifier.setRtime(decodeKerberosTime(rtime));
 					break;
 				case 7:
 					DERInteger nonce = (DERInteger)derObject;
-					reqBody.setNonce(nonce.getValue().intValue());
+					requestBodyModifier.setNonce(nonce.getValue().intValue());
 					break;
 				case 8:
 					DERSequence etype = (DERSequence)derObject;
-					reqBody.setEType(decodeEncryptionType(etype));
+					requestBodyModifier.setEType(decodeEncryptionType(etype));
 					break;
 				case 9:
 					DERSequence hostAddresses = (DERSequence)derObject;
-					reqBody.setAddresses(decodeHostAddresses(hostAddresses));
+					requestBodyModifier.setAddresses(decodeHostAddresses(hostAddresses));
 					break;
 				case 10:
 					DERSequence encryptedData = (DERSequence)derObject;
-					reqBody.setEncAuthorizationData(decodeEncryptedData(encryptedData));
+					requestBodyModifier.setEncAuthorizationData(decodeEncryptedData(encryptedData));
 					break;
 				case 11:
 					DERSequence tag11 = (DERSequence)derObject;
-					reqBody.setAdditionalTickets(decodeTickets(tag11));
+					requestBodyModifier.setAdditionalTickets(decodeTickets(tag11));
 					break;
 			    default:
-			    	System.out.println("****** " + object.getObject());
+			    	System.out.println(derObject);
 			    	break;
 			}
 		}
 		
-		return reqBody;
+		return requestBodyModifier.getRequestBody();
 	}
 	
 	protected Ticket[] decodeTickets(DERSequence sequence) throws IOException {

Modified: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/KdcRequest.java
==============================================================================
--- incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/KdcRequest.java
(original)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/KdcRequest.java
Wed Oct 27 06:04:24 2004
@@ -23,12 +23,15 @@
 public class KdcRequest extends KerberosMessage {
 
 	private PreAuthenticationData[] _preAuthData; //optional
-	private KdcReqBody              _requestBody;
+	private RequestBody             _requestBody;
+	
+	// TODO - this is protocol workflow and a violation of the immutable request
+	private KerberosTime            _requestedRenewalTime;
 
 	/**
 	 * Class constructor
 	 */
-	public KdcRequest(int pvno, MessageType msgType, PreAuthenticationData[] paData, KdcReqBody
reqBody) {
+	public KdcRequest(int pvno, MessageType msgType, PreAuthenticationData[] paData, RequestBody
reqBody) {
 		super(pvno, msgType);
 		_preAuthData = paData;
 		_requestBody = reqBody;
@@ -41,7 +44,7 @@
 		_preAuthData = paData;
 	}
 	
-	// KdcReqBody delegate methods
+	// RequestBody delegate methods
 	public Ticket[] getAdditionalTickets() {
 		return _requestBody.getAdditionalTickets();
 	}
@@ -70,7 +73,10 @@
 		return _requestBody.getNonce();
 	}
 	public KerberosTime getRtime() {
-		return _requestBody.getRtime();
+		if (_requestedRenewalTime == null) {
+			return _requestBody.getRtime();
+		}
+		return _requestedRenewalTime;
 	}
 	public PrincipalName getSname() {
 		return _requestBody.getSname();
@@ -80,10 +86,10 @@
 	}
 	
 	public void setRtime(KerberosTime rtime) {
-		_requestBody.setRtime(rtime);
+		_requestedRenewalTime = rtime;
 	}
 	
-	// KdcReqBody KdcOptions delegate accesors
+	// RequestBody KdcOptions delegate accesors
 	public boolean getOption(int option) {
 		return _requestBody.getKdcOptions().get(option);
 	}

Added: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/value/RequestBody.java
==============================================================================
--- (empty file)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/value/RequestBody.java
Wed Oct 27 06:04:24 2004
@@ -0,0 +1,93 @@
+/*
+ *   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 org.apache.kerberos.crypto.encryption.*;
+import org.apache.kerberos.messages.components.*;
+
+public class RequestBody {
+
+	private KdcOptions       _kdcOptions;
+	private PrincipalName    _cname;                //optional in TgsReq only
+	private Realm            _realm;
+	private PrincipalName    _sname;                //optional
+	private KerberosTime     _from;                 //optional
+	private KerberosTime     _till;
+	private KerberosTime     _rtime;                //optional
+	private int              _nonce;
+	private EncryptionType[] _eType;
+	private HostAddresses    _addresses;            //optional
+	private EncryptedData    _encAuthorizationData; //optional
+	private Ticket[]         _additionalTickets;    //optional
+
+	public RequestBody(KdcOptions kdcOptions, PrincipalName cname, Realm realm,
+			PrincipalName sname, KerberosTime from, KerberosTime till, KerberosTime rtime,
+			int nonce, EncryptionType[] eType, HostAddresses addresses, EncryptedData encAuthorizationData,
+			Ticket[] additionalTickets) {
+		
+		_kdcOptions           = kdcOptions;
+		_cname                = cname;
+		_realm                = realm;
+		_sname                = sname;
+		_from                 = from;
+		_till                 = till;
+		_rtime                = rtime;
+		_nonce                = nonce;
+		_eType                = eType;
+		_addresses            = addresses;
+		_encAuthorizationData = encAuthorizationData;
+		_additionalTickets    = additionalTickets;
+	}
+
+	public Ticket[] getAdditionalTickets() {
+		return _additionalTickets;
+	}
+	public HostAddresses getAddresses() {
+		return _addresses;
+	}
+	public PrincipalName getCname() {
+		return _cname;
+	}
+	public Realm getRealm() {
+		return _realm;
+	}
+	public EncryptedData getEncAuthorizationData() {
+		return _encAuthorizationData;
+	}
+	public EncryptionType[] getEType() {
+		return _eType;
+	}
+	public KerberosTime getFrom() {
+		return _from;
+	}
+	public KdcOptions getKdcOptions() {
+		return _kdcOptions;
+	}
+	public int getNonce() {
+		return _nonce;
+	}
+	public KerberosTime getRtime() {
+		return _rtime;
+	}
+	public PrincipalName getSname() {
+		return _sname;
+	}
+	public KerberosTime getTill() {
+		return _till;
+	}
+}
+

Added: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/value/RequestBodyModifier.java
==============================================================================
--- (empty file)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/value/RequestBodyModifier.java
Wed Oct 27 06:04:24 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.value;
+
+import org.apache.kerberos.crypto.encryption.*;
+import org.apache.kerberos.messages.components.*;
+
+public class RequestBodyModifier {
+	
+	private KdcOptions       _kdcOptions;
+	private PrincipalName    _cname;                //optional in TgsReq only
+	private Realm            _realm;
+	private PrincipalName    _sname;                //optional
+	private KerberosTime     _from;                 //optional
+	private KerberosTime     _till;
+	private KerberosTime     _rtime;                //optional
+	private int              _nonce;
+	private EncryptionType[] _eType;
+	private HostAddresses    _addresses;            //optional
+	private EncryptedData    _encAuthorizationData; //optional
+	private Ticket[]         _additionalTickets;    //optional
+	
+	public RequestBody getRequestBody() {
+		return new RequestBody(_kdcOptions, _cname, _realm, _sname, _from, _till, _rtime,
+			_nonce, _eType, _addresses, _encAuthorizationData, _additionalTickets);
+	}
+	
+	public void setAdditionalTickets(Ticket[] tickets) {
+		_additionalTickets = tickets;
+	}
+	public void setAddresses(HostAddresses addresses) {
+		_addresses = addresses;
+	}
+	public void setCname(PrincipalName cname) {
+		_cname = cname;
+	}
+	public void setRealm(Realm realm) {
+		_realm = realm;
+	}
+	public void setEncAuthorizationData(EncryptedData authorizationData) {
+		_encAuthorizationData = authorizationData;
+	}
+	public void setEType(EncryptionType[] type) {
+		_eType = type;
+	}
+	public void setFrom(KerberosTime from) {
+		_from = from;
+	}
+	public void setKdcOptions(KdcOptions options) {
+		_kdcOptions = options;
+	}
+	public void setNonce(int nonce) {
+		_nonce = nonce;
+	}
+	public void setRtime(KerberosTime rtime) {
+		_rtime = rtime;
+	}
+	public void setSname(PrincipalName sname) {
+		_sname = sname;
+	}
+	public void setTill(KerberosTime till) {
+		_till = till;
+	}
+}
+

Mime
View raw message