Search in sources :

Example 16 with SMIMEEnveloped

use of org.bouncycastle.mail.smime.SMIMEEnveloped in project nhin-d by DirectProject.

the class SplitDirectRecipientInformationFactory_createInstanceTest method createSMIMEEnv.

protected SMIMEEnveloped createSMIMEEnv() throws Exception {
    // get the cert
    final X509Certificate cert = TestUtils.getExternalCert("user1");
    // create an encrypted message
    final MimeEntity entity = new MimeEntity();
    entity.setText("Hello world.");
    entity.setHeader(MimeStandard.ContentTypeHeader, "text/plain");
    entity.setHeader(MimeStandard.ContentTransferEncodingHeader, "7bit");
    final SMIMECryptographerImpl encryptor = new SMIMECryptographerImpl();
    return new SMIMEEnveloped(encryptor.encrypt(entity, Arrays.asList(cert)));
}
Also used : SMIMECryptographerImpl(org.nhindirect.stagent.cryptography.SMIMECryptographerImpl) MimeEntity(org.nhindirect.stagent.mail.MimeEntity) SMIMEEnveloped(org.bouncycastle.mail.smime.SMIMEEnveloped) X509Certificate(java.security.cert.X509Certificate)

Aggregations

SMIMEEnveloped (org.bouncycastle.mail.smime.SMIMEEnveloped)16 RecipientInformation (org.bouncycastle.cms.RecipientInformation)9 X509Certificate (java.security.cert.X509Certificate)5 X509CertificateEx (org.nhindirect.stagent.cert.X509CertificateEx)5 MimeEntity (org.nhindirect.stagent.mail.MimeEntity)5 SMIMECryptographerImpl (org.nhindirect.stagent.cryptography.SMIMECryptographerImpl)4 KeyStore (java.security.KeyStore)3 PrivateKey (java.security.PrivateKey)3 File (java.io.File)2 InputStream (java.io.InputStream)2 Key (java.security.Key)2 Certificate (java.security.cert.Certificate)2 RecipientId (org.bouncycastle.cms.RecipientId)2 RecipientInformationStore (org.bouncycastle.cms.RecipientInformationStore)2 DirectRecipientInformation (org.nhindirect.stagent.cryptography.activekeyops.DirectRecipientInformation)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 MessagingException (javax.mail.MessagingException)1 MimeBodyPart (javax.mail.internet.MimeBodyPart)1 MimeMessage (javax.mail.internet.MimeMessage)1