Examples of CMSProcessable


Examples of org.bouncycastle.cms.CMSProcessable

      return ret;
    }
   
    private byte[] createPKCS7(Certificate[] chain, PrivateKey pk, X509Certificate cert) throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchProviderException, CertStoreException, CMSException, IOException {
      Collection<Certificate> certList = Arrays.asList(chain);
      CMSProcessable msg = new CMSProcessableByteArray(new byte[0]);
      CertStore certs = CertStore.getInstance("Collection", new CollectionCertStoreParameters(certList), "BC");
      CMSSignedDataGenerator gen = new CMSSignedDataGenerator();
      gen.addCertificatesAndCRLs(certs);
      // it is possible to sign the pkcs7, but it's not currently used
      CMSSignedData s = null;
View Full Code Here

Examples of org.bouncycastle.cms.CMSProcessable

      // Add our signer info and sign the message
      if ((serviceReq.getMode() & CmsCAServiceRequest.MODE_SIGN) != 0) {
        final CertStore certs = CertStore.getInstance("Collection", new CollectionCertStoreParameters(certificatechain), "BC");
        gen1.addCertificatesAndCRLs(certs);
        gen1.addSigner(privKey, signerCert, CMSSignedGenerator.DIGEST_SHA1);
        final CMSProcessable msg = new CMSProcessableByteArray(resp);
        final CMSSignedData s = gen1.generate(msg, true, "BC");
        resp = s.getEncoded();
      }
      if ((serviceReq.getMode() & CmsCAServiceRequest.MODE_ENCRYPT) != 0) {
        CMSEnvelopedDataGenerator edGen = new CMSEnvelopedDataGenerator();
View Full Code Here

Examples of org.bouncycastle.cms.CMSProcessable

                } else {
                    log.debug("Creating a STATUS_PENDING message.");
                }              
            }

            CMSProcessable msg;
            // Create encrypted response if this is success and NOT a CRL response message
            if (status.equals(ResponseStatus.SUCCESS)) {

                CMSEnvelopedDataGenerator edGen = new CMSEnvelopedDataGenerator();
                // Add the issued certificate to the signed portion of the CMS (as signer, degenerate case)
View Full Code Here

Examples of org.bouncycastle.cms.CMSProcessable

        }
        CertStore store = csd.getCertificatesAndCRLs("Collection", "BC");
        Collection certs = store.getCertificates(null);
        assertEquals(2, certs.size());

        CMSProcessable cp = csd.getSignedContent();
        Object o = cp.getContent();
        byte[] ob = (byte[]) o;
        assertEquals(new String(doc), new String(ob));
    }
View Full Code Here

Examples of org.bouncycastle.cms.CMSProcessable

              if ( responsestatus.equals(ResponseStatus.PENDING.getValue()) || !messageType.equals("3") ) {
                return true;
              }
              // First we extract the encrypted data from the CMS enveloped data contained
              // within the CMS signed data
              final CMSProcessable sp = s.getSignedContent();
              final byte content[] = (byte[])sp.getContent();
              final CMSEnvelopedData ed = new CMSEnvelopedData(content);
              final RecipientInformationStore recipients = ed.getRecipientInfos();
              final RecipientInformation recipient;
              {
                final Collection<?> c = recipients.getRecipients();
View Full Code Here

Examples of org.bouncycastle.cms.CMSProcessable

        //
        if (messageType.equals("3")) {
            // First we extract the encrypted data from the CMS enveloped data
            // contained
            // within the CMS signed data
            final CMSProcessable sp = s.getSignedContent();
            final byte[] content = (byte[]) sp.getContent();
            final CMSEnvelopedData ed = new CMSEnvelopedData(content);
            final RecipientInformationStore recipients = ed.getRecipientInfos();
            CertStore certstore;
            {
                Collection<RecipientInformation> c = recipients.getRecipients();
View Full Code Here

Examples of org.bouncycastle.cms.CMSProcessable

        // Check different message types
        //       
        if (!responsestatus.equals(ResponseStatus.PENDING.getValue()) && messageType.equals("3")) {
            // First we extract the encrypted data from the CMS enveloped data contained
            // within the CMS signed data
            CMSProcessable sp = s.getSignedContent();
            byte[] content = (byte[])sp.getContent();
            CMSEnvelopedData ed = new CMSEnvelopedData(content);
            RecipientInformationStore recipients = ed.getRecipientInfos();
            Collection c = recipients.getRecipients();
            assertEquals(c.size(), 1);
            Iterator it = c.iterator();
View Full Code Here

Examples of org.bouncycastle.cms.CMSProcessable

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

Examples of org.bouncycastle.cms.CMSProcessable

        }
        if (includeChain) {
            certList.addAll(chain);
        }
        try {
            CMSProcessable msg = new CMSProcessableByteArray("EJBCA".getBytes());
            CertStore certs = CertStore.getInstance("Collection", new CollectionCertStoreParameters(certList), "BC");
            CMSSignedDataGenerator gen = new CMSSignedDataGenerator();
            if (getCAToken().getPrivateKey(SecConst.CAKEYPURPOSE_CERTSIGN) == null) {
              String msg1 = "createPKCS7: Private key does not exist!";
              log.debug(msg1);
View Full Code Here

Examples of org.bouncycastle.cms.CMSProcessable

        //
        // 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
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.