Fix missing imports and misc. warnings
package org.bouncycastle.tsp;
-import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
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.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;
@@ -80,7 +80,7 @@ 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)
{
@@ -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
{
@@ -98,7 +98,8 @@ 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()));
@@ -338,22 +339,6 @@ public CMSSignedData toCMSSignedData()
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)
