Examples of addCertificatesAndCRLs()


Examples of org.bouncycastle.cms.CMSSignedDataGenerator.addCertificatesAndCRLs()

    {
      certStore = CertStore.getInstance("Collection",
          new CollectionCertStoreParameters(certList), provider);
      gen.addSigner(privKey, (X509Certificate) certList.get(0),
          CMSSignedGenerator.DIGEST_SHA256);
      gen.addCertificatesAndCRLs(certStore);
      CMSSignedData signedData = gen.generate(input, false, provider);
      return signedData.getEncoded();
    }
    catch (Exception e)
    {
View Full Code Here

Examples of org.bouncycastle.cms.CMSSignedDataGenerator.addCertificatesAndCRLs()

    CertStore certStore = null;
    try {
      certStore = CertStore.getInstance("Collection", new CollectionCertStoreParameters(certList), provider);
      gen.addSigner(privKey, (X509Certificate) certList.get(0), CMSSignedGenerator.DIGEST_SHA256);
      gen.addCertificatesAndCRLs(certStore);
      CMSSignedData signedData = gen.generate(input, false, provider);
      return signedData.getEncoded();
    } catch (Exception e) {
      // should be handled
      System.err.println("Error while creating pkcs7 signature.");
View Full Code Here

Examples of org.bouncycastle.cms.CMSSignedDataGenerator.addCertificatesAndCRLs()

    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;
      if ( (pk != null) && (cert != null) ) {
        gen.addSigner(pk, cert, CMSSignedDataGenerator.DIGEST_MD5);
          s = gen.generate(msg, true, "BC");
View Full Code Here

Examples of org.bouncycastle.cms.CMSSignedDataGenerator.addCertificatesAndCRLs()

    try {
      byte[] resp = serviceReq.getDoc();
      // 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();
      }
View Full Code Here

Examples of org.bouncycastle.cms.CMSSignedDataGenerator.addCertificatesAndCRLs()

                        new CollectionCertStoreParameters(certList), "BC");

                // Create the signed CMS message to be contained inside the envelope
                // this message does not contain any message, and no signerInfo
                CMSSignedDataGenerator gen = new CMSSignedDataGenerator();
                gen.addCertificatesAndCRLs(certs);
                CMSSignedData s = gen.generate(null, false, "BC");

                // Envelope the CMS message
                if (recipientKeyInfo != null) {
                    try {
View Full Code Here

Examples of org.bouncycastle.cms.CMSSignedDataGenerator.addCertificatesAndCRLs()

    try{
          ArrayList certList = new ArrayList();
          certList.add(signCert);
          CertStore certs = CertStore.getInstance("Collection", new CollectionCertStoreParameters(certList), provider);         
      CMSSignedDataGenerator    gen = new CMSSignedDataGenerator();
      gen.addCertificatesAndCRLs(certs);
      gen.addSigner(signKey, signCert, signAlg);       
      CMSSignedData           signedData = gen.generate(new CMSProcessableByteArray(data), true, provider);
      retdata = signedData.getEncoded();
    } catch(Exception e){
      log.error("Error signing data : ", e);
View Full Code Here

Examples of org.bouncycastle.cms.CMSSignedDataGenerator.addCertificatesAndCRLs()

        // Add our signer info and sign the message
        ArrayList certList = new ArrayList();
        certList.add(cert);
        CertStore certs = CertStore.getInstance("Collection", new CollectionCertStoreParameters(certList), "BC");
        gen1.addCertificatesAndCRLs(certs);
        gen1.addSigner(keys.getPrivate(), cert, digestOid,
                new AttributeTable(attributes), null);
        // The signed data to be enveloped
        CMSSignedData s = gen1.generate(signThis, true, "BC");
        return s;
View Full Code Here

Examples of org.bouncycastle.cms.CMSSignedDataGenerator.addCertificatesAndCRLs()

              String msg1 = "createPKCS7: Private key does not exist!";
              log.debug(msg1);
              throw new SignRequestSignatureException(msg1);
            }
            gen.addSigner(getCAToken().getPrivateKey(SecConst.CAKEYPURPOSE_CERTSIGN), (X509Certificate)getCACertificate(), CMSSignedGenerator.DIGEST_SHA1);
            gen.addCertificatesAndCRLs(certs);
            CMSSignedData s = null;
            CATokenContainer catoken = getCAToken();
            CATokenInfo tokeninfo = getCAInfo().getCATokenInfo();
            if (catoken != null && !(tokeninfo instanceof NullCATokenInfo)) {
              log.debug("createPKCS7: Provider="+catoken.getProvider()+" using algorithm "+getCAToken().getPrivateKey(SecConst.CAKEYPURPOSE_CERTSIGN).getAlgorithm());
View Full Code Here

Examples of org.bouncycastle.cms.CMSSignedDataGenerator.addCertificatesAndCRLs()

        // Add our signer info and sign the message
        ArrayList certList = new ArrayList();
        certList.add(cert);
        CertStore certs = CertStore.getInstance("Collection", new CollectionCertStoreParameters(certList), "BC");
        gen1.addCertificatesAndCRLs(certs);
        gen1.addSigner(keys.getPrivate(), cert, digestOid,
                new AttributeTable(attributes), null);
        // The signed data to be enveloped
        CMSSignedData s = gen1.generate(signThis, true, "BC");
        return s;
View Full Code Here

Examples of org.bouncycastle.cms.CMSSignedDataGenerator.addCertificatesAndCRLs()

        CMSSignedDataGenerator gen = new CMSSignedDataGenerator();

        gen.addSigner(keyPair.getPrivate(), keyCert, CMSSignedDataGenerator.DIGEST_SHA1);

        gen.addCertificatesAndCRLs(certsAndCrls);

        CMSSignedData s = gen.generate(msg, true, "SunRsaSign");

        ByteArrayInputStream bIn = new ByteArrayInputStream(s.getEncoded());
        ASN1InputStream aIn = new ASN1InputStream(bIn);
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.