diff options
author | Endi Sukma Dewata <edewata@redhat.com> | 2012-03-28 00:36:32 -0500 |
---|---|---|
committer | Endi Sukma Dewata <edewata@redhat.com> | 2012-03-28 13:19:26 -0500 |
commit | 1c8437891cdfe5580e09c495f79d81334ed0c2c0 (patch) | |
tree | 5a3ca8c31ca13c2809cccd3ac73c5791fe491163 /base/common/src/com/netscape/cmscore | |
parent | e744c37ab1510f87ed4b5b3eafeb3758f1d0e30f (diff) | |
download | pki-1c8437891cdfe5580e09c495f79d81334ed0c2c0.tar.gz pki-1c8437891cdfe5580e09c495f79d81334ed0c2c0.tar.xz pki-1c8437891cdfe5580e09c495f79d81334ed0c2c0.zip |
Replaced deprecated AlgorithmId.getAlgorithmId().
The deprecated getAlgorithmId() method in AlgorithmId has been replaced
with get().
Ticket #3
Diffstat (limited to 'base/common/src/com/netscape/cmscore')
3 files changed, 55 insertions, 57 deletions
diff --git a/base/common/src/com/netscape/cmscore/cert/CertUtils.java b/base/common/src/com/netscape/cmscore/cert/CertUtils.java index 9710d63f5..009e9b0d9 100644 --- a/base/common/src/com/netscape/cmscore/cert/CertUtils.java +++ b/base/common/src/com/netscape/cmscore/cert/CertUtils.java @@ -66,7 +66,7 @@ import com.netscape.cmsutil.util.Utils; * Utility class with assorted methods to check for * smime pairs, determining the type of cert - signature * or encryption ..etc. - * + * * @author kanda * @version $Revision$, $Date$ */ @@ -172,8 +172,7 @@ public class CertUtils { if (info == null) { throw new EBaseException(CMS.getUserMessage("CMS_BASE_INVALID_OPERATION")); } - X509Key key = new X509Key(AlgorithmId.getAlgorithmId( - "RSAEncryption"), encoded); + X509Key key = new X509Key(AlgorithmId.get("RSAEncryption"), encoded); info.set(X509CertInfo.KEY, key); } catch (Exception e) { @@ -191,7 +190,7 @@ public class CertUtils { info.set(X509CertInfo.SERIAL_NUMBER, new CertificateSerialNumber(serialno)); info.set(X509CertInfo.ALGORITHM_ID, new - CertificateAlgorithmId(AlgorithmId.getAlgorithmId(alg))); + CertificateAlgorithmId(AlgorithmId.get(alg))); info.set(X509CertInfo.ISSUER, new CertificateIssuerName(new X500Name(issuerName))); info.set(X509CertInfo.VALIDITY, new @@ -398,9 +397,9 @@ public class CertUtils { /** * Returns the index of the given cert in an array of certs. - * + * * Assumptions: The certs are issued by the same CA - * + * * @param certArray The array of certs. * @param givenCert The certificate we are lokking for in the array. * @return -1 if not found or the index of the given cert in the array. @@ -421,9 +420,9 @@ public class CertUtils { /** * Returns the most recently issued signing certificate from an * an array of certs. - * + * * Assumptions: The certs are issued by the same CA - * + * * @param certArray The array of certs. * @param givenCert The certificate we are lokking for in the array. * @return null if there is no recent cert or the most recent cert. @@ -643,7 +642,7 @@ public class CertUtils { /** * strips out the begin and end certificate brackets - * + * * @param s the string potentially bracketed with * "-----BEGIN CERTIFICATE-----" and "-----END CERTIFICATE-----" * @return string without the brackets @@ -670,7 +669,7 @@ public class CertUtils { /** * Returns a string that represents a cert's fingerprint. * The fingerprint is a MD5 digest of the DER encoded certificate. - * + * * @param cert Certificate to get the fingerprint of. * @return a String that represents the cert's fingerprint. */ @@ -693,16 +692,16 @@ public class CertUtils { * MD5, MD2 and SHA1 hashes. * A certificate's fingerprint is a hash digest of the DER encoded * certificate. - * + * * @param cert Certificate to get the fingerprints of. * @return a String with fingerprints using the MD5, MD2 and SHA1 hashes. * For example, - * + * * <pre> * MD2: 78:7E:D1:F9:3E:AF:50:18:68:A7:29:50:C3:21:1F:71 - * + * * MD5: 0E:89:91:AC:40:50:F7:BE:6E:7B:39:4F:56:73:75:75 - * + * * SHA1: DC:D9:F7:AF:E2:83:10:B2:F7:0A:77:E8:50:E2:F7:D1:15:9A:9D:00 * </pre> */ @@ -731,16 +730,16 @@ public class CertUtils { * MD5, MD2 and SHA1 hashes. * A certificate's fingerprint is a hash digest of the DER encoded * certificate. - * + * * @param cert Certificate to get the fingerprints of. * @return a String with fingerprints using the MD5, MD2 and SHA1 hashes. * For example, - * + * * <pre> * MD2: 78:7E:D1:F9:3E:AF:50:18:68:A7:29:50:C3:21:1F:71 - * + * * MD5: 0E:89:91:AC:40:50:F7:BE:6E:7B:39:4F:56:73:75:75 - * + * * SHA1: DC:D9:F7:AF:E2:83:10:B2:F7:0A:77:E8:50:E2:F7:D1:15:9A:9D:00 * </pre> */ @@ -764,7 +763,7 @@ public class CertUtils { /** * Check if a object identifier in string form is valid, * that is a string in the form n.n.n.n and der encode and decode-able. - * + * * @param attrName attribute name (from the configuration file) * @param value object identifier string. */ @@ -1083,7 +1082,7 @@ public class CertUtils { /** * Signed Audit Log * This method is called to store messages to the signed audit log. - * + * * @param msg signed audit log message */ private static void audit(String msg) { diff --git a/base/common/src/com/netscape/cmscore/security/JssSubsystem.java b/base/common/src/com/netscape/cmscore/security/JssSubsystem.java index 42768060c..7c16c6f43 100644 --- a/base/common/src/com/netscape/cmscore/security/JssSubsystem.java +++ b/base/common/src/com/netscape/cmscore/security/JssSubsystem.java @@ -103,7 +103,7 @@ import com.netscape.cmsutil.util.Utils; /** * Subsystem for initializing JSS> * <P> - * + * * @version $Revision$ $Date$ */ public final class JssSubsystem implements ICryptoSubsystem { @@ -137,7 +137,7 @@ public final class JssSubsystem implements ICryptoSubsystem { // May 01, 1999 01:55:55. private static SimpleDateFormat mFormatter = new SimpleDateFormat("MMMMM dd, yyyy HH:mm:ss"); - // SSL related variables. + // SSL related variables. private IConfigStore mSSLConfig = null; @@ -367,9 +367,9 @@ public final class JssSubsystem implements ICryptoSubsystem { } public String isCipherFortezza() throws EBaseException { - // we always display fortezza suites. - // too much work to display tokens/certs corresponding to the - // suites. + // we always display fortezza suites. + // too much work to display tokens/certs corresponding to the + // suites. return "true"; } @@ -396,10 +396,10 @@ public final class JssSubsystem implements ICryptoSubsystem { /** * Initialize SSL cipher suites from config file. - * + * */ private void initSSL() throws EBaseException { - // JSS will AND what is set and what is allowed by export policy + // JSS will AND what is set and what is allowed by export policy // so we can set what is requested. try { @@ -415,7 +415,7 @@ public final class JssSubsystem implements ICryptoSubsystem { if (Debug.ON) Debug.trace("configured ssl cipher prefs is " + sslCiphers); - // first, disable all ciphers, since JSS defaults to all-enabled + // first, disable all ciphers, since JSS defaults to all-enabled for (int i = mJSSCipherSuites.length - 1; i >= 0; i--) { try { SSLSocket.setCipherPreferenceDefault(mJSSCipherSuites[i], @@ -436,7 +436,7 @@ public final class JssSubsystem implements ICryptoSubsystem { } while (ciphers.hasMoreTokens()) { String cipher = ciphers.nextToken(); - Integer sslcipher = (Integer) mCipherNames.get(cipher); + Integer sslcipher = mCipherNames.get(cipher); if (sslcipher != null) { String msg = "setting ssl cipher " + cipher; @@ -749,7 +749,7 @@ public final class JssSubsystem implements ICryptoSubsystem { return new AlgIdDSA(P, Q, G); } } - return AlgorithmId.getAlgorithmId(algname); + return AlgorithmId.get(algname); } catch (NoSuchAlgorithmException e) { throw new EBaseException(CMS.getUserMessage("CMS_BASE_ALG_NOT_SUPPORTED", "")); } @@ -1099,7 +1099,7 @@ public final class JssSubsystem implements ICryptoSubsystem { } try { if (mNicknameMapCertsTable != null) { - X509Certificate[] certs = (X509Certificate[]) mNicknameMapCertsTable.get(nickname); + X509Certificate[] certs = mNicknameMapCertsTable.get(nickname); if (certs == null) { EBaseException e = new EBaseException(CMS.getUserMessage("CMS_BASE_CERT_NOT_FOUND")); @@ -1164,7 +1164,7 @@ public final class JssSubsystem implements ICryptoSubsystem { Hashtable<String, Vector<X509Certificate>> vecTable = new Hashtable<String, Vector<X509Certificate>>(); while (enums.hasMoreElements()) { - CryptoToken token = (CryptoToken) enums.nextElement(); + CryptoToken token = enums.nextElement(); String tokenName = token.getName(); CryptoStore store = token.getCryptoStore(); @@ -1186,7 +1186,7 @@ public final class JssSubsystem implements ICryptoSubsystem { try { Vector<X509Certificate> v; - if (vecTable.containsKey((Object) nickname) == true) { + if (vecTable.containsKey(nickname) == true) { v = vecTable.get(nickname); } else { v = new Vector<X509Certificate>(); @@ -1213,11 +1213,11 @@ public final class JssSubsystem implements ICryptoSubsystem { Enumeration<String> elms = vecTable.keys(); while (elms.hasMoreElements()) { - String key = (String) elms.nextElement(); - Vector<X509Certificate> v = vecTable.get((Object) key); + String key = elms.nextElement(); + Vector<X509Certificate> v = vecTable.get(key); X509Certificate[] a = new X509Certificate[v.size()]; - v.copyInto((Object[]) a); + v.copyInto(a); mNicknameMapCertsTable.put(key, a); } } @@ -1237,7 +1237,7 @@ public final class JssSubsystem implements ICryptoSubsystem { Enumeration<CryptoToken> enums = mCryptoManager.getAllTokens(); while (enums.hasMoreElements()) { - CryptoToken token = (CryptoToken) enums.nextElement(); + CryptoToken token = enums.nextElement(); String tokenName = token.getName(); CryptoStore store = token.getCryptoStore(); @@ -1305,7 +1305,7 @@ public final class JssSubsystem implements ICryptoSubsystem { Enumeration<CryptoToken> enums = mCryptoManager.getAllTokens(); while (enums.hasMoreElements()) { - CryptoToken token = (CryptoToken) enums.nextElement(); + CryptoToken token = enums.nextElement(); CryptoStore store = token.getCryptoStore(); X509Certificate[] list = store.getCertificates(); @@ -1388,7 +1388,7 @@ public final class JssSubsystem implements ICryptoSubsystem { /* build a table of our own */ Vector<X509Certificate> v; - if (vecTable.containsKey((Object) nickname) == true) { + if (vecTable.containsKey(nickname) == true) { v = vecTable.get(nickname); } else { v = new Vector<X509Certificate>(); @@ -1401,19 +1401,19 @@ public final class JssSubsystem implements ICryptoSubsystem { Enumeration<String> elms = vecTable.keys(); while (elms.hasMoreElements()) { - String key = (String) elms.nextElement(); - Vector<X509Certificate> v = vecTable.get((Object) key); + String key = elms.nextElement(); + Vector<X509Certificate> v = vecTable.get(key); X509Certificate[] a = new X509Certificate[v.size()]; - v.copyInto((Object[]) a); + v.copyInto(a); mNicknameMapCertsTable.put(key, a); } Enumeration<String> keys = mNicknameMapCertsTable.keys(); while (keys.hasMoreElements()) { - String nickname = (String) keys.nextElement(); - X509Certificate[] value = (X509Certificate[]) mNicknameMapCertsTable.get(nickname); + String nickname = keys.nextElement(); + X509Certificate[] value = mNicknameMapCertsTable.get(nickname); for (int i = 0; i < value.length; i++) { InternalCertificate icert = null; @@ -1462,7 +1462,7 @@ public final class JssSubsystem implements ICryptoSubsystem { EBaseException { try { if (mNicknameMapCertsTable != null) { - X509Certificate[] certs = (X509Certificate[]) mNicknameMapCertsTable.get(nickname); + X509Certificate[] certs = mNicknameMapCertsTable.get(nickname); if (certs == null) { EBaseException e = new EBaseException(CMS.getUserMessage("CMS_BASE_CERT_NOT_FOUND")); @@ -1505,7 +1505,7 @@ public final class JssSubsystem implements ICryptoSubsystem { /** * Delete the CA certificate from the perm database. - * + * * @param nickname The nickname of the CA certificate. * @param notAfterTime The notAfter of the certificate. It is possible to get multiple * certificates under the same nickname. If one of the certificates match the notAfterTime, @@ -1515,7 +1515,7 @@ public final class JssSubsystem implements ICryptoSubsystem { public void deleteCACert(String nickname, String notAfterTime) throws EBaseException { try { if (mNicknameMapCertsTable != null) { - X509Certificate[] certs = (X509Certificate[]) mNicknameMapCertsTable.get(nickname); + X509Certificate[] certs = mNicknameMapCertsTable.get(nickname); if (certs == null) { EBaseException e = new EBaseException(CMS.getUserMessage("CMS_BASE_CERT_NOT_FOUND")); @@ -1566,7 +1566,7 @@ public final class JssSubsystem implements ICryptoSubsystem { /** * Delete any certificate from the any token. - * + * * @param nickname The nickname of the certificate. * @param notAfterTime The notAfter of the certificate. It is possible to get multiple * certificates under the same nickname. If one of the certificates match the notAfterTime, @@ -1581,13 +1581,13 @@ public final class JssSubsystem implements ICryptoSubsystem { try { if (mNicknameMapCertsTable != null) { certs = - (X509Certificate[]) mNicknameMapCertsTable.get(nickname); + mNicknameMapCertsTable.get(nickname); } if (certs == null) { if (mNicknameMapUserCertsTable != null) { certs = - (X509Certificate[]) mNicknameMapUserCertsTable.get(nickname); + mNicknameMapUserCertsTable.get(nickname); if (certs != null) { CMS.debug("in mNicknameMapUserCertsTable, isUserCert is true"); isUserCert = true; @@ -1956,7 +1956,7 @@ public final class JssSubsystem implements ICryptoSubsystem { if ((certs == null || certs.length == 0) && mNicknameMapCertsTable != null) { - certs = (X509Certificate[]) mNicknameMapCertsTable.get(nickname); + certs = mNicknameMapCertsTable.get(nickname); } if (certs == null) { EBaseException e = new EBaseException(CMS.getUserMessage("CMS_BASE_CERT_NOT_FOUND")); diff --git a/base/common/src/com/netscape/cmscore/security/KeyCertUtil.java b/base/common/src/com/netscape/cmscore/security/KeyCertUtil.java index 2a9afb868..2bb31ba1a 100644 --- a/base/common/src/com/netscape/cmscore/security/KeyCertUtil.java +++ b/base/common/src/com/netscape/cmscore/security/KeyCertUtil.java @@ -63,7 +63,6 @@ import netscape.security.x509.AlgIdDSA; import netscape.security.x509.AlgorithmId; import netscape.security.x509.AuthorityKeyIdentifierExtension; import netscape.security.x509.BasicConstraintsExtension; -import netscape.security.x509.CertAttrSet; import netscape.security.x509.CertificateAlgorithmId; import netscape.security.x509.CertificateExtensions; import netscape.security.x509.Extension; @@ -119,7 +118,7 @@ import com.netscape.cmsutil.util.Utils; /** * This class provides all the base methods to generate the key for different * kinds of certificates. - * + * * @author Christine Ho * @version $Revision$, $Date$ */ @@ -162,7 +161,7 @@ public class KeyCertUtil { int num = 0; while (tokens.hasMoreElements()) { - CryptoToken c = (CryptoToken) tokens.nextElement(); + CryptoToken c = tokens.nextElement(); if (num++ == 0) tokenList = tokenList + c.getName(); @@ -333,7 +332,7 @@ public class KeyCertUtil { return new AlgIdDSA(P, Q, G); } } - return AlgorithmId.getAlgorithmId(algname); + return AlgorithmId.get(algname); } catch (NoSuchAlgorithmException e) { throw new EBaseException(CMS.getUserMessage("CMS_BASE_ALG_NOT_SUPPORTED")); } @@ -603,7 +602,7 @@ public class KeyCertUtil { if (exts != null) { PKCS10Attribute attr = new PKCS10Attribute(PKCS9Attribute.EXTENSION_REQUEST_OID, - (CertAttrSet) exts); + exts); PKCS10Attributes attrs = new PKCS10Attributes(); attrs.setAttribute(attr.getAttributeValue().getName(), attr); @@ -764,7 +763,7 @@ public class KeyCertUtil { byte bCert[] = Utils.base64decode(str); /* - java.security.cert.X509Certificate cert = + java.security.cert.X509Certificate cert = java.security.cert.X509Certificate.getInstance(bCert); return cert; */ |