From 1c8437891cdfe5580e09c495f79d81334ed0c2c0 Mon Sep 17 00:00:00 2001 From: Endi Sukma Dewata Date: Wed, 28 Mar 2012 00:36:32 -0500 Subject: Replaced deprecated AlgorithmId.getAlgorithmId(). The deprecated getAlgorithmId() method in AlgorithmId has been replaced with get(). Ticket #3 --- .../src/netscape/security/extensions/CertInfo.java | 9 +++-- .../src/netscape/security/x509/AlgorithmId.java | 39 ++++++++-------------- .../src/netscape/security/x509/X500Signer.java | 16 ++++----- 3 files changed, 25 insertions(+), 39 deletions(-) (limited to 'base/util') diff --git a/base/util/src/netscape/security/extensions/CertInfo.java b/base/util/src/netscape/security/extensions/CertInfo.java index ab88ec8ab..47a138253 100644 --- a/base/util/src/netscape/security/extensions/CertInfo.java +++ b/base/util/src/netscape/security/extensions/CertInfo.java @@ -65,14 +65,13 @@ public class CertInfo extends X509CertInfo { SERIALIZE_SERIALNO = new CertificateSerialNumber(new BigInteger("0")); SERIALIZE_ALGOR = - new CertificateAlgorithmId( - AlgorithmId.getAlgorithmId("MD5withRSA")); + new CertificateAlgorithmId(AlgorithmId.get("MD5withRSA")); } catch (IOException e) { - // should never happen. If does, system is hosed. + // should never happen. If does, system is hosed. System.out.println("**** Impossible Error encountered ****"); throw new RuntimeException(e.toString()); } catch (NoSuchAlgorithmException e) { - // should never happen. If does, system is hosed. + // should never happen. If does, system is hosed. System.out.println("**** Impossible Error encountered ****"); throw new RuntimeException(e.toString()); } @@ -111,7 +110,7 @@ public class CertInfo extends X509CertInfo { certinfo.set(X509CertInfo.SUBJECT, SERIALIZE_SUBJECT); } // key is set later in the request. - } // these exceptions shouldn't happen here unless the + } // these exceptions shouldn't happen here unless the // whole process is hosed. catch (CertificateException e) { } catch (IOException e) { diff --git a/base/util/src/netscape/security/x509/AlgorithmId.java b/base/util/src/netscape/security/x509/AlgorithmId.java index b0113af41..947853a42 100644 --- a/base/util/src/netscape/security/x509/AlgorithmId.java +++ b/base/util/src/netscape/security/x509/AlgorithmId.java @@ -35,19 +35,19 @@ import netscape.security.util.ObjectIdentifier; * are used when this runtime environment has no special knowledge of the * algorithm type, and may also be used in other cases. Equivalence is * defined according to OID and (where relevant) parameters. - * + * *

* Subclasses may be used, for example when when the algorithm ID has associated parameters which some code (e.g. code * using public keys) needs to have parsed. Two examples of such algorithms are Diffie-Hellman key exchange, and the * Digital Signature Standard Algorithm (DSS/DSA). - * + * *

* The OID constants defined in this class correspond to some widely used algorithms, for which conventional string * names have been defined. This class is not a general repository for OIDs, or for such string names. Note that the * mappings between algorithm IDs and algorithm names is not one-to-one. - * + * * @version 1.70 - * + * * @author David Brownell * @author Amit Kapoor * @author Hemma Prafullchandra @@ -77,19 +77,6 @@ public class AlgorithmId implements Serializable, DerEncoder { protected String paramsString = null; - /** - * Returns one of the algorithm IDs most commonly associated - * with this algorithm name. - * - * @param algname the name being used - * @deprecated use the short get form of this method. - * @exception NoSuchAlgorithmException on error. - */ - public static AlgorithmId getAlgorithmId(String algname) - throws NoSuchAlgorithmException { - return get(algname); - } - public AlgorithmParameters getParameters() { return this.algParams; } @@ -106,7 +93,7 @@ public class AlgorithmId implements Serializable, DerEncoder { /** * Returns one of the algorithm IDs most commonly associated * with this algorithm name. - * + * * @param algname the name being used * @exception NoSuchAlgorithmException on error. */ @@ -124,7 +111,7 @@ public class AlgorithmId implements Serializable, DerEncoder { * Parse (unmarshal) an ID from a DER sequence input value. This form * parsing might be used when expanding a value which has already been * partially unmarshaled as a set or sequence member. - * + * * @exception IOException on error. * @param val the input value, which contains the algid and, if * there are any parameters, those parameters. @@ -163,7 +150,7 @@ public class AlgorithmId implements Serializable, DerEncoder { alg.decodeParams(); /* - * Set the raw params string in case + * Set the raw params string in case * higher level code might want the info */ @@ -185,7 +172,7 @@ public class AlgorithmId implements Serializable, DerEncoder { /** * Constructs a parameterless algorithm ID. - * + * * @param oid the identifier for the algorithm */ public AlgorithmId(ObjectIdentifier oid) { @@ -203,7 +190,7 @@ public class AlgorithmId implements Serializable, DerEncoder { /** * Constructs an algorithm ID which will be initialized * separately, for example by deserialization. - * + * * @deprecated use one of the other constructors. */ public AlgorithmId() { @@ -236,10 +223,10 @@ public class AlgorithmId implements Serializable, DerEncoder { /** * DER encode this object onto an output stream. * Implements the DerEncoder interface. - * + * * @param out * the output stream on which to write the DER encoding. - * + * * @exception IOException on encoding error. */ public void derEncode(OutputStream out) throws IOException { @@ -459,7 +446,7 @@ public class AlgorithmId implements Serializable, DerEncoder { /** * Returns the DER encoded parameter, which can then be * used to initialize java.security.AlgorithmParamters. - * + * * @return DER encoded parameters, or null not present. */ public byte[] getEncodedParams() throws IOException { @@ -502,7 +489,7 @@ public class AlgorithmId implements Serializable, DerEncoder { * Compares this AlgorithmID to another. If algorithm parameters are * available, they are compared. Otherwise, just the object IDs * for the algorithm are compared. - * + * * @param other preferably an AlgorithmId, else an ObjectIdentifier */ public boolean equals(Object other) { diff --git a/base/util/src/netscape/security/x509/X500Signer.java b/base/util/src/netscape/security/x509/X500Signer.java index 0b8cf87a4..3bc5a413e 100644 --- a/base/util/src/netscape/security/x509/X500Signer.java +++ b/base/util/src/netscape/security/x509/X500Signer.java @@ -26,17 +26,17 @@ import java.security.Signer; * This class provides a binding between a Signature object and an * authenticated X.500 name (from an X.509 certificate chain), which * is needed in many public key signing applications. - * + * *

* The name of the signer is important, both because knowing it is the whole point of the signature, and because the * associated X.509 certificate is always used to verify the signature. - * + * *

* The X.509 certificate chain is temporarily not associated with * the signer, but this omission will be resolved. - * + * * @version 1.18 - * + * * @author David Brownell * @author Amit Kapoor * @author Hemma Prafullchandra @@ -51,7 +51,7 @@ public final class X500Signer extends Signer { * Called for each chunk of the data being signed. That * is, you can present the data in many chunks, so that * it doesn't need to be in a single sequential buffer. - * + * * @param buf buffer holding the next chunk of the data to be signed * @param offset starting point of to-be-signed data * @param len how many bytes of data are to be signed @@ -64,7 +64,7 @@ public final class X500Signer extends Signer { /** * Produces the signature for the data processed by update(). - * + * * @exception SignatureException on errors. */ public byte[] sign() throws SignatureException { @@ -98,12 +98,12 @@ public final class X500Signer extends Signer { this.agent = agent; try { - this.algid = AlgorithmId.getAlgorithmId(sig.getAlgorithm()); + this.algid = AlgorithmId.get(sig.getAlgorithm()); String alg = sig.getAlgorithm(); if (alg.equals("DSA")) { alg = "SHA1withDSA"; } - this.algid = AlgorithmId.getAlgorithmId(alg); + this.algid = AlgorithmId.get(alg); } catch (NoSuchAlgorithmException e) { throw new RuntimeException("internal error! " + e.getMessage()); -- cgit