Examples of CMSEnvelopedData


Examples of org.bouncycastle.cms.CMSEnvelopedData

            for (int i = 0; i<recipients.size(); i++)
            {
                PdfObject recipient = (PdfObject)recipients.getArrayList().get(i);
                strings.remove(recipient);
               
                CMSEnvelopedData data = null;
                try {
                    data = new CMSEnvelopedData(recipient.getBytes());
               
                    Iterator recipientCertificatesIt =
                        data.getRecipientInfos().getRecipients().iterator();
           
                    while (recipientCertificatesIt.hasNext()) {
                        RecipientInformation recipientInfo =
                            (RecipientInformation)recipientCertificatesIt.next();
View Full Code Here

Examples of org.bouncycastle.cms.CMSEnvelopedData

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

            String extraInfo = "";
            for (; i < encryption.getRecipientsLength(); i++)
            {
                COSString recipientFieldString = encryption.getRecipientStringAt(i);
                byte[] recipientBytes = recipientFieldString.getBytes();
                CMSEnvelopedData data = new CMSEnvelopedData(recipientBytes);
                Iterator<?> recipCertificatesIt = data.getRecipientInfos().getRecipients().iterator();
                int j = 0;
                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

 
            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

        resp = s.getEncoded();
      }
      if ((serviceReq.getMode() & CmsCAServiceRequest.MODE_ENCRYPT) != 0) {
        CMSEnvelopedDataGenerator edGen = new CMSEnvelopedDataGenerator();
        edGen.addKeyTransRecipient(getCMSCertificate());
        CMSEnvelopedData ed = edGen.generate(new CMSProcessableByteArray(resp),CMSEnvelopedDataGenerator.DES_EDE3_CBC,"BC");
        resp = ed.getEncoded();
      }
      if ((serviceReq.getMode() & CmsCAServiceRequest.MODE_DECRYPT) != 0) {
        CMSEnvelopedData ed = new CMSEnvelopedData(resp);
        RecipientInformationStore  recipients = ed.getRecipientInfos();
        RecipientId id = new RecipientId();
        id.setIssuer(getCMSCertificate().getIssuerX500Principal());
        id.setSerialNumber(getCMSCertificate().getSerialNumber());
        RecipientInformation recipient = recipients.get(id);
        if (recipient != null) {
View Full Code Here

Examples of org.bouncycastle.cms.CMSEnvelopedData

            error = 6;
            log.error(errorText);
            return;
        }

        CMSEnvelopedData ed = new CMSEnvelopedData(envEncData);
        RecipientInformationStore recipients = ed.getRecipientInfos();
        Collection c = recipients.getRecipients();
        Iterator it = c.iterator();
        byte[] decBytes = null;

        while (it.hasNext()) {
View Full Code Here

Examples of org.bouncycastle.cms.CMSEnvelopedData

                        throw new IOException("Can not decode recipients self signed certificate!");
                    }
                } else {
                    edGen.addKeyTransRecipient((X509Certificate) cert);
                }
                CMSEnvelopedData ed = edGen.generate(new CMSProcessableByteArray(s.getEncoded()),
                        SMIMECapability.dES_CBC.getId(), "BC");

                log.debug("Enveloped data is " + ed.getEncoded().length + " bytes long");
                msg = new CMSProcessableByteArray(ed.getEncoded());
            } else {
                // Create an empty message here
                //msg = new CMSProcessableByteArray("PrimeKey".getBytes());
                msg = new CMSProcessableByteArray(new byte[0]);
            }
View Full Code Here

Examples of org.bouncycastle.cms.CMSEnvelopedData

   */
  public static byte[] encryptData(X509Certificate encCert, byte[] data) throws IOException{

        CMSEnvelopedDataGenerator edGen = new CMSEnvelopedDataGenerator();                             
      
      CMSEnvelopedData ed;
    try {
      edGen.addKeyTransRecipient(encCert);
      ed = edGen.generate(
          new CMSProcessableByteArray(data),encAlg,provider);
    } catch (Exception e) {
            log.error("Error Encryotin Keys:: ", e);
            throw new IOException(e.getMessage());       
    }
       
   
    return ed.getEncoded();    
  }
View Full Code Here

Examples of org.bouncycastle.cms.CMSEnvelopedData

   * @return encrypted byte[] or null if decryption failed.
   */
  public static byte[] decryptData(PrivateKey decKey, byte[] encData) {
    byte[] retdata = null;
    try{
      CMSEnvelopedData ed = new CMSEnvelopedData(encData);          
     
      RecipientInformationStore  recipients = ed.getRecipientInfos();            
      Iterator    it =  recipients.getRecipients().iterator();
      RecipientInformation   recipient = (RecipientInformation) it.next();     
      retdata = recipient.getContent(decKey, provider);
    } catch(Exception e){
      log.error("Error decypting data : ", e);
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.