8291509: Minor cleanup could be done in sun.security

Reviewed-by: weijun
This commit is contained in:
Mark Powers 2022-09-15 19:59:53 +00:00 committed by Weijun Wang
parent 6beeb8471c
commit 4cec141a90
298 changed files with 2650 additions and 3262 deletions

View file

@ -90,7 +90,7 @@ public class PKCS7 {
* @exception ParsingException on parsing errors.
* @exception IOException on other errors.
*/
public PKCS7(InputStream in) throws ParsingException, IOException {
public PKCS7(InputStream in) throws IOException {
DataInputStream dis = new DataInputStream(in);
byte[] data = new byte[dis.available()];
dis.readFully(data);
@ -158,7 +158,7 @@ public class PKCS7 {
* Parses a PKCS#7 block.
*
* @param derin the ASN.1 encoding of the PKCS#7 block.
* @param oldStyle flag indicating whether or not the given PKCS#7 block
* @param oldStyle flag indicating whether the given PKCS#7 block
* is encoded according to JDK1.1.x.
*/
private void parse(DerInputStream derin, boolean oldStyle)
@ -212,8 +212,7 @@ public class PKCS7 {
this(digestAlgorithmIds, contentInfo, certificates, null, signerInfos);
}
private void parseNetscapeCertChain(DerValue val)
throws ParsingException, IOException {
private void parseNetscapeCertChain(DerValue val) throws IOException {
DerInputStream dis = new DerInputStream(val.toByteArray());
DerValue[] contents = dis.getSequence(2);
certificates = new X509Certificate[contents.length];
@ -259,9 +258,7 @@ public class PKCS7 {
// crls
// [1] IMPLICIT CertificateRevocationLists OPTIONAL,
// signerInfos SignerInfos }
private void parseSignedData(DerValue val)
throws ParsingException, IOException {
private void parseSignedData(DerValue val) throws IOException {
DerInputStream dis = val.toDerInputStream();
// Version
@ -385,9 +382,7 @@ public class PKCS7 {
* Parses an old-style SignedData encoding (for backwards
* compatibility with JDK1.1.x).
*/
private void parseOldSignedData(DerValue val)
throws ParsingException, IOException
{
private void parseOldSignedData(DerValue val) throws IOException {
DerInputStream dis = val.toDerInputStream();
// Version
@ -531,7 +526,7 @@ public class PKCS7 {
// Add the CRL set (tagged with [1] IMPLICIT)
// to the signed data
signedData.putOrderedSetOf((byte)0xA1,
implCRLs.toArray(new X509CRLImpl[implCRLs.size()]));
implCRLs.toArray(new X509CRLImpl[0]));
}
// signerInfos
@ -765,8 +760,8 @@ public class PKCS7 {
* @param privateKey signer's private ky
* @param signerChain signer's certificate chain
* @param content the content to sign
* @param internalsf whether the content should be include in output
* @param directsign if the content is signed directly or thru authattrs
* @param internalsf whether the content should be included in output
* @param directsign if the content is signed directly or through authattrs
* @param ts (optional) timestamper
* @return the pkcs7 output in an array
* @throws SignatureException if signing failed
@ -1012,8 +1007,8 @@ public class PKCS7 {
throws IOException, CertificateException
{
// Generate a timestamp
MessageDigest messageDigest = null;
TSRequest tsQuery = null;
MessageDigest messageDigest;
TSRequest tsQuery;
try {
messageDigest = MessageDigest.getInstance(tSADigestAlg);
tsQuery = new TSRequest(tSAPolicyID, toBeTimestamped, messageDigest);