• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SMIMESignedGenerator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.bouncycastle.mail.smime.SMIMESignedGenerator的典型用法代码示例。如果您正苦于以下问题:Java SMIMESignedGenerator类的具体用法?Java SMIMESignedGenerator怎么用?Java SMIMESignedGenerator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SMIMESignedGenerator类属于org.bouncycastle.mail.smime包,在下文中一共展示了SMIMESignedGenerator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
 
开发者ID:mlundblad,项目名称:bc-java,代码行数:19,代码来源:NewSMIMESignedTest.java


示例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");
}
 
开发者ID:mlundblad,项目名称:bc-java,代码行数:20,代码来源:SMIMESignedTest.java


示例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());
}
 
开发者ID:mlundblad,项目名称:bc-java,代码行数:21,代码来源:SMIMESignedTest.java


示例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");
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:20,代码来源:SMIMESignedTest.java


示例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();


}
 
开发者ID:gini,项目名称:jersey-smime,代码行数:24,代码来源:SignedTest.java


示例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");
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:21,代码来源:SMIMESignedTest.java


示例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;
}
 
开发者ID:cecid,项目名称:hermes,代码行数:14,代码来源:IncomingMessageProcessorTest.java


示例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());
}
 
开发者ID:mlundblad,项目名称:bc-java,代码行数:12,代码来源:SMIMESignedTest.java


示例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]);
}
 
开发者ID:mlundblad,项目名称:bc-java,代码行数:11,代码来源:SMIMESignedTest.java


示例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());
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:14,代码来源:NewSMIMESignedTest.java


示例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());
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:14,代码来源:NewSMIMESignedTest.java


示例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());
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:14,代码来源:NewSMIMESignedTest.java


示例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());
}
 
开发者ID:mlundblad,项目名称:bc-java,代码行数:14,代码来源:SMIMESignedTest.java


示例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());
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:14,代码来源:NewSMIMESignedTest.java


示例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());
}
 
开发者ID:mlundblad,项目名称:bc-java,代码行数:14,代码来源:SMIMESignedTest.java


示例16: testSHA224WithRSAParser

import org.bouncycastle.mail.smime.SMIMESignedGenerator; //导入依赖的package包/类
public void testSHA224WithRSAParser()
    throws Exception
{
    MimeMultipart     smm = generateMultiPartRsa("SHA224withRSA", msg, SMIMESignedGenerator.RFC3851_MICALGS);
    SMIMESignedParser s = new SMIMESignedParser(new JcaDigestCalculatorProviderBuilder().setProvider(BC).build(), smm);
    Store             certs = s.getCertificates();
    
    assertEquals(getDigestOid(s.getSignerInfos()), NISTObjectIdentifiers.id_sha224.toString());
    
    verifyMessageBytes(msg, s.getContent());

    verifySigners(certs, s.getSignerInfos());
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:14,代码来源:NewSMIMESignedTest.java


示例17: testSHA256WithRSABinaryWithParser

import org.bouncycastle.mail.smime.SMIMESignedGenerator; //导入依赖的package包/类
public void testSHA256WithRSABinaryWithParser()
    throws Exception
{
    MimeBodyPart      msg = generateBinaryPart();
    MimeMultipart     smm = generateMultiPartRsa("SHA256withRSA", msg, SMIMESignedGenerator.RFC3851_MICALGS);
    SMIMESignedParser s = new SMIMESignedParser(new JcaDigestCalculatorProviderBuilder().setProvider(BC).build(), smm);

    verifyMessageBytes(msg, s.getContent());

    verifySigners(s.getCertificates(), s.getSignerInfos());
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:12,代码来源:NewSMIMESignedTest.java


示例18: testSHA1WithRSA

import org.bouncycastle.mail.smime.SMIMESignedGenerator; //导入依赖的package包/类
public void testSHA1WithRSA()
    throws Exception
{
    MimeMultipart smm = generateMultiPartRsa(SMIMESignedGenerator.DIGEST_SHA1, msg, SMIMESignedGenerator.RFC3851_MICALGS);
    SMIMESigned   s = new SMIMESigned(smm);

    verifyMessageBytes(msg, s.getContent());

    verifySigners(s.getCertificatesAndCRLs("Collection", "BC"), s.getSignerInfos());
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:11,代码来源:SMIMESignedTest.java


示例19: generateMultiPartRsaPSS

import org.bouncycastle.mail.smime.SMIMESignedGenerator; //导入依赖的package包/类
private MimeMultipart generateMultiPartRsaPSS(
    String digest,
    MimeBodyPart msg,
    Date         signingTime)
    throws Exception
{
    List certList = new ArrayList();

    certList.add(_signCert);
    certList.add(_origCert);

    Store certs = new JcaCertStore(certList);

    ASN1EncodableVector signedAttrs = generateSignedAttributes();

    if (signingTime != null)
    {
        signedAttrs.add(new Attribute(CMSAttributes.signingTime, new DERSet(new Time(signingTime))));
    }

    SMIMESignedGenerator gen = new SMIMESignedGenerator();

    gen.addSignerInfoGenerator(new JcaSimpleSignerInfoGeneratorBuilder().setProvider(BC).setSignedAttributeGenerator(new AttributeTable(signedAttrs)).build(digest + "withRSAandMGF1", _signKP.getPrivate(), _signCert));
    gen.addCertificates(certs);

    return gen.generate(msg);
}
 
开发者ID:mlundblad,项目名称:bc-java,代码行数:28,代码来源:NewSMIMESignedTest.java


示例20: testSHA224WithRSA

import org.bouncycastle.mail.smime.SMIMESignedGenerator; //导入依赖的package包/类
public void testSHA224WithRSA()
    throws Exception
{
    MimeMultipart smm = generateMultiPartRsa(SMIMESignedGenerator.DIGEST_SHA224, 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.getCertificatesAndCRLs("Collection", "BC"), s.getSignerInfos());
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:14,代码来源:SMIMESignedTest.java



注:本文中的org.bouncycastle.mail.smime.SMIMESignedGenerator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Grape类代码示例发布时间:2022-05-22
下一篇:
Java JsonField类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap