Package org.bouncycastle.cert

Examples of org.bouncycastle.cert.X509CertificateHolder


      AsymmetricKeyParameter caPrivateKeyParameters = PrivateKeyFactory.createKey(signerPrivateKey.getEncoded());
      ContentSigner contentSigner = new BcRSAContentSignerBuilder(sigAlgId, digestAlgId)
          .build(caPrivateKeyParameters);

      X509CertificateHolder certificateHolder = certificateBuilder.build(contentSigner);
      Certificate certificate = certificateHolder.toASN1Structure();

      return certificate;
    } catch (OperatorCreationException e) {
      throw new OpsException("Error signing certificate", e);
    } catch (IOException e) {
View Full Code Here


                {
                    RecipientInformation ri = (RecipientInformation) recipCertificatesIt.next();
                    // Impl: if a matching certificate was previously found it is an error,
                    // here we just don't care about it
                    X509Certificate certificate = material.getCertificate();
                    X509CertificateHolder materialCert = null;
                    if (null != certificate)
                    {
                        materialCert = new X509CertificateHolder(certificate.getEncoded());
                    }
                    RecipientId rid = ri.getRID();
                    if (rid.match(materialCert) && !foundRecipient)
                    {
                        foundRecipient = true;
                        PrivateKey privateKey = (PrivateKey) material.getPrivateKey();
                        envelopedData = ri.getContent(new JceKeyTransEnvelopedRecipient(privateKey).setProvider("BC"));
                        break;
                    }
                    j++;
                    if ((verbose || LOG.isDebugEnabled()) && certificate != null)
                    {
                        extraInfo += "\n" + j + ": ";
                        if (rid instanceof KeyTransRecipientId)
                        {
                            KeyTransRecipientId ktRid = (KeyTransRecipientId) rid;
                            BigInteger ridSerialNumber = ktRid.getSerialNumber();
                            if (ridSerialNumber != null)
                            {
                                String certSerial = "unknown";
                                BigInteger certSerialNumber = certificate.getSerialNumber();
                                if (certSerialNumber != null)
                                {
                                    certSerial = certSerialNumber.toString(16);
                                }
                                extraInfo += "serial-#: rid " + ridSerialNumber.toString(16)
                                        + " vs. cert " + certSerial + " issuer: rid \'"
                                        + ktRid.getIssuer() + "\' vs. cert \'"
                                        + (materialCert == null ? "null" : materialCert.getIssuer()) + "\' ";
                            }
                        }
                    }
                }
                recipientFieldsBytes[i] = recipientBytes;
View Full Code Here

            RSAKeyParameters keyParams = new RSAKeyParameters(true, privateRSAKey.getModulus(), privateRSAKey.getPrivateExponent());
            ContentSigner sigGen = new BcRSAContentSignerBuilder(sigAlgId, digAlgId).build(keyParams);
            CMSSignedDataGenerator gen = new CMSSignedDataGenerator();
            gen.addSignerInfoGenerator(
                    new SignerInfoGeneratorBuilder(new BcDigestCalculatorProvider())
                        .build(sigGen, new X509CertificateHolder(certificate)));
            CMSProcessableInputStream processable = new CMSProcessableInputStream(content);
            CMSSignedData signedData = gen.generate(processable, false);
            return signedData.getEncoded();
        }
        catch (CertificateEncodingException e)
View Full Code Here

            RSAKeyParameters keyParams = new RSAKeyParameters(true, privateRSAKey.getModulus(), privateRSAKey.getPrivateExponent());
            ContentSigner sigGen = new BcRSAContentSignerBuilder(sigAlgId, digAlgId).build(keyParams);

            gen.addSignerInfoGenerator(
                    new SignerInfoGeneratorBuilder(new BcDigestCalculatorProvider())
                        .build(sigGen, new X509CertificateHolder(certificate)));
            CMSProcessableInputStream processable = new CMSProcessableInputStream(content);
            CMSSignedData signedData = gen.generate(processable, false);
            if (tsaClient != null)
            {
                signedData = signTimeStamps(signedData);
View Full Code Here

      if (!signCert.getSerialNumber().equals(resp[i].getCertID().getSerialNumber())) {
        continue;
      }
      // check if the issuer matches
      try {
        if (!resp[i].getCertID().matchesIssuer(new X509CertificateHolder(issuerCert.getEncoded()), new BcDigestCalculatorProvider())) {
          LOGGER.info("OCSP: Issuers doesn't match.");
          continue;
        }
      } catch (OCSPException e) {
        continue;
View Full Code Here

    certGen.addExtension(Extension.basicConstraints, false, new BasicConstraints(isCertAuthority));
    certGen.addExtension(Extension.authorityKeyIdentifier, false, extensionUtils.createAuthorityKeyIdentifier(signerPublicKey));
    if (isCertAuthority) {
      certGen.addExtension(Extension.keyUsage, true, new KeyUsage(KeyUsage.keyCertSign));
    }
    X509CertificateHolder cert = certGen.build(new JcaContentSignerBuilder(signingAlgorithm).build(signerPrivateKey));
    return new X509CertificateObject(cert.toASN1Structure());
  }
View Full Code Here

    CMSAttributeTableGenerator attrGen = new DefaultSignedAttributeTableGenerator(at);
    SignerInfoGeneratorBuilder genBuild =
       new SignerInfoGeneratorBuilder(new BcDigestCalculatorProvider());
    genBuild.setSignedAttributeGenerator(attrGen);
    SignerInfoGenerator sifGen =
       genBuild.build(sigGen, new X509CertificateHolder(userCertificate.getEncoded()));

    gen.addSignerInfoGenerator(sifGen);

    /**
     * Popolo la "catena di certificazione" (certificate chain)
View Full Code Here

    {
      SignerInformation signer = (SignerInformation) it.next();
      Collection certCollection = certStore.getMatches(signer.getSID());

      Iterator certIt = certCollection.iterator();
      X509CertificateHolder cert = (X509CertificateHolder) certIt.next();

      if(signer.verify(new JcaSimpleSignerInfoVerifierBuilder().setProvider("BC").build(cert)))
      {
        verified = true;
      }
View Full Code Here

  try {
      signer = new JcaContentSignerBuilder("SHA1withRSA").build(priKey);
  } catch (OperatorCreationException e) {
      throw new Exception(e);
  }
  X509CertificateHolder holder = builder.build(signer);
  return new JcaX509CertificateConverter().getCertificate(holder);
    }
View Full Code Here

    Date notBefore = cal.getTime();
    cal.add(Calendar.YEAR, 2);
    Date notAfter = cal.getTime();
    JcaX509v1CertificateBuilder builder = new JcaX509v1CertificateBuilder(
        name, BigInteger.ONE, notBefore, notAfter, name, pubKey);
    X509CertificateHolder holder = builder.build(signer);
    return new JcaX509CertificateConverter().getCertificate(holder);
  }
View Full Code Here

TOP

Related Classes of org.bouncycastle.cert.X509CertificateHolder

Copyright © 2018 www.massapicom. 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.