directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: rev 57038 - in incubator/directory/kerberos/trunk/kerberos/src/java/org/apache/kerberos: io/decoder messages messages/value
Date Tue, 09 Nov 2004 13:28:59 GMT
Author: erodriguez
Date: Tue Nov  9 05:28:58 2004
New Revision: 57038

Added:
   incubator/directory/kerberos/trunk/kerberos/src/java/org/apache/kerberos/messages/value/EncryptedDataModifier.java
Modified:
   incubator/directory/kerberos/trunk/kerberos/src/java/org/apache/kerberos/io/decoder/KerberosMessageDecoder.java
   incubator/directory/kerberos/trunk/kerberos/src/java/org/apache/kerberos/messages/KdcReply.java
   incubator/directory/kerberos/trunk/kerberos/src/java/org/apache/kerberos/messages/value/EncryptedData.java
Log:
Refactored EncryptedData to immutable value, mutable companion.

Modified: incubator/directory/kerberos/trunk/kerberos/src/java/org/apache/kerberos/io/decoder/KerberosMessageDecoder.java
==============================================================================
--- incubator/directory/kerberos/trunk/kerberos/src/java/org/apache/kerberos/io/decoder/KerberosMessageDecoder.java
(original)
+++ incubator/directory/kerberos/trunk/kerberos/src/java/org/apache/kerberos/io/decoder/KerberosMessageDecoder.java
Tue Nov  9 05:28:58 2004
@@ -78,7 +78,7 @@
 	}*/
 	protected EncryptedData decodeEncryptedData(DERSequence sequence) {
 		
-		EncryptedData data = new EncryptedData();
+		EncryptedDataModifier modifier = new EncryptedDataModifier();
 		
 		for (Enumeration e = sequence.getObjects(); e.hasMoreElements();) {
 			DERTaggedObject object = ((DERTaggedObject) e.nextElement());
@@ -87,22 +87,22 @@
 			switch (tag) {
 				case 0:
 					DERInteger etype = (DERInteger)derObject;
-					data.setEncryptionType(EncryptionType.getTypeByOrdinal(etype.getValue().intValue()));
+					modifier.setEncryptionType(EncryptionType.getTypeByOrdinal(etype.getValue().intValue()));
 					break;
 				case 1:
 					DERInteger kvno = (DERInteger)derObject;
-					data.setKeyVersion(kvno.getValue().intValue());
+					modifier.setKeyVersion(kvno.getValue().intValue());
 					break;
 				case 2:
 					DEROctetString cipher = (DEROctetString)derObject;
-					data.setCipherText(cipher.getOctets());
+					modifier.setCipherText(cipher.getOctets());
 					break;
 			    default:
 			    	System.out.println(object.getObject());
 			    	break;
 			}
 		}
-		return data;
+		return modifier.getEncryptedData();
 	}
 	
 	/*

Modified: incubator/directory/kerberos/trunk/kerberos/src/java/org/apache/kerberos/messages/KdcReply.java
==============================================================================
--- incubator/directory/kerberos/trunk/kerberos/src/java/org/apache/kerberos/messages/KdcReply.java
(original)
+++ incubator/directory/kerberos/trunk/kerberos/src/java/org/apache/kerberos/messages/KdcReply.java
Tue Nov  9 05:28:58 2004
@@ -28,7 +28,7 @@
 	private Ticket                  _ticket;
 	
 	private EncKdcRepPart _encKDCRepPart = new EncKdcRepPart();
-	private EncryptedData _encPart       = new EncryptedData();
+	private EncryptedData _encPart;
 
 	public KdcReply(MessageType msgType) {
 		super(msgType);

Modified: incubator/directory/kerberos/trunk/kerberos/src/java/org/apache/kerberos/messages/value/EncryptedData.java
==============================================================================
--- incubator/directory/kerberos/trunk/kerberos/src/java/org/apache/kerberos/messages/value/EncryptedData.java
(original)
+++ incubator/directory/kerberos/trunk/kerberos/src/java/org/apache/kerberos/messages/value/EncryptedData.java
Tue Nov  9 05:28:58 2004
@@ -16,49 +16,34 @@
  */
 package org.apache.kerberos.messages.value;
 
-import org.apache.kerberos.crypto.encryption.*;
+import org.apache.kerberos.crypto.encryption.EncryptionType;
 
-public class EncryptedData {
+public class EncryptedData
+{
+	private EncryptionType encryptionType;
+	private int            keyVersion;     //optional
+	private byte[]         cipherText;
 
-	private EncryptionType _encryptionType;
-	private int            _keyVersion;     //optional
-	private byte[]         _cipherText;
-	
-	public EncryptedData() {
-		// TODO - temp
+	public EncryptedData(EncryptionType type, int version, byte[] cipherText)
+    {
+		encryptionType  = type;
+		keyVersion      = version;
+		this.cipherText = cipherText;
 	}
-	
-	public EncryptedData(EncryptionType eType, byte[] cipher) {
-		_encryptionType = eType;
-		_cipherText     = cipher;
-	}
-	
-	public EncryptedData(EncryptionType eType, int kvno, byte[] cipher) {
-		_encryptionType = eType;
-		_keyVersion     = kvno;
-		_cipherText     = cipher;
-	}
-	
-	// getters
-	public EncryptionType getEncryptionType() {
-		return _encryptionType;
-	}
-	public int getKeyVersion() {
-		return _keyVersion;
-	}
-	public byte[] getCipherText() {
-		return _cipherText;
-	}
-	
-	// setters
-	public void setCipherText(byte[] text) {
-		_cipherText = text;
+
+	public EncryptionType getEncryptionType()
+    {
+		return encryptionType;
 	}
-	public void setEncryptionType(EncryptionType type) {
-		_encryptionType = type;
+
+	public int getKeyVersion()
+    {
+		return keyVersion;
 	}
-	public void setKeyVersion(int version) {
-		_keyVersion = version;
+
+	public byte[] getCipherText()
+    {
+		return cipherText;
 	}
 }
 

Added: incubator/directory/kerberos/trunk/kerberos/src/java/org/apache/kerberos/messages/value/EncryptedDataModifier.java
==============================================================================
--- (empty file)
+++ incubator/directory/kerberos/trunk/kerberos/src/java/org/apache/kerberos/messages/value/EncryptedDataModifier.java
Tue Nov  9 05:28:58 2004
@@ -0,0 +1,47 @@
+/*
+ *   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.EncryptionType;
+
+public class EncryptedDataModifier
+{
+	private EncryptionType encryptionType;
+	private int            keyVersion;     //optional
+	private byte[]         cipherText;
+	
+	public EncryptedData getEncryptedData()
+    {
+        return new EncryptedData(encryptionType, keyVersion, cipherText);
+	}
+
+	public void setCipherText(byte[] cipherText)
+    {
+		this.cipherText = cipherText;
+	}
+
+	public void setEncryptionType(EncryptionType type)
+    {
+		encryptionType = type;
+	}
+
+	public void setKeyVersion(int version)
+    {
+		keyVersion = version;
+	}
+}
+

Mime
View raw message