Examples of CMSEnvelopedData


Examples of org.bouncycastle.cms.CMSEnvelopedData

   
    private CMSEnvelopedData envelope(CMSProcessable envThis) throws NoSuchAlgorithmException, NoSuchProviderException, CMSException {
        CMSEnvelopedDataGenerator edGen = new CMSEnvelopedDataGenerator();
        // Envelope the CMS message
        edGen.addKeyTransRecipient(cacert);
        CMSEnvelopedData ed = edGen.generate(envThis, SMIMECapability.dES_CBC.getId(), "BC");
        return ed;
    }
View Full Code Here

Examples of org.bouncycastle.cms.CMSEnvelopedData

    private byte[] wrap(byte[] envBytes, String messageType, String transactionId) throws IOException, NoSuchAlgorithmException, NoSuchProviderException, CMSException, InvalidAlgorithmParameterException, CertStoreException {

        //
        // Create inner enveloped data
        //
        CMSEnvelopedData ed = envelope(new CMSProcessableByteArray(envBytes));
        log.debug("Enveloped data is " + ed.getEncoded().length + " bytes long");
        CMSProcessable msg = new CMSProcessableByteArray(ed.getEncoded());
        //
        // Create the outer signed data
        //
        CMSSignedData s = sign(msg, messageType, transactionId);
       
View Full Code Here

Examples of org.bouncycastle.cms.CMSEnvelopedData

 
            for(int i=0; i<encDictionary.getRecipientsLength(); i++)
            {
                COSString recipientFieldString = encDictionary.getRecipientStringAt(i);
                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,
View Full Code Here

Examples of org.bouncycastle.cms.CMSEnvelopedData

            }
            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());

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

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

                        if (recipientInfo.getRID().match(certificate) && !foundRecipient) {
View Full Code Here

Examples of org.bouncycastle.cms.CMSEnvelopedData

        hasMessageData = false;
      }
    }
    if (hasMessageData) {
      try {
        CMSEnvelopedData ed = encodeMessage(message);
        signable = new CMSProcessableByteArray(ed.getEncoded());
      } catch (IOException e) {
        throw new MessageEncodingException(e);
      }
    } else {
      signable = new CMSAbsentContent();
View Full Code Here

Examples of org.bouncycastle.cms.CMSEnvelopedData

      failInfo);
      } else if (pkiStatus == PkiStatus.PENDING) {
    LOGGER.debug("Finished decoding pkiMessage");
    return new CertRep(transId, senderNonce, recipientNonce);
      } else {
    final CMSEnvelopedData ed = getEnvelopedData(signedContent
      .getContent());
    final byte[] envelopedContent = decoder.decode(ed);
    CMSSignedData messageData;
    try {
        messageData = new CMSSignedData(envelopedContent);
    } catch (CMSException e) {
        throw new MessageDecodingException(e);
    }
    LOGGER.debug("Finished decoding pkiMessage");
    return new CertRep(transId, senderNonce, recipientNonce,
      messageData);
      }
  } else {
      CMSEnvelopedData ed = getEnvelopedData(signedContent.getContent());
      byte[] decoded = decoder.decode(ed);
      if (messageType == MessageType.GET_CERT) {
    IssuerAndSerialNumber messageData = IssuerAndSerialNumber
      .getInstance(decoded);
    LOGGER.debug("Finished decoding pkiMessage");
View Full Code Here

Examples of org.bouncycastle.cms.CMSEnvelopedData

      throws MessageDecodingException {
  // We expect the byte array to be a sequence
  // ... and that sequence to be a ContentInfo (but might be the
  // EnvelopedData)
  try {
      return new CMSEnvelopedData((byte[]) bytes);
  } catch (CMSException e) {
      throw new MessageDecodingException(e);
  }
    }
View Full Code Here

Examples of org.bouncycastle.cms.CMSEnvelopedData

      encryptor = getEncryptor();
    } catch (CMSException e) {
      throw new MessageEncodingException(e);
    }
    try {
      CMSEnvelopedData pkcsPkiEnvelope = edGenerator.generate(
          envelopable, encryptor);

      LOGGER.debug("Finished encoding pkcsPkiEnvelope");
      return pkcsPkiEnvelope;
    } catch (CMSException e) {
View Full Code Here

Examples of org.bouncycastle.cms.CMSEnvelopedData

            }
            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());

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

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

                        if (recipientInfo.getRID().match(certificate) && !foundRecipient) {
View Full Code Here

Examples of org.bouncycastle.cms.CMSEnvelopedData

 
            for(int i=0; i<encDictionary.getRecipientsLength(); i++)
            {
                COSString recipientFieldString = encDictionary.getRecipientStringAt(i);
                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,
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.