data = new CMSEnvelopedData(recipient.getBytes());
Iterator<RecipientInformation> recipientCertificatesIt = data.getRecipientInfos().getRecipients().iterator();
while (recipientCertificatesIt.hasNext()) {
RecipientInformation recipientInfo = recipientCertificatesIt.next();
if (recipientInfo.getRID().match(certHolder) && !foundRecipient) {
envelopedData = PdfEncryptor.getContent(recipientInfo, (PrivateKey) certificateKey, certificateKeyProvider);
foundRecipient = true;
}
}
} catch (Exception f) {
throw new ExceptionConverter(f);
}
}
} else {
for (int i = 0; i < recipients.size(); i++) {
PdfObject recipient = recipients.getPdfObject(i);
strings.remove(recipient);
CMSEnvelopedData data = null;
try {
data = new CMSEnvelopedData(recipient.getBytes());
RecipientInformation recipientInfo =
data.getRecipientInfos().get(externalDecryptionProcess.getCmsRecipientId());
if (recipientInfo != null) {
envelopedData =
recipientInfo.getContent(externalDecryptionProcess.getCmsRecipient());
foundRecipient = true;
}
} catch (Exception f) {
throw new ExceptionConverter(f);
}