当前位置: 首页>>代码示例>>Java>>正文


Java SMIMESignedGenerator类代码示例

本文整理汇总了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);
}
 
开发者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


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