本文整理汇总了Java中org.bouncycastle.cms.CMSSignedDataGenerator.addCRL方法的典型用法代码示例。如果您正苦于以下问题:Java CMSSignedDataGenerator.addCRL方法的具体用法?Java CMSSignedDataGenerator.addCRL怎么用?Java CMSSignedDataGenerator.addCRL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.cms.CMSSignedDataGenerator
的用法示例。
在下文中一共展示了CMSSignedDataGenerator.addCRL方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCrl
import org.bouncycastle.cms.CMSSignedDataGenerator; //导入方法依赖的package包/类
private SignedData getCrl(X509Ca ca, BigInteger serialNumber)
throws FailInfoException, OperationException {
if (!control.supportGetCrl()) {
throw FailInfoException.BAD_REQUEST;
}
CertificateList crl = ca.getBcCurrentCrl();
if (crl == null) {
throw FailInfoException.BAD_REQUEST;
}
CMSSignedDataGenerator cmsSignedDataGen = new CMSSignedDataGenerator();
cmsSignedDataGen.addCRL(new X509CRLHolder(crl));
CMSSignedData signedData;
try {
signedData = cmsSignedDataGen.generate(new CMSAbsentContent());
} catch (CMSException ex) {
LogUtil.error(LOG, ex, "could not generate CMSSignedData");
throw new OperationException(ErrorCode.SYSTEM_FAILURE, ex);
}
return SignedData.getInstance(signedData.toASN1Structure().getContent());
}
示例2: sign
import org.bouncycastle.cms.CMSSignedDataGenerator; //导入方法依赖的package包/类
public byte[] sign(InputStream content) {
CMSSignedDataGenerator gen = new CMSSignedDataGenerator();
// CertificateChain
List<Certificate> certList = Arrays.asList(certChain);
try {
CertStore certStore = CertStore.getInstance("Collection", new CollectionCertStoreParameters(certList),
provider);
Hashtable signedAttrs = new Hashtable();
X509Certificate signingCert = (X509Certificate) certList.get(0);
gen.addSignerInfoGenerator(new JcaSimpleSignerInfoGeneratorBuilder().setProvider("BC")
.setSignedAttributeGenerator(new AttributeTable(signedAttrs))
.build("SHA256withRSA", privKey, signingCert));
gen.addCertificates(new JcaCertStore(certList));
// gen.addCRLs(new JcaCRLStore(certStore.getCRLs(null)));
boolean embedCrls = true;
if (embedCrls) {
X509CRL[] crls = fetchCRLs(signingCert);
for (X509CRL crl : crls) {
gen.addCRL(new JcaX509CRLHolder(crl));
}
}
// gen.addOtherRevocationInfo(arg0, arg1);
CMSProcessableByteArray processable = new CMSProcessableByteArray(IOUtils.toByteArray(content));
CMSSignedData signedData = gen.generate(processable, false);
if (tsaClient != null) {
signedData = signTimeStamps(signedData);
}
return signedData.getEncoded();
} catch (Exception e) {
new RuntimeException(e);
}
throw new RuntimeException("Problem while preparing signature");
}