本文整理汇总了Java中org.bouncycastle.mail.smime.SMIMESignedGenerator类的典型用法代码示例。如果您正苦于以下问题:Java SMIMESignedGenerator类的具体用法?Java SMIMESignedGenerator怎么用?Java SMIMESignedGenerator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SMIMESignedGenerator类属于org.bouncycastle.mail.smime包,在下文中一共展示了SMIMESignedGenerator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateMultiPartGost
import org.bouncycastle.mail.smime.SMIMESignedGenerator; //导入依赖的package包/类
private MimeMultipart generateMultiPartGost(
MimeBodyPart msg)
throws Exception
{
List certList = new ArrayList();
certList.add(_signCert);
certList.add(_signGostCert);
Store certs = new JcaCertStore(certList);
SMIMESignedGenerator gen = new SMIMESignedGenerator();
gen.addSignerInfoGenerator(new JcaSimpleSignerInfoGeneratorBuilder().setProvider(BC).build("GOST3411withGOST3410", _signGostKP.getPrivate(), _signGostCert));
gen.addCertificates(certs);
return gen.generate(msg);
}
示例2: generateMultiPartGost
import org.bouncycastle.mail.smime.SMIMESignedGenerator; //导入依赖的package包/类
private MimeMultipart generateMultiPartGost(
MimeBodyPart msg)
throws Exception
{
List certList = new ArrayList();
certList.add(_signCert);
certList.add(_signGostCert);
CertStore certs = CertStore.getInstance("Collection",
new CollectionCertStoreParameters(certList), "BC");
SMIMESignedGenerator gen = new SMIMESignedGenerator();
gen.addSigner(_signGostKP.getPrivate(), _signGostCert, SMIMESignedGenerator.DIGEST_GOST3411);
gen.addCertificatesAndCRLs(certs);
return gen.generate(msg, "BC");
}
示例3: testSHA1WithRSAEncapsulatedParserAndFile
import org.bouncycastle.mail.smime.SMIMESignedGenerator; //导入依赖的package包/类
public void testSHA1WithRSAEncapsulatedParserAndFile()
throws Exception
{
File tmp = File.createTempFile("bcTest", ".mime");
MimeBodyPart res = generateEncapsulatedRsa(SMIMESignedGenerator.DIGEST_SHA1, msg);
SMIMESignedParser s = new SMIMESignedParser(res, tmp);
FileBackedMimeBodyPart content = (FileBackedMimeBodyPart)s.getContent();
verifyMessageBytes(msg, s.getContent());
verifySigners(s.getCertificatesAndCRLs("Collection", "BC"), s.getSignerInfos());
assertTrue(tmp.exists());
s.close();
content.dispose();
assertFalse(tmp.exists());
}
示例4: 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");
}
示例5: testPythonVerified
import org.bouncycastle.mail.smime.SMIMESignedGenerator; //导入依赖的package包/类
@Test
public void testPythonVerified() throws Exception {
SMIMESignedGenerator gen = new SMIMESignedGenerator();
SignerInfoGenerator signer = new JcaSimpleSignerInfoGeneratorBuilder().setProvider("BC").build("SHA1WITHRSA", privateKey, cert);
gen.addSignerInfoGenerator(signer);
MimeMultipart mp = gen.generate(createMsg());
ByteArrayOutputStream os = new ByteArrayOutputStream();
mp.writeTo(os);
String contentType = mp.getContentType();
contentType = contentType.replace("\r\n", "").replace("\t", " ");
System.out.println(contentType);
String s = new String(os.toByteArray());
StringBuilder builder = new StringBuilder();
builder.append("Content-Type: ").append(contentType).append("\r\n\r\n").append(s);
String output = builder.toString();
FileOutputStream fp = new FileOutputStream("smime_signed.txt");
fp.write(output.getBytes());
fp.close();
}
示例6: 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");
}
示例7: calculateMIC
import org.bouncycastle.mail.smime.SMIMESignedGenerator; //导入依赖的package包/类
private String calculateMIC(MimeBodyPart bodyPart) throws Exception{
// By default, MIC calculate with Headers
ByteArrayOutputStream contentBAOS = new ByteArrayOutputStream();
bodyPart.writeTo(contentBAOS);
byte[] content = (contentBAOS.toByteArray());
MessageDigest md = MessageDigest.getInstance( SMIMESignedGenerator.DIGEST_SHA1, "BC");
md.update(content);
byte[] digest = md.digest();
String digestString = new String(Base64.encode(digest));
return digestString + ", " + DispositionNotificationOption.SIGNED_RECEIPT_MICALG_SHA1;
}
示例8: testSHA256WithRSABinary
import org.bouncycastle.mail.smime.SMIMESignedGenerator; //导入依赖的package包/类
public void testSHA256WithRSABinary()
throws Exception
{
MimeBodyPart msg = generateBinaryPart();
MimeMultipart smm = generateMultiPartRsa(SMIMESignedGenerator.DIGEST_SHA256, msg, SMIMESignedGenerator.RFC3851_MICALGS);
SMIMESigned s = new SMIMESigned(smm);
verifyMessageBytes(msg, s.getContent());
verifySigners(s.getCertificatesAndCRLs("Collection", "BC"), s.getSignerInfos());
}
示例9: testHeaders
import org.bouncycastle.mail.smime.SMIMESignedGenerator; //导入依赖的package包/类
public void testHeaders()
throws Exception
{
MimeMultipart smm = generateMultiPartRsa(SMIMESignedGenerator.DIGEST_SHA1, msg, SMIMESignedGenerator.RFC3851_MICALGS);
BodyPart bp = smm.getBodyPart(1);
assertEquals("application/pkcs7-signature; name=smime.p7s; smime-type=signed-data", bp.getHeader("Content-Type")[0]);
assertEquals("attachment; filename=\"smime.p7s\"", bp.getHeader("Content-Disposition")[0]);
assertEquals("S/MIME Cryptographic Signature", bp.getHeader("Content-Description")[0]);
}
示例10: testSHA224WithRSARfc3851
import org.bouncycastle.mail.smime.SMIMESignedGenerator; //导入依赖的package包/类
public void testSHA224WithRSARfc3851()
throws Exception
{
MimeMultipart smm = generateMultiPartRsa("SHA224withRSA", msg, SMIMESignedGenerator.RFC3851_MICALGS);
SMIMESigned s = new SMIMESigned(smm);
assertEquals("sha224", getMicAlg(smm));
assertEquals(getDigestOid(s.getSignerInfos()), NISTObjectIdentifiers.id_sha224.toString());
verifyMessageBytes(msg, s.getContent());
verifySigners(s.getCertificates(), s.getSignerInfos());
}
示例11: testSHA256WithRSARfc3851
import org.bouncycastle.mail.smime.SMIMESignedGenerator; //导入依赖的package包/类
public void testSHA256WithRSARfc3851()
throws Exception
{
MimeMultipart smm = generateMultiPartRsa("SHA256withRSA", msg, SMIMESignedGenerator.RFC3851_MICALGS);
SMIMESigned s = new SMIMESigned(smm);
assertEquals("sha256", getMicAlg(smm));
assertEquals(getDigestOid(s.getSignerInfos()), NISTObjectIdentifiers.id_sha256.toString());
verifyMessageBytes(msg, s.getContent());
verifySigners(s.getCertificates(), s.getSignerInfos());
}
示例12: testSHA384WithRSA
import org.bouncycastle.mail.smime.SMIMESignedGenerator; //导入依赖的package包/类
public void testSHA384WithRSA()
throws Exception
{
MimeMultipart smm = generateMultiPartRsa("SHA384withRSA", msg, SMIMESignedGenerator.STANDARD_MICALGS);
SMIMESigned s = new SMIMESigned(smm);
assertEquals("sha-384", getMicAlg(smm));
assertEquals(getDigestOid(s.getSignerInfos()), NISTObjectIdentifiers.id_sha384.toString());
verifyMessageBytes(msg, s.getContent());
verifySigners(s.getCertificates(), s.getSignerInfos());
}
示例13: testSHA224WithRSAParser
import org.bouncycastle.mail.smime.SMIMESignedGenerator; //导入依赖的package包/类
public void testSHA224WithRSAParser()
throws Exception
{
MimeMultipart smm = generateMultiPartRsa(SMIMESignedGenerator.DIGEST_SHA224, msg, SMIMESignedGenerator.RFC3851_MICALGS);
SMIMESignedParser s = new SMIMESignedParser(smm);
CertStore certs = s.getCertificatesAndCRLs("Collection", "BC");
assertEquals(getDigestOid(s.getSignerInfos()), NISTObjectIdentifiers.id_sha224.toString());
verifyMessageBytes(msg, s.getContent());
verifySigners(certs, s.getSignerInfos());
}
示例14: testSHA512WithRSARfc3851
import org.bouncycastle.mail.smime.SMIMESignedGenerator; //导入依赖的package包/类
public void testSHA512WithRSARfc3851()
throws Exception
{
MimeMultipart smm = generateMultiPartRsa("SHA512withRSA", msg, SMIMESignedGenerator.RFC3851_MICALGS);
SMIMESigned s = new SMIMESigned(smm);
assertEquals("sha512", getMicAlg(smm));
assertEquals(getDigestOid(s.getSignerInfos()), NISTObjectIdentifiers.id_sha512.toString());
verifyMessageBytes(msg, s.getContent());
verifySigners(s.getCertificates(), s.getSignerInfos());
}
示例15: testSHA512WithRSA
import org.bouncycastle.mail.smime.SMIMESignedGenerator; //导入依赖的package包/类
public void testSHA512WithRSA()
throws Exception
{
MimeMultipart smm = generateMultiPartRsa(SMIMESignedGenerator.DIGEST_SHA512, msg, SMIMESignedGenerator.RFC3851_MICALGS);
SMIMESigned s = new SMIMESigned(smm);
assertEquals("sha512", getMicAlg(smm));
assertEquals(getDigestOid(s.getSignerInfos()), NISTObjectIdentifiers.id_sha512.toString());
verifyMessageBytes(msg, s.getContent());
verifySigners(s.getCertificatesAndCRLs("Collection", "BC"), s.getSignerInfos());
}