List of usage examples for org.bouncycastle.cms CMSEnvelopedData getRecipientInfos
public RecipientInformationStore getRecipientInfos()
From source file:org.xipki.pki.scep.message.EnvelopedDataDecryptor.java
License:Open Source License
public byte[] decrypt(final CMSEnvelopedData envData) throws MessageDecodingException { ParamUtil.requireNonNull("envData", envData); final RecipientInformationStore recipientInfos = envData.getRecipientInfos(); RecipientInformation recipientInfo = null; EnvelopedDataDecryptorInstance decryptor = null; for (EnvelopedDataDecryptorInstance m : decryptors) { recipientInfo = recipientInfos.get(m.getRecipientId()); if (recipientInfo != null) { decryptor = m;//from w ww . ja v a 2 s .co m break; } } if (recipientInfo == null || decryptor == null) { throw new MessageDecodingException("missing expected key transfer recipient"); } try { return recipientInfo.getContent(decryptor.getRecipient()); } catch (CMSException ex) { throw new MessageDecodingException("could not decrypt the envelopedData"); } }