directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: rev 55729 - incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/crypto/encryption
Date Wed, 27 Oct 2004 19:59:00 GMT
Author: erodriguez
Date: Wed Oct 27 12:58:59 2004
New Revision: 55729

Modified:
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/crypto/encryption/EncryptionType.java
Log:
Refactored encryption types to use explicit ordinals.

Modified: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/crypto/encryption/EncryptionType.java
==============================================================================
--- incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/crypto/encryption/EncryptionType.java
(original)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/crypto/encryption/EncryptionType.java
Wed Oct 27 12:58:59 2004
@@ -24,54 +24,54 @@
 	 * Enumeration elements are constructed once upon class loading.
 	 * Order of appearance here determines the order of compareTo.
 	 */
-	public static final EncryptionType NULL                 = new EncryptionType("null");
-	public static final EncryptionType DES_CBC_CRC          = new EncryptionType("DES CBC CRC");
-	public static final EncryptionType DES_CBC_MD4          = new EncryptionType("DES CBC MD4");
-	public static final EncryptionType DES_CBC_MD5          = new EncryptionType("DES CBC MD5");
-	public static final EncryptionType RESERVED4            = new EncryptionType("RESERVED -
4");
-	public static final EncryptionType DES3_CBC_MD5         = new EncryptionType("DES3 CBC MD5");
-	public static final EncryptionType RESERVED6            = new EncryptionType("RESERVED -
6");
-	public static final EncryptionType DES3_CBC_SHA1        = new EncryptionType("DES3 CBC SHA1");
-	public static final EncryptionType DES3_CBC_SHA1_KD     = new EncryptionType("DES3 CBC SHA1
KD");
-	public static final EncryptionType DSAWITHSHA1_CMSOID   = new EncryptionType("DSA with SHA1
CMS oid");
-	public static final EncryptionType MD5WITHRSAENCRYPTION_CMSOID  = new EncryptionType("MD5
with RSA encryption CMS oid");
-	public static final EncryptionType SHA1WITHRSAENCRYPTION_CMSOID = new EncryptionType("SHA1
with RSA encryption CMS oid");
-	public static final EncryptionType RC2CBC_ENVOID        = new EncryptionType("RC2 CBC environment
oid");
-	public static final EncryptionType RSAENCRYPTION_ENVOID = new EncryptionType("RSA encryption
environment oid");
-	public static final EncryptionType RSAES_OAEP_ENV_OID   = new EncryptionType("RSA ES OAEP
environment oid");
-	public static final EncryptionType DES_EDE3_CBC_ENV_OID = new EncryptionType("DES EDE3 CBC
environment oid");
-	public static final EncryptionType RC4_HMAC             = new EncryptionType("RC4 HMAC");
-	public static final EncryptionType PK_CROSS             = new EncryptionType("PK cross");
+	public static final EncryptionType NULL                 = new EncryptionType(0, "null");
+	public static final EncryptionType DES_CBC_CRC          = new EncryptionType(1, "DES CBC
CRC");
+	public static final EncryptionType DES_CBC_MD4          = new EncryptionType(2, "DES CBC
MD4");
+	public static final EncryptionType DES_CBC_MD5          = new EncryptionType(3, "DES CBC
MD5");
+	public static final EncryptionType RESERVED4            = new EncryptionType(4, "RESERVED
- 4");
+	public static final EncryptionType DES3_CBC_MD5         = new EncryptionType(5, "DES3 CBC
MD5");
+	public static final EncryptionType RESERVED6            = new EncryptionType(6, "RESERVED
- 6");
+	public static final EncryptionType DES3_CBC_SHA1        = new EncryptionType(7, "DES3 CBC
SHA1");
+	public static final EncryptionType DES3_CBC_SHA1_KD     = new EncryptionType(8, "DES3 CBC
SHA1 KD");
+	public static final EncryptionType DSAWITHSHA1_CMSOID   = new EncryptionType(9, "DSA with
SHA1 CMS oid");
+	public static final EncryptionType MD5WITHRSAENCRYPTION_CMSOID  = new EncryptionType(10,
"MD5 with RSA encryption CMS oid");
+	public static final EncryptionType SHA1WITHRSAENCRYPTION_CMSOID = new EncryptionType(11,
"SHA1 with RSA encryption CMS oid");
+	public static final EncryptionType RC2CBC_ENVOID        = new EncryptionType(12, "RC2 CBC
environment oid");
+	public static final EncryptionType RSAENCRYPTION_ENVOID = new EncryptionType(13, "RSA encryption
environment oid");
+	public static final EncryptionType RSAES_OAEP_ENV_OID   = new EncryptionType(14, "RSA ES
OAEP environment oid");
+	public static final EncryptionType DES_EDE3_CBC_ENV_OID = new EncryptionType(15, "DES EDE3
CBC environment oid");
+	public static final EncryptionType RC4_HMAC             = new EncryptionType(16, "RC4 HMAC");
+	public static final EncryptionType PK_CROSS             = new EncryptionType(17, "PK cross");
 
 	public String toString() {
-		return fName;
+		return _fName + " (" + _fOrdinal + ")";
 	}
 
 	public int compareTo(Object that) {
-		return fOrdinal - ((EncryptionType) that).fOrdinal;
+		return _fOrdinal - ((EncryptionType) that)._fOrdinal;
 	}
 
 	public static EncryptionType getTypeByOrdinal(int type) {
 		for (int i = 0; i < fValues.length; i++)
-			if (fValues[i].fOrdinal == type)
+			if (fValues[i]._fOrdinal == type)
 				return fValues[i];
 		return NULL;
 	}
 	
 	public int getOrdinal() {
-		return fOrdinal;
+		return _fOrdinal;
 	}
 
 	/// PRIVATE /////
-	private final String fName;
-	private static int fNextOrdinal = 0;
-	private final int fOrdinal = fNextOrdinal++;
+	private final String _fName;
+	private final int    _fOrdinal;
 
 	/**
 	 * Private constructor prevents construction outside of this class.
 	 */
-	private EncryptionType(String aName) {
-		fName = aName;
+	private EncryptionType(int ordinal, String name) {
+		_fOrdinal = ordinal;
+		_fName    = name;
 	}
 
 	/**
@@ -83,6 +83,5 @@
 			RSAENCRYPTION_ENVOID, RSAES_OAEP_ENV_OID, DES_EDE3_CBC_ENV_OID,	RC4_HMAC, PK_CROSS};
 	// VALUES needs to be located here, otherwise illegal forward reference
 	public static final List VALUES = Collections.unmodifiableList(Arrays.asList(fValues));
-	
 }
 

Mime
View raw message