Package org.bouncycastle.x509

Examples of org.bouncycastle.x509.X509V1CertificateGenerator.generate()


                PolicyInformation pi = new PolicyInformation(new DERObjectIdentifier(policyId));
                DERSequence seq = new DERSequence(pi);
                certgen.addExtension(X509Extensions.CertificatePolicies.getId(), false, seq);
        }

        X509Certificate selfcert = certgen.generate(privKey, provider);

        return selfcert;
    } //genselfCertForPurpose

    /**
 
View Full Code Here


              certGen.setNotBefore(time);
              certGen.setNotAfter(new Date (time.getTime() + 1000L * 60 * 60 * 24 * 365 * 10))// 10 years of life
              certGen.setSubjectDN(dnName);                       // note: same as issuer
              certGen.setPublicKey(key_pair.getPublic());
              certGen.setSignatureAlgorithm("SHA1withRSA");
              final X509Certificate certificate = certGen.generate(key_pair.getPrivate(), "BC");
              final String fingerprint = CertTools.getFingerprintAsString(certificate);
              // We add all certificates that does not have a user already to "missing_user_name"
              final UserDataVO missingUserDataVO = ejb.getUserAdminSession().findUser(getAdmin(), missing_user_name);
              if (missingUserDataVO == null) {
                // Add the user and change status to REVOKED
View Full Code Here

        
         X509Certificate cert;
         if (log.isTraceEnabled()) {
           log.trace(">certgen.generate");
         }
         cert = certgen.generate(caPrivateKey, provider);
         if (log.isTraceEnabled()) {
           log.trace("<certgen.generate");
         }
       
        // Verify before returning
View Full Code Here

    {
      certGen.addExtension(X509Extensions.SubjectKeyIdentifier, false,
              new SubjectKeyIdentifierStructure(keypair.getPublic()));
      certGen.addExtension(X509Extensions.BasicConstraints, false,
              new BasicConstraints(true));
      final X509Certificate cert = certGen.generate(keypair.getPrivate());
      return cert;
    }
    catch (final Exception e)
    {
      throw new IllegalStateException(
View Full Code Here

    v3CertGen.addExtension(X509Extensions.BasicConstraints, true,
            new BasicConstraints(0));

    // X509Certificate cert = v3CertGen.generateX509Certificate(caPrivKey);
    final X509Certificate cert = v3CertGen.generate(caPriKey, "BC");
    cert.checkValidity(new Date());
    cert.verify(caCert.getPublicKey());

    // cert.verify(caCert.getPublicKey());
    // cert.getEncoded();
View Full Code Here

/*
    Creates and sign this certificate with the private key corresponding
    to the public key of the FOAF+SSL DN
*/
    cert = certGenerator.generate(service.privateKey);

/*
    Checks that this certificate has indeed been correctly signed.
*/
    cert.verify(service.certificate.getPublicKey());
 
View Full Code Here

//        false,
//        new CRLDistPoint(new DistributionPoint[] {}));
   
   
   
    X509Certificate cert = v3CertGen.generate(caPrivateKey, "BC");
   
    return cert;
  }
 
  /**
 
View Full Code Here

    v3CertGen.addExtension(
        X509Extensions.AuthorityKeyIdentifier,
        false,
        new AuthorityKeyIdentifierStructure(caCert.getPublicKey()));
   
    X509Certificate cert = v3CertGen.generate(caPrivateKey, "BC");
   
    // For debugging purposes.
    //cert.checkValidity(new Date());
    //cert.verify(caCert.getPublicKey());
   
View Full Code Here

    v3CertGen.addExtension(
        X509Extensions.ExtendedKeyUsage,
        false,
        new DERSequence(typicalCAExtendedKeyUsages));
   
    X509Certificate cert = v3CertGen.generate(keyPair.getPrivate(), "BC");
   
    cert.checkValidity(new Date());
   
    cert.verify(keyPair.getPublic());
   
View Full Code Here

            v3CertGen.setSubjectDN(dn);
            v3CertGen.setPublicKey(keyPair.getPublic());
            v3CertGen.setSignatureAlgorithm("MD5withRSA");
            final SecureRandom sr = new SecureRandom();
            v3CertGen.setSerialNumber(BigInteger.ONE);
            X509Certificate certificate = v3CertGen.generate(keyPair.getPrivate(), sr);

            //save keystore to a new file
            final KeyStore keystore = KeyStore.getInstance("JKS");
            keystore.load(null, null);
            keystore.setKeyEntry(name, keyPair.getPrivate(), KEYSTORE_PASSWORD.toCharArray(),
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.