Example usage for org.bouncycastle.cms.jcajce JceKeyTransRecipient setProvider

List of usage examples for org.bouncycastle.cms.jcajce JceKeyTransRecipient setProvider

Introduction

In this page you can find the example usage for org.bouncycastle.cms.jcajce JceKeyTransRecipient setProvider.

Prototype

public JceKeyTransRecipient setProvider(String providerName) 

Source Link

Document

Set the provider to use for key recovery and content processing.

Usage

From source file:net.markenwerk.utils.mail.smime.SmimeUtil.java

License:Open Source License

private static byte[] decryptContent(SMIMEEnveloped smimeEnveloped, SmimeKey smimeKey)
        throws MessagingException, CMSException {
    X509Certificate certificate = smimeKey.getCertificate();
    PrivateKey privateKey = smimeKey.getPrivateKey();

    RecipientInformationStore recipients = smimeEnveloped.getRecipientInfos();
    RecipientInformation recipient = recipients.get(new JceKeyTransRecipientId(certificate));

    if (null == recipient) {
        throw new MessagingException("no recipient");
    }//from  www  .j ava  2 s  .c  om

    JceKeyTransRecipient transportRecipient = new JceKeyTransEnvelopedRecipient(privateKey);
    transportRecipient.setProvider(BouncyCastleProvider.PROVIDER_NAME);
    return recipient.getContent(transportRecipient);
}