Skip to content

Commit

Permalink
Fix missing imports and misc. warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdettman committed May 13, 2019
1 parent e46c8c7 commit 39e0bbc
Showing 1 changed file with 9 additions and 24 deletions.
33 changes: 9 additions & 24 deletions pkix/src/main/java/org/bouncycastle/tsp/TimeStampToken.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.bouncycastle.tsp;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
Expand All @@ -16,14 +15,15 @@
import org.bouncycastle.asn1.ess.ESSCertIDv2;
import org.bouncycastle.asn1.ess.SigningCertificate;
import org.bouncycastle.asn1.ess.SigningCertificateV2;
import org.bouncycastle.asn1.nist.NISTObjectIdentifiers;
import org.bouncycastle.asn1.oiw.OIWObjectIdentifiers;
import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
import org.bouncycastle.asn1.tsp.TSTInfo;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.asn1.x509.GeneralName;
import org.bouncycastle.asn1.x509.IssuerSerial;
import org.bouncycastle.cert.X509AttributeCertificateHolder;
import org.bouncycastle.cert.X509CRLHolder;
import org.bouncycastle.cert.X509CertificateHolder;
import org.bouncycastle.cms.CMSException;
import org.bouncycastle.cms.CMSProcessable;
Expand Down Expand Up @@ -79,8 +79,8 @@ public TimeStampToken(CMSSignedData signedData)
{
throw new TSPValidationException("ContentInfo object not for a time stamp.");
}
Collection signers = tsToken.getSignerInfos().getSigners();

Collection<SignerInformation> signers = tsToken.getSignerInfos().getSigners();

if (signers.size() != 1)
{
Expand All @@ -89,7 +89,7 @@ public TimeStampToken(CMSSignedData signedData)
+ " signers, but it must contain just the TSA signature.");
}

tsaSignerInfo = (SignerInformation)signers.iterator().next();
tsaSignerInfo = signers.iterator().next();

try
{
Expand All @@ -98,15 +98,16 @@ public TimeStampToken(CMSSignedData signedData)

content.write(bOut);

ASN1InputStream aIn = new ASN1InputStream(new ByteArrayInputStream(bOut.toByteArray()));
@SuppressWarnings("resource")
ASN1InputStream aIn = new ASN1InputStream(bOut.toByteArray());

this.tstInfo = new TimeStampTokenInfo(TSTInfo.getInstance(aIn.readObject()));

Attribute attr = tsaSignerInfo.getSignedAttributes().get(PKCSObjectIdentifiers.id_aa_signingCertificate);
Attribute attr = tsaSignerInfo.getSignedAttributes().get(PKCSObjectIdentifiers.id_aa_signingCertificate);

if (attr != null)
{
SigningCertificate signCert = SigningCertificate.getInstance(attr.getAttrValues().getObjectAt(0));
SigningCertificate signCert = SigningCertificate.getInstance(attr.getAttrValues().getObjectAt(0));

this.certID = new CertID(ESSCertID.getInstance(signCert.getCerts()[0]));
}
Expand Down Expand Up @@ -338,22 +339,6 @@ private class CertID
this.certID = null;
}

public String getHashAlgorithmName()
{
if (certID != null)
{
return "SHA-1";
}
else
{
if (NISTObjectIdentifiers.id_sha256.equals(certIDv2.getHashAlgorithm().getAlgorithm()))
{
return "SHA-256";
}
return certIDv2.getHashAlgorithm().getAlgorithm().getId();
}
}

public AlgorithmIdentifier getHashAlgorithm()
{
if (certID != null)
Expand Down

0 comments on commit 39e0bbc

Please sign in to comment.