Examples of RecipientInformation


Examples of org.bouncycastle.cms.RecipientInformation

            RecipientInformationStore recipients = ed.getRecipientInfos();
            Collection c = recipients.getRecipients();
            assertEquals(c.size(), 1);
            Iterator it = c.iterator();
            byte[] decBytes = null;
            RecipientInformation recipient = (RecipientInformation) it.next();
            decBytes = recipient.getContent(keys.getPrivate(), "BC");
            // This is yet another CMS signed data
            CMSSignedData sd = new CMSSignedData(decBytes);
            // Get certificates from the signed data
            CertStore certstore = sd.getCertificatesAndCRLs("Collection","BC");
            if (crlRep) {
View Full Code Here

Examples of org.bouncycastle.cms.RecipientInformation

    public static void decrypt(final InputStream is, OutputStream os, Key key, String providerName) throws Exception  {
        final InputStream bis = new BufferedInputStream(is, bufferSize);
        final OutputStream bos = new BufferedOutputStream(os, bufferSize);
        final Iterator  it = new CMSEnvelopedDataParser(bis).getRecipientInfos().getRecipients().iterator();
        if (it.hasNext()) {
            final RecipientInformation recipient = (RecipientInformation)it.next();
            final CMSTypedStream recData = recipient.getContentStream(key, providerName);
            final InputStream ris = recData.getContentStream();
            fromInToOut(ris, bos);
        }
        os.close();
    }
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

    public KeyPair decryptKeys(byte[] data) throws Exception {
      CMSEnvelopedData ed = new CMSEnvelopedData(data);          
          
    RecipientInformationStore  recipients = ed.getRecipientInfos();            
      Iterator it =  recipients.getRecipients().iterator();
      RecipientInformation   recipient = (RecipientInformation) it.next();
      ObjectInputStream ois = null;
      byte[] recdata = recipient.getContent(getCAToken().getPrivateKey(SecConst.CAKEYPURPOSE_KEYENCRYPT),getCAToken().getJCEProvider());
      ois = new ObjectInputStream(new ByteArrayInputStream(recdata));
                 
      return (KeyPair) ois.readObject()
    }
View Full Code Here

Examples of org.bouncycastle.cms.RecipientInformation

  public byte[] decryptData(byte[] data, int cAKeyPurpose) throws Exception {
      CMSEnvelopedData ed = new CMSEnvelopedData(data);
    RecipientInformationStore  recipients = ed.getRecipientInfos();            
      Iterator it =  recipients.getRecipients().iterator();
      RecipientInformation   recipient = (RecipientInformation) it.next();
      byte[] recdata = recipient.getContent(getCAToken().getPrivateKey(cAKeyPurpose),getCAToken().getProvider());     
                 
      return recdata; 
  }
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<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

    LOGGER.debug(
        "Decrypting pkcsPkiEnvelope using key belonging to [issuer={}; serial={}]",
        recipient.getIssuerDN(), recipient.getSerialNumber());
    final RecipientInformationStore recipientInfos = pkcsPkiEnvelope
        .getRecipientInfos();
    RecipientInformation info = recipientInfos
        .get(new JceKeyTransRecipientId(recipient));

    if (info == null) {
      throw new MessageDecodingException(
          "Missing expected key transfer recipient");
    }

    LOGGER.debug("pkcsPkiEnvelope encryption algorithm: {}", info
        .getKeyEncryptionAlgorithm().getAlgorithm());

    try {
      byte[] messageData = info.getContent(getKeyTransRecipient());
      LOGGER.debug("Finished decoding pkcsPkiEnvelope");
      return messageData;
    } catch (CMSException e) {
      throw new MessageDecodingException(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");
                    }
                }
                recipientFieldsBytes[i] = recipientBytes;
                recipientFieldsLength += recipientBytes.length;
            }
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.