Examples of RecipientInformation


Examples of org.bouncycastle.cms.RecipientInformation

            try {
                SMIMEEnveloped env = new SMIMEEnveloped(message);
                Collection<RecipientInformation> recipients = env.getRecipientInfos().getRecipients();
                Iterator<RecipientInformation> iter = recipients.iterator();
                while (iter.hasNext()) {
                    RecipientInformation info = iter.next();
                    RecipientId id = info.getRID();
                    if (id.match(keyHolder.getCertificate())) {
                        try {
                            MimeBodyPart part = SMIMEUtil.toMimeBodyPart(info.getContent(keyHolder.getPrivateKey(), "BC"));
                            // strippedMessage contains the decrypted message.
                            strippedMessage = part;
                            log("Encrypted message decrypted");
                        } catch (Exception e) {
                            throw new MessagingException("Error during the decryption of the message", e); }
View Full Code Here

Examples of org.bouncycastle.cms.RecipientInformation

                        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);
                    }
View Full Code Here

Examples of org.bouncycastle.cms.RecipientInformation

        if (message.isMimeType("application/x-pkcs7-mime") || message.isMimeType("application/pkcs7-mime")) {
            try {
                SMIMEEnveloped env = new SMIMEEnveloped(message);
                Collection recipients = env.getRecipientInfos().getRecipients();
                for (Iterator iter = recipients.iterator();iter.hasNext();) {
                    RecipientInformation info = (RecipientInformation) iter.next();
                    RecipientId id = info.getRID();
                    if (id.match(keyHolder.getCertificate())) {
                        try {
                            MimeBodyPart part = SMIMEUtil.toMimeBodyPart(info.getContent(keyHolder.getPrivateKey(), "BC"));
                            // strippedMessage contains the decrypted message.
                            strippedMessage = part;
                            log("Encrypted message decrypted");
                        } catch (Exception e) {
                            throw new MessagingException("Error during the decryption of the message", e); }
View Full Code Here

Examples of org.bouncycastle.cms.RecipientInformation

                    data = new CMSEnvelopedData(recipient.getBytes());

                    Iterator<RecipientInformation> recipientCertificatesIt = data.getRecipientInfos().getRecipients().iterator();

                    while (recipientCertificatesIt.hasNext()) {
                        RecipientInformation recipientInfo = recipientCertificatesIt.next();

                        if (recipientInfo.getRID().match(certificate) && !foundRecipient) {
                         envelopedData = recipientInfo.getContent(certificateKey, certificateKeyProvider);
                         foundRecipient = true;
                        }
                    }
                }
                catch (Exception f) {
View Full Code Here

Examples of org.bouncycastle.cms.RecipientInformation

                byte[] recipientBytes = recipientFieldString.getBytes();
                CMSEnvelopedData data = new CMSEnvelopedData(recipientBytes);
                Iterator recipCertificatesIt = data.getRecipientInfos().getRecipients().iterator();
                while(recipCertificatesIt.hasNext())
                {
                    RecipientInformation ri =
                        (RecipientInformation)recipCertificatesIt.next();
                    // Impl: if a matching certificate was previously found it is an error,
                    // here we just don't care about it
                    if(ri.getRID().match(material.getCertificate()) && !foundRecipient)
                    {
                        foundRecipient = true;
                        envelopedData = ri.getContent(material.getPrivateKey(), "BC");
                        break;
                    }
                }
                recipientFieldsBytes[i] = recipientBytes;
                recipientFieldsLength += recipientBytes.length;
View Full Code Here

Examples of org.bouncycastle.cms.RecipientInformation

                byte[] recipientBytes = recipientFieldString.getBytes();
                CMSEnvelopedData data = new CMSEnvelopedData(recipientBytes);
                Iterator recipCertificatesIt = data.getRecipientInfos().getRecipients().iterator();
                while(recipCertificatesIt.hasNext())
                {
                    RecipientInformation ri =
                        (RecipientInformation)recipCertificatesIt.next();
                    // Impl: if a matching certificate was previously found it is an error,
                    // here we just don't care about it
                    if(ri.getRID().match(material.getCertificate()) && !foundRecipient)
                    {
                        foundRecipient = true;
                        envelopedData = ri.getContent(material.getPrivateKey(), "BC");
                        break;
                    }
                }
                recipientFieldsBytes[i] = recipientBytes;
                recipientFieldsLength += recipientBytes.length;
View Full Code Here

Examples of org.bouncycastle.cms.RecipientInformation

                    data = new CMSEnvelopedData(recipient.getBytes());

                    Iterator recipientCertificatesIt = data.getRecipientInfos().getRecipients().iterator();

                    while (recipientCertificatesIt.hasNext()) {
                        RecipientInformation recipientInfo = (RecipientInformation)recipientCertificatesIt.next();

                        if (recipientInfo.getRID().match(certificate) && !foundRecipient) {
                         envelopedData = recipientInfo.getContent(certificateKey, certificateKeyProvider);
                         foundRecipient = true;
                        }
                    }
                }
                catch (Exception f) {
View Full Code Here

Examples of org.bouncycastle.cms.RecipientInformation

                Object[] recipientList = recipientEnvelope.getRecipientInfos().getRecipients().toArray();
                int listCount = recipientList.length;

                for (int ii = 0; ii < listCount; ii++) {
                    RecipientInformation recipientInfo = (RecipientInformation) recipientList[ii];

                    if (recipientInfo.getRID().match(certificate)) {
                        envelopedData = recipientInfo.getContent(key, provider);
                        ii = listCount;
                    }
                }
            } catch (Exception ee) {
                ee.printStackTrace();
View Full Code Here

Examples of org.bouncycastle.cms.RecipientInformation

                    data = new CMSEnvelopedData(recipient.getBytes());

                    Iterator recipientCertificatesIt = data.getRecipientInfos().getRecipients().iterator();

                    while (recipientCertificatesIt.hasNext()) {
                        RecipientInformation recipientInfo = (RecipientInformation)recipientCertificatesIt.next();

                        if (recipientInfo.getRID().match(certificate) && !foundRecipient) {
                         envelopedData = recipientInfo.getContent(certificateKey, certificateKeyProvider);
                         foundRecipient = true;
                        }
                    }
                }
                catch (Exception f) {
View Full Code Here

Examples of org.bouncycastle.cms.RecipientInformation

               
                    Iterator recipientCertificatesIt =
                        data.getRecipientInfos().getRecipients().iterator();
           
                    while (recipientCertificatesIt.hasNext()) {
                        RecipientInformation recipientInfo =
                            (RecipientInformation)recipientCertificatesIt.next();

                        if (recipientInfo.getRID().match(certificate) && !foundRecipient) {
   
                         envelopedData = recipientInfo.getContent(certificateKey, certificateKeyProvider);
                         foundRecipient = true;                        
                        }
                    }                       
                } catch (Exception f) {
                    throw new ExceptionConverter(f);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.