當前位置: 首頁>>代碼示例>>Java>>正文


Java FileBackedMimeBodyPart類代碼示例

本文整理匯總了Java中org.bouncycastle.mail.smime.util.FileBackedMimeBodyPart的典型用法代碼示例。如果您正苦於以下問題:Java FileBackedMimeBodyPart類的具體用法?Java FileBackedMimeBodyPart怎麽用?Java FileBackedMimeBodyPart使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FileBackedMimeBodyPart類屬於org.bouncycastle.mail.smime.util包,在下文中一共展示了FileBackedMimeBodyPart類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testSHA1WithRSAEncapsulatedParserAndFile

import org.bouncycastle.mail.smime.util.FileBackedMimeBodyPart; //導入依賴的package包/類
public void testSHA1WithRSAEncapsulatedParserAndFile()
    throws Exception
{
    File         tmp = File.createTempFile("bcTest", ".mime");
    MimeBodyPart res = generateEncapsulatedRsa("SHA1withRSA", msg);       
    SMIMESignedParser s = new SMIMESignedParser(new JcaDigestCalculatorProviderBuilder().setProvider(BC).build(), res, tmp);
    FileBackedMimeBodyPart content = (FileBackedMimeBodyPart)s.getContent();

    verifyMessageBytes(msg, s.getContent());

    verifySigners(s.getCertificates(), s.getSignerInfos());
    
    assertTrue(tmp.exists());
    
    s.close();
    
    content.dispose();
    
    assertFalse(tmp.exists());
}
 
開發者ID:credentials,項目名稱:irma_future_id,代碼行數:21,代碼來源:NewSMIMESignedTest.java

示例2: testSHA1WithRSAEncapsulatedParserAndFile

import org.bouncycastle.mail.smime.util.FileBackedMimeBodyPart; //導入依賴的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:credentials,項目名稱:irma_future_id,代碼行數:21,代碼來源:SMIMESignedTest.java

示例3: toMimeBodyPart

import org.bouncycastle.mail.smime.util.FileBackedMimeBodyPart; //導入依賴的package包/類
/**
 * return a file backed MimeBodyPart described in {@link CMSTypedStream} content. 
 * </p>
 */
public static FileBackedMimeBodyPart toMimeBodyPart(
    CMSTypedStream    content)
    throws SMIMEException
{
    try
    {
        return toMimeBodyPart(content, File.createTempFile("bcMail", ".mime"));
    }
    catch (IOException e)
    {
        throw new SMIMEException("IOException creating tmp file:" + e.getMessage(), e);
    }
}
 
開發者ID:credentials,項目名稱:irma_future_id,代碼行數:18,代碼來源:SMIMEUtil.java

示例4: testQuotePrintableSigPreservation

import org.bouncycastle.mail.smime.util.FileBackedMimeBodyPart; //導入依賴的package包/類
public void testQuotePrintableSigPreservation()
    throws Exception
{
    MimeMessage msg = new MimeMessage((Session)null, getClass().getResourceAsStream("qp-soft-break.eml"));

    SMIMEEnvelopedGenerator  encGen = new SMIMEEnvelopedGenerator();

    encGen.addKeyTransRecipient(origCert);

    MimeBodyPart   mp = encGen.generate(msg, SMIMEEnvelopedGenerator.AES128_CBC, "BC");

    SMIMEEnveloped       env = new SMIMEEnveloped(mp);
    RecipientInformation ri = (RecipientInformation)env.getRecipientInfos().getRecipients().iterator().next();
    MimeBodyPart         mm = SMIMEUtil.toMimeBodyPart(ri.getContentStream(origKP.getPrivate(), "BC"));
    SMIMESigned          s = new SMIMESigned((MimeMultipart)mm.getContent());
    Collection           c = s.getSignerInfos().getSigners();
    Iterator             it = c.iterator();
    CertStore            certs = s.getCertificatesAndCRLs("Collection", "BC");

    while (it.hasNext())
    {
        SignerInformation   signer = (SignerInformation)it.next();
        Collection          certCollection = certs.getCertificates(selectorConverter.getCertSelector(signer.getSID()));

        Iterator        certIt = certCollection.iterator();
        X509Certificate cert = (X509Certificate)certIt.next();

        assertEquals(true, signer.verify(cert, "BC"));
    }

    ((FileBackedMimeBodyPart)mm).dispose();
}
 
開發者ID:credentials,項目名稱:irma_future_id,代碼行數:33,代碼來源:SMIMEMiscTest.java

示例5: testSHA1WithRSAEncapsulatedParser

import org.bouncycastle.mail.smime.util.FileBackedMimeBodyPart; //導入依賴的package包/類
public void testSHA1WithRSAEncapsulatedParser()
    throws Exception
{
    MimeBodyPart res = generateEncapsulatedRsa("SHA1withRSA", msg);
    SMIMESignedParser s = new SMIMESignedParser(new JcaDigestCalculatorProviderBuilder().setProvider(BC).build(), res);

    FileBackedMimeBodyPart content = (FileBackedMimeBodyPart)s.getContent();
    
    verifyMessageBytes(msg, content);

    content.dispose();
    
    verifySigners(s.getCertificates(), s.getSignerInfos());
    
    s.close();
}
 
開發者ID:credentials,項目名稱:irma_future_id,代碼行數:17,代碼來源:NewSMIMESignedTest.java

示例6: testSHA1WithRSAEncapsulatedParser

import org.bouncycastle.mail.smime.util.FileBackedMimeBodyPart; //導入依賴的package包/類
public void testSHA1WithRSAEncapsulatedParser()
    throws Exception
{
    MimeBodyPart res = generateEncapsulatedRsa(SMIMESignedGenerator.DIGEST_SHA1, msg);       
    SMIMESignedParser s = new SMIMESignedParser(res);

    FileBackedMimeBodyPart content = (FileBackedMimeBodyPart)s.getContent();
    
    verifyMessageBytes(msg, content);

    content.dispose();
    
    verifySigners(s.getCertificatesAndCRLs("Collection", "BC"), s.getSignerInfos());
    
    s.close();
}
 
開發者ID:credentials,項目名稱:irma_future_id,代碼行數:17,代碼來源:SMIMESignedTest.java

示例7: testTwoRecipients

import org.bouncycastle.mail.smime.util.FileBackedMimeBodyPart; //導入依賴的package包/類
public void testTwoRecipients()
    throws Exception
{
    MimeBodyPart    _msg      = SMIMETestUtil.makeMimeBodyPart("WallaWallaWashington");

    SMIMEEnvelopedGenerator   gen = new SMIMEEnvelopedGenerator();
      
    gen.addKeyTransRecipient(_reciCert);
    gen.addKeyTransRecipient(_reciCert2);
     
    //
    // generate a MimeBodyPart object which encapsulates the content
    // we want encrypted.
    //
    MimeBodyPart mp = gen.generate(_msg, SMIMEEnvelopedGenerator.RC2_CBC, 40, "BC");

    SMIMEEnvelopedParser       m = new SMIMEEnvelopedParser(mp);

    RecipientId                recId = getRecipientId(_reciCert2);

    RecipientInformationStore  recipients = m.getRecipientInfos();
    RecipientInformation       recipient = recipients.get(recId);
    
    FileBackedMimeBodyPart    res = SMIMEUtil.toMimeBodyPart(recipient.getContentStream(_reciKP2.getPrivate(), "BC"));

    verifyMessageBytes(_msg, res);
    
    m = new SMIMEEnvelopedParser(mp);

    res.dispose();
    
    recId = getRecipientId(_reciCert);

    recipients = m.getRecipientInfos();
    recipient = recipients.get(recId);
 
    res = SMIMEUtil.toMimeBodyPart(recipient.getContentStream(_reciKP.getPrivate(), "BC"));

    verifyMessageBytes(_msg, res);
    
    res.dispose();
}
 
開發者ID:credentials,項目名稱:irma_future_id,代碼行數:43,代碼來源:SMIMEEnvelopedTest.java

示例8: testTwoRecipients

import org.bouncycastle.mail.smime.util.FileBackedMimeBodyPart; //導入依賴的package包/類
public void testTwoRecipients()
    throws Exception
{
    MimeBodyPart    _msg      = SMIMETestUtil.makeMimeBodyPart("WallaWallaWashington");

    SMIMEEnvelopedGenerator   gen = new SMIMEEnvelopedGenerator();

    gen.addRecipientInfoGenerator(new JceKeyTransRecipientInfoGenerator(_reciCert).setProvider(BC));
    gen.addRecipientInfoGenerator(new JceKeyTransRecipientInfoGenerator(_reciCert2).setProvider(BC));
     
    //
    // generate a MimeBodyPart object which encapsulates the content
    // we want encrypted.
    //
    MimeBodyPart mp = gen.generate(_msg, new JceCMSContentEncryptorBuilder(CMSAlgorithm.RC2_CBC, 40).setProvider(BC).build());

    SMIMEEnvelopedParser       m = new SMIMEEnvelopedParser(mp);

    RecipientId                recId = getRecipientId(_reciCert2);

    RecipientInformationStore  recipients = m.getRecipientInfos();
    RecipientInformation       recipient = recipients.get(recId);
    
    FileBackedMimeBodyPart    res = SMIMEUtil.toMimeBodyPart(recipient.getContentStream(new JceKeyTransEnvelopedRecipient(_reciKP2.getPrivate()).setProvider(BC)));

    verifyMessageBytes(_msg, res);
    
    m = new SMIMEEnvelopedParser(mp);

    res.dispose();
    
    recId = getRecipientId(_reciCert);

    recipients = m.getRecipientInfos();
    recipient = recipients.get(recId);
 
    res = SMIMEUtil.toMimeBodyPart(recipient.getContentStream(new JceKeyTransEnvelopedRecipient(_reciKP.getPrivate()).setProvider(BC)));

    verifyMessageBytes(_msg, res);
    
    res.dispose();
}
 
開發者ID:credentials,項目名稱:irma_future_id,代碼行數:43,代碼來源:NewSMIMEEnvelopedTest.java


注:本文中的org.bouncycastle.mail.smime.util.FileBackedMimeBodyPart類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。