Examples of addSigner()


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

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

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

    List<Certificate> certList = Arrays.asList(cert);

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

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

      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");
      } else {
          s = gen.generate(msg, "BC");       
      }
      return s.getEncoded();
View Full Code Here

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

      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();
      }
      if ((serviceReq.getMode() & CmsCAServiceRequest.MODE_ENCRYPT) != 0) {
View Full Code Here

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

                attributes.put(attr.getAttrType(), attr);
            }

            // Add our signer info and sign the message
            log.debug("Signing SCEP message with cert: "+CertTools.getSubjectDN(signCert));
            gen1.addSigner(signKey, (X509Certificate)signCert, digestAlg, new AttributeTable(attributes), null);
            signedData = gen1.generate(msg, true, provider);
            responseMessage = signedData.getEncoded();
            if (responseMessage != null) {
                ret = true;
            }
View Full Code Here

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

          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.addSigner()

        // 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.addSigner()

            if (getCAToken().getPrivateKey(SecConst.CAKEYPURPOSE_CERTSIGN) == null) {
              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)) {
View Full Code Here

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

        // 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.addSigner()

      }
      MultivaluedMapImpl<String, Object> bodyHeaders = new MultivaluedMapImpl<String, Object>();
      bodyHeaders.add("Content-Type",  out.getMediaType().toString());
      writer.writeTo(out.getEntity(), out.getType(), out.getGenericType(), null, out.getMediaType(), bodyHeaders, bodyOs);
      CMSSignedDataGenerator signGen = new CMSSignedDataGenerator();
      signGen.addSigner(out.getPrivateKey(), (X509Certificate)out.getCertificate(), CMSSignedDataGenerator.DIGEST_SHA1);
      //signGen.addCertificatesAndCRLs(certs);
      CMSProcessable content = new CMSProcessableByteArray(bodyOs.toByteArray());

      CMSSignedData signedData = signGen.generate(content, true, "BC");
      return signedData.getEncoded();
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.