本文整理汇总了Java中org.bouncycastle.asn1.ocsp.OCSPResponse.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java OCSPResponse.getInstance方法的具体用法?Java OCSPResponse.getInstance怎么用?Java OCSPResponse.getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.asn1.ocsp.OCSPResponse
的用法示例。
在下文中一共展示了OCSPResponse.getInstance方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOthersFromStore
import org.bouncycastle.asn1.ocsp.OCSPResponse; //导入方法依赖的package包/类
static Collection getOthersFromStore(ASN1ObjectIdentifier otherRevocationInfoFormat, Store otherRevocationInfos)
{
List others = new ArrayList();
for (Iterator it = otherRevocationInfos.getMatches(null).iterator(); it.hasNext();)
{
ASN1Encodable info = (ASN1Encodable)it.next();
if (CMSObjectIdentifiers.id_ri_ocsp_response.equals(otherRevocationInfoFormat))
{
OCSPResponse resp = OCSPResponse.getInstance(info);
if (resp.getResponseStatus().getValue().intValue() != OCSPResponseStatus.SUCCESSFUL)
{
throw new IllegalArgumentException("cannot add unsuccessful OCSP response to CMS SignedData");
}
}
others.add(new DERTaggedObject(false, 1, new OtherRevocationInfoFormat(otherRevocationInfoFormat, info)));
}
return others;
}
示例2: parse
import org.bouncycastle.asn1.ocsp.OCSPResponse; //导入方法依赖的package包/类
/**
* Parse a {@link CertificateStatus} from an {@link InputStream}.
*
* @param input
* the {@link InputStream} to parse from.
* @return a {@link CertificateStatus} object.
* @throws IOException
*/
public static CertificateStatus parse(InputStream input) throws IOException
{
short status_type = TlsUtils.readUint8(input);
Object response;
switch (status_type)
{
case CertificateStatusType.ocsp:
{
byte[] derEncoding = TlsUtils.readOpaque24(input);
response = OCSPResponse.getInstance(TlsUtils.readDERObject(derEncoding));
break;
}
default:
throw new TlsFatalAlert(AlertDescription.decode_error);
}
return new CertificateStatus(status_type, response);
}
示例3: CertEtcToken
import org.bouncycastle.asn1.ocsp.OCSPResponse; //导入方法依赖的package包/类
private CertEtcToken(ASN1TaggedObject choice)
{
this.tagNo = choice.getTagNo();
switch (tagNo)
{
case TAG_CERTIFICATE:
value = Certificate.getInstance(choice, false);
break;
case TAG_ESSCERTID:
value = ESSCertID.getInstance(choice.getObject());
break;
case TAG_PKISTATUS:
value = PKIStatusInfo.getInstance(choice, false);
break;
case TAG_ASSERTION:
value = ContentInfo.getInstance(choice.getObject());
break;
case TAG_CRL:
value = CertificateList.getInstance(choice, false);
break;
case TAG_OCSPCERTSTATUS:
value = CertStatus.getInstance(choice.getObject());
break;
case TAG_OCSPCERTID:
value = CertID.getInstance(choice, false);
break;
case TAG_OCSPRESPONSE:
value = OCSPResponse.getInstance(choice, false);
break;
case TAG_CAPABILITIES:
value = SMIMECapabilities.getInstance(choice.getObject());
break;
default:
throw new IllegalArgumentException("Unknown tag: " + tagNo);
}
}
示例4: validateInfoFormat
import org.bouncycastle.asn1.ocsp.OCSPResponse; //导入方法依赖的package包/类
private static void validateInfoFormat(OtherRevocationInfoFormat infoFormat)
{
if (CMSObjectIdentifiers.id_ri_ocsp_response.equals(infoFormat.getInfoFormat()))
{
OCSPResponse resp = OCSPResponse.getInstance(infoFormat.getInfo());
if (resp.getResponseStatus().getValue().intValue() != OCSPResponseStatus.SUCCESSFUL)
{
throw new IllegalArgumentException("cannot add unsuccessful OCSP response to CMS SignedData");
}
}
}
示例5: testSHA1WithRSAAndOtherRevocation
import org.bouncycastle.asn1.ocsp.OCSPResponse; //导入方法依赖的package包/类
public void testSHA1WithRSAAndOtherRevocation()
throws Exception
{
List certList = new ArrayList();
CMSTypedData msg = new CMSProcessableByteArray("Hello world!".getBytes());
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
certList.add(_origCert);
certList.add(_signCert);
Store certs = new JcaCertStore(certList);
CMSSignedDataStreamGenerator gen = new CMSSignedDataStreamGenerator();
ContentSigner sha1Signer = new JcaContentSignerBuilder("SHA1withRSA").setProvider(BC).build(_origKP.getPrivate());
gen.addSignerInfoGenerator(new JcaSignerInfoGeneratorBuilder(new JcaDigestCalculatorProviderBuilder().setProvider(BC).build()).build(sha1Signer, _origCert));
gen.addCertificates(certs);
List otherInfo = new ArrayList();
OCSPResp response = new OCSPResp(successResp);
otherInfo.add(response.toASN1Structure());
gen.addOtherRevocationInfo(CMSObjectIdentifiers.id_ri_ocsp_response, new CollectionStore(otherInfo));
OutputStream sigOut = gen.open(bOut, true);
sigOut.write(TEST_MESSAGE.getBytes());
sigOut.close();
CMSSignedDataParser sp = new CMSSignedDataParser(new JcaDigestCalculatorProviderBuilder().setProvider(BC).build(), bOut.toByteArray());
CMSTypedStream stream = sp.getSignedContent();
assertEquals(CMSObjectIdentifiers.data, stream.getContentType());
stream.drain();
//
// check version
//
assertEquals(5, sp.getVersion());
//
// compute expected content digest
//
MessageDigest md = MessageDigest.getInstance("SHA1", BC);
verifySignatures(sp, md.digest(TEST_MESSAGE.getBytes()));
Store dataOtherInfo = sp.getOtherRevocationInfo(CMSObjectIdentifiers.id_ri_ocsp_response);
assertEquals(1, dataOtherInfo.getMatches(null).size());
OCSPResp dataResponse = new OCSPResp(OCSPResponse.getInstance(dataOtherInfo.getMatches(null).iterator().next()));
assertEquals(response, dataResponse);
}
示例6: testSHA1WithRSAAndOtherRevocation
import org.bouncycastle.asn1.ocsp.OCSPResponse; //导入方法依赖的package包/类
public void testSHA1WithRSAAndOtherRevocation()
throws Exception
{
List certList = new ArrayList();
CMSTypedData msg = new CMSProcessableByteArray("Hello world!".getBytes());
certList.add(_origCert);
certList.add(_signCert);
Store certs = new JcaCertStore(certList);
CMSSignedDataGenerator gen = new CMSSignedDataGenerator();
ContentSigner sha1Signer = new JcaContentSignerBuilder("SHA1withRSA").setProvider(BC).build(_origKP.getPrivate());
gen.addSignerInfoGenerator(new JcaSignerInfoGeneratorBuilder(new JcaDigestCalculatorProviderBuilder().setProvider(BC).build()).build(sha1Signer, _origCert));
gen.addCertificates(certs);
List otherInfo = new ArrayList();
OCSPResp response = new OCSPResp(successResp);
otherInfo.add(response.toASN1Structure());
gen.addOtherRevocationInfo(CMSObjectIdentifiers.id_ri_ocsp_response, new CollectionStore(otherInfo));
CMSSignedData s;
s = gen.generate(msg, false);
//
// check version
//
assertEquals(5, s.getVersion());
//
// compute expected content digest
//
MessageDigest md = MessageDigest.getInstance("SHA1", BC);
verifySignatures(s, md.digest("Hello world!".getBytes()));
Store dataOtherInfo = s.getOtherRevocationInfo(CMSObjectIdentifiers.id_ri_ocsp_response);
assertEquals(1, dataOtherInfo.getMatches(null).size());
OCSPResp dataResponse = new OCSPResp(OCSPResponse.getInstance(dataOtherInfo.getMatches(null).iterator().next()));
assertEquals(response, dataResponse);
}