本文整理汇总了Java中org.bouncycastle.mail.smime.SMIMESignedGenerator.addCertificatesAndCRLs方法的典型用法代码示例。如果您正苦于以下问题:Java SMIMESignedGenerator.addCertificatesAndCRLs方法的具体用法?Java SMIMESignedGenerator.addCertificatesAndCRLs怎么用?Java SMIMESignedGenerator.addCertificatesAndCRLs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.mail.smime.SMIMESignedGenerator
的用法示例。
在下文中一共展示了SMIMESignedGenerator.addCertificatesAndCRLs方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateEncapsulatedRsa
import org.bouncycastle.mail.smime.SMIMESignedGenerator; //导入方法依赖的package包/类
private MimeBodyPart generateEncapsulatedRsa(String digestOid, MimeBodyPart msg)
throws Exception
{
List certList = new ArrayList();
certList.add(_signCert);
certList.add(_origCert);
CertStore certs = CertStore.getInstance("Collection",
new CollectionCertStoreParameters(certList), "BC");
ASN1EncodableVector signedAttrs = generateSignedAttributes();
SMIMESignedGenerator gen = new SMIMESignedGenerator();
gen.addSigner(_signKP.getPrivate(), _signCert, digestOid, new AttributeTable(signedAttrs), null);
gen.addCertificatesAndCRLs(certs);
return gen.generateEncapsulated(msg, "BC");
}
示例2: generateMultiPartECGost
import org.bouncycastle.mail.smime.SMIMESignedGenerator; //导入方法依赖的package包/类
private MimeMultipart generateMultiPartECGost(
MimeBodyPart msg)
throws Exception
{
List certList = new ArrayList();
certList.add(_signCert);
certList.add(_signEcGostCert);
CertStore certs = CertStore.getInstance("Collection",
new CollectionCertStoreParameters(certList), "BC");
SMIMESignedGenerator gen = new SMIMESignedGenerator();
gen.addSigner(_signEcGostKP.getPrivate(), _signEcGostCert, SMIMESignedGenerator.DIGEST_GOST3411);
gen.addCertificatesAndCRLs(certs);
return gen.generate(msg, "BC");
}
示例3: generateMultiPartRsaPSS
import org.bouncycastle.mail.smime.SMIMESignedGenerator; //导入方法依赖的package包/类
private MimeMultipart generateMultiPartRsaPSS(
String digestOid,
MimeBodyPart msg,
Date signingTime)
throws Exception
{
List certList = new ArrayList();
certList.add(_signCert);
certList.add(_origCert);
CertStore certs = CertStore.getInstance("Collection",
new CollectionCertStoreParameters(certList), "BC");
ASN1EncodableVector signedAttrs = generateSignedAttributes();
if (signingTime != null)
{
signedAttrs.add(new Attribute(CMSAttributes.signingTime, new DERSet(new Time(signingTime))));
}
SMIMESignedGenerator gen = new SMIMESignedGenerator();
gen.addSigner(_signKP.getPrivate(), _signCert, SMIMESignedGenerator.ENCRYPTION_RSA_PSS, digestOid, new AttributeTable(signedAttrs), null);
gen.addCertificatesAndCRLs(certs);
return gen.generate(msg, "BC");
}
示例4: testHeadersEncapsulated
import org.bouncycastle.mail.smime.SMIMESignedGenerator; //导入方法依赖的package包/类
public void testHeadersEncapsulated()
throws Exception
{
List certList = new ArrayList();
certList.add(_signCert);
certList.add(_origCert);
CertStore certs = CertStore.getInstance("Collection",
new CollectionCertStoreParameters(certList), "BC");
ASN1EncodableVector signedAttrs = generateSignedAttributes();
SMIMESignedGenerator gen = new SMIMESignedGenerator();
gen.addSigner(_signKP.getPrivate(), _signCert, SMIMESignedGenerator.DIGEST_SHA1, new AttributeTable(signedAttrs), null);
gen.addCertificatesAndCRLs(certs);
MimeBodyPart res = gen.generateEncapsulated(msg, "BC");
assertEquals("application/pkcs7-mime; name=smime.p7m; smime-type=signed-data", res.getHeader("Content-Type")[0]);
assertEquals("attachment; filename=\"smime.p7m\"", res.getHeader("Content-Disposition")[0]);
assertEquals("S/MIME Cryptographic Signed Data", res.getHeader("Content-Description")[0]);
}
示例5: testSHA1WithRSAAddSigners
import org.bouncycastle.mail.smime.SMIMESignedGenerator; //导入方法依赖的package包/类
public void testSHA1WithRSAAddSigners()
throws Exception
{
MimeMultipart smm = generateMultiPartRsa(SMIMESignedGenerator.DIGEST_SHA1, msg, SMIMESignedGenerator.RFC3851_MICALGS);
SMIMESigned s = new SMIMESigned(smm);
List certList = new ArrayList();
certList.add(_signCert);
certList.add(_origCert);
CertStore certs = CertStore.getInstance("Collection",
new CollectionCertStoreParameters(certList), "BC");
SMIMESignedGenerator gen = new SMIMESignedGenerator();
gen.addSigners(s.getSignerInfos());
gen.addCertificatesAndCRLs(certs);
SMIMESigned newS = new SMIMESigned(gen.generate(msg, "BC"));
verifyMessageBytes(msg, newS.getContent());
verifySigners(newS.getCertificatesAndCRLs("Collection", "BC"), newS.getSignerInfos());
}
示例6: testCertificateManagement
import org.bouncycastle.mail.smime.SMIMESignedGenerator; //导入方法依赖的package包/类
public void testCertificateManagement()
throws Exception
{
List certList = new ArrayList();
certList.add(_signCert);
certList.add(_origCert);
CertStore certs = CertStore.getInstance("Collection",
new CollectionCertStoreParameters(certList), "BC");
SMIMESignedGenerator gen = new SMIMESignedGenerator();
gen.addCertificatesAndCRLs(certs);
MimeBodyPart smm = gen.generateCertificateManagement("BC");
SMIMESigned s = new SMIMESigned(smm);
certs = s.getCertificatesAndCRLs("Collection", "BC");
assertEquals(2, certs.getCertificates(null).size());
}
示例7: testMimeMultipartBinaryParser
import org.bouncycastle.mail.smime.SMIMESignedGenerator; //导入方法依赖的package包/类
public void testMimeMultipartBinaryParser()
throws Exception
{
MimeBodyPart m = createMultipartMessage();
List certList = new ArrayList();
certList.add(_signCert);
certList.add(_origCert);
CertStore certs = CertStore.getInstance("Collection",
new CollectionCertStoreParameters(certList), "BC");
ASN1EncodableVector signedAttrs = generateSignedAttributes();
SMIMESignedGenerator gen = new SMIMESignedGenerator("binary");
gen.addSigner(_signKP.getPrivate(), _signCert, SMIMESignedGenerator.DIGEST_SHA1, new AttributeTable(signedAttrs), null);
gen.addCertificatesAndCRLs(certs);
MimeMultipart mm = gen.generate(m, "BC");
SMIMESignedParser s = new SMIMESignedParser(mm, "binary");
verifySigners(s.getCertificatesAndCRLs("Collection", "BC"), s.getSignerInfos());
}
示例8: testMimeMultipartBinaryReader
import org.bouncycastle.mail.smime.SMIMESignedGenerator; //导入方法依赖的package包/类
public void testMimeMultipartBinaryReader()
throws Exception
{
MimeBodyPart m = createMultipartMessage();
List certList = new ArrayList();
certList.add(_signCert);
certList.add(_origCert);
CertStore certs = CertStore.getInstance("Collection",
new CollectionCertStoreParameters(certList), "BC");
ASN1EncodableVector signedAttrs = generateSignedAttributes();
SMIMESignedGenerator gen = new SMIMESignedGenerator("binary");
gen.addSigner(_signKP.getPrivate(), _signCert, SMIMESignedGenerator.DIGEST_SHA1, new AttributeTable(signedAttrs), null);
gen.addCertificatesAndCRLs(certs);
MimeMultipart mm = gen.generate(m, "BC");
SMIMESigned s = new SMIMESigned(mm, "binary");
verifySigners(s.getCertificatesAndCRLs("Collection", "BC"), s.getSignerInfos());
}
示例9: testMimeMultipartBinaryParserGetMimeContent
import org.bouncycastle.mail.smime.SMIMESignedGenerator; //导入方法依赖的package包/类
public void testMimeMultipartBinaryParserGetMimeContent()
throws Exception
{
MimeBodyPart m = createMultipartMessage();
List certList = new ArrayList();
certList.add(_signCert);
certList.add(_origCert);
CertStore certs = CertStore.getInstance("Collection",
new CollectionCertStoreParameters(certList), "BC");
ASN1EncodableVector signedAttrs = generateSignedAttributes();
SMIMESignedGenerator gen = new SMIMESignedGenerator("binary");
gen.addSigner(_signKP.getPrivate(), _signCert, SMIMESignedGenerator.DIGEST_SHA1, new AttributeTable(signedAttrs), null);
gen.addCertificatesAndCRLs(certs);
MimeMultipart mm = gen.generate(m, "BC");
SMIMESignedParser s = new SMIMESignedParser(mm, "binary");
verifySigners(s.getCertificatesAndCRLs("Collection", "BC"), s.getSignerInfos());
MimeMessage bp = s.getContentAsMimeMessage(Session.getDefaultInstance(new Properties()));
}
示例10: testSignAttachmentOnly
import org.bouncycastle.mail.smime.SMIMESignedGenerator; //导入方法依赖的package包/类
public void testSignAttachmentOnly()
throws Exception
{
MimeMessage m = loadMessage("attachonly.eml");
List certList = new ArrayList();
certList.add(_signCert);
certList.add(_origCert);
CertStore certs = CertStore.getInstance("Collection",
new CollectionCertStoreParameters(certList), "BC");
ASN1EncodableVector signedAttrs = generateSignedAttributes();
SMIMESignedGenerator gen = new SMIMESignedGenerator("binary");
gen.addSigner(_signKP.getPrivate(), _signCert, SMIMESignedGenerator.DIGEST_SHA1, new AttributeTable(signedAttrs), null);
gen.addCertificatesAndCRLs(certs);
MimeMultipart mm = gen.generate(m, "BC");
SMIMESigned s = new SMIMESigned(mm);
verifySigners(s.getCertificatesAndCRLs("Collection", "BC"), s.getSignerInfos());
SMIMESignedParser sp = new SMIMESignedParser(mm);
verifySigners(sp.getCertificatesAndCRLs("Collection", "BC"), sp.getSignerInfos());
}
示例11: testMD5WithRSAAddSignersSHA1
import org.bouncycastle.mail.smime.SMIMESignedGenerator; //导入方法依赖的package包/类
public void testMD5WithRSAAddSignersSHA1()
throws Exception
{
MimeMultipart smm = generateMultiPartRsa(SMIMESignedGenerator.DIGEST_SHA1, msg, SMIMESignedGenerator.RFC3851_MICALGS);
SMIMESigned s = new SMIMESigned(smm);
List certList = new ArrayList();
certList.add(_signCert);
certList.add(_origCert);
CertStore certs = CertStore.getInstance("Collection",
new CollectionCertStoreParameters(certList), "BC");
SMIMESignedGenerator gen = new SMIMESignedGenerator();
gen.addSigner(_signKP.getPrivate(), _signCert, SMIMESignedGenerator.DIGEST_MD5);
gen.addSigners(s.getSignerInfos());
gen.addCertificatesAndCRLs(certs);
smm = gen.generate(msg, "BC");
SMIMESigned newS = new SMIMESigned(gen.generate(msg, "BC"));
verifyMessageBytes(msg, newS.getContent());
verifySigners(newS.getCertificatesAndCRLs("Collection", "BC"), newS.getSignerInfos());
assertEquals("\"md5,sha-1\"", getMicAlg(smm));
}
示例12: testSHA224WithRSAParserEncryptedWithDES
import org.bouncycastle.mail.smime.SMIMESignedGenerator; //导入方法依赖的package包/类
public void testSHA224WithRSAParserEncryptedWithDES()
throws Exception
{
List certList = new ArrayList();
certList.add(_signCert);
certList.add(_origCert);
CertStore certs = CertStore.getInstance("Collection",
new CollectionCertStoreParameters(certList), "BC");
ASN1EncodableVector signedAttrs = generateSignedAttributes();
SMIMESignedGenerator gen = new SMIMESignedGenerator();
gen.addSigner(_signKP.getPrivate(), _signCert, SMIMESignedGenerator.DIGEST_SHA224, new AttributeTable(signedAttrs), null);
gen.addCertificatesAndCRLs(certs);
MimeMultipart smm = gen.generate(msg, "BC");
SMIMESignedParser s = new SMIMESignedParser(smm);
certs = s.getCertificatesAndCRLs("Collection", "BC");
assertEquals(getDigestOid(s.getSignerInfos()), NISTObjectIdentifiers.id_sha224.toString());
verifyMessageBytes(msg, s.getContent());
verifySigners(certs, s.getSignerInfos());
}
示例13: testWithAttributeCertificate
import org.bouncycastle.mail.smime.SMIMESignedGenerator; //导入方法依赖的package包/类
public void testWithAttributeCertificate()
throws Exception
{
List certList = new ArrayList();
certList.add(_signCert);
certList.add(_origCert);
CertStore certs = CertStore.getInstance("Collection",
new CollectionCertStoreParameters(certList), "BC");
ASN1EncodableVector signedAttrs = generateSignedAttributes();
SMIMESignedGenerator gen = new SMIMESignedGenerator();
gen.addSigner(_signKP.getPrivate(), _signCert, SMIMESignedGenerator.DIGEST_SHA256, new AttributeTable(signedAttrs), null);
gen.addCertificatesAndCRLs(certs);
X509AttributeCertificateHolder attrCert = CMSTestUtil.getAttributeCertificate();
X509Store store = X509Store.getInstance("AttributeCertificate/Collection",
new X509CollectionStoreParameters(Collections.singleton(attrCert)), "BC");
gen.addAttributeCertificates(store);
SMIMESigned s = new SMIMESigned(gen.generateEncapsulated(msg, "BC"));
verifyMessageBytes(msg, s.getContent());
verifySigners(s.getCertificatesAndCRLs("Collection", "BC"), s.getSignerInfos());
Store attrCerts = s.getAttributeCertificates();
assertTrue(attrCerts.getMatches(null).contains(attrCert));
}
示例14: testSHA1withDSA
import org.bouncycastle.mail.smime.SMIMESignedGenerator; //导入方法依赖的package包/类
public void testSHA1withDSA()
throws Exception
{
dsaSignKP = CMSTestUtil.makeDsaKeyPair();
dsaSignCert = CMSTestUtil.makeCertificate(dsaSignKP, _origDN, dsaSignKP, _origDN);
dsaOrigKP = CMSTestUtil.makeDsaKeyPair();
dsaOrigCert = CMSTestUtil.makeCertificate(dsaOrigKP, _signDN, dsaSignKP, _origDN);
List certList = new ArrayList();
certList.add(dsaOrigCert);
certList.add(dsaSignCert);
CertStore certs = CertStore.getInstance("Collection",
new CollectionCertStoreParameters(certList), "BC");
SMIMESignedGenerator gen = new SMIMESignedGenerator();
gen.addSigner(dsaOrigKP.getPrivate(), dsaOrigCert, SMIMESignedGenerator.DIGEST_SHA1);
gen.addCertificatesAndCRLs(certs);
MimeMultipart smm = gen.generate(msg, "BC");
SMIMESigned s = new SMIMESigned(smm);
verifyMessageBytes(msg, s.getContent());
verifySigners(s.getCertificatesAndCRLs("Collection", "BC"), s.getSignerInfos());
}
示例15: testMimeMultipart
import org.bouncycastle.mail.smime.SMIMESignedGenerator; //导入方法依赖的package包/类
public void testMimeMultipart()
throws Exception
{
MimeBodyPart m = createMultipartMessage();
List certList = new ArrayList();
certList.add(_signCert);
certList.add(_origCert);
CertStore certs = CertStore.getInstance("Collection",
new CollectionCertStoreParameters(certList), "BC");
ASN1EncodableVector signedAttrs = generateSignedAttributes();
SMIMESignedGenerator gen = new SMIMESignedGenerator("binary");
gen.addSigner(_signKP.getPrivate(), _signCert, SMIMESignedGenerator.DIGEST_SHA1, new AttributeTable(signedAttrs), null);
gen.addCertificatesAndCRLs(certs);
MimeMultipart mm = gen.generate(m, "BC");
SMIMESigned s = new SMIMESigned(mm);
verifySigners(s.getCertificatesAndCRLs("Collection", "BC"), s.getSignerInfos());
byte[] contentDigest = (byte[])gen.getGeneratedDigests().get(SMIMESignedGenerator.DIGEST_SHA1);
AttributeTable table = ((SignerInformation)s.getSignerInfos().getSigners().iterator().next()).getSignedAttributes();
Attribute hash = table.get(CMSAttributes.messageDigest);
assertTrue(MessageDigest.isEqual(contentDigest, ((ASN1OctetString)hash.getAttrValues().getObjectAt(0)).getOctets()));
}