Package com.drighetto.essai.bouncycastle.certificate

Examples of com.drighetto.essai.bouncycastle.certificate.RootCertificateVO


    System.out.println("---[Bouncy Castle Sample]---");
    try {
      System.out.println("[Certificate Sample]");
      // Create the ROOT certificate
      System.out.print("Generate a ROOT certificate...");
      RootCertificateVO rootCertificateVO = certGenerator
          .createRootCertificate();
      X509Certificate rootCertificate = rootCertificateVO
          .getRootCertificate();
      System.out.println("OK");
      System.out.println("Certificate content :");
      System.out.println(rootCertificate.toString());
      System.out.print("Certificate is currently valid : ");
View Full Code Here


        Security.addProvider(new BouncyCastleProvider());
      }

      /* Generate a root and a normal certificate for this sample */
      CertificateGenerator certificateGenerator = new CertificateGenerator();
      RootCertificateVO rootCertificateInfo = certificateGenerator.createRootCertificate();
      CertificateVO certificateContainer = certificateGenerator.createNormalizeCertificate2(rootCertificateInfo);

      /*
       * Create a keystore of type "JKS" using the "SUN" security provider
       * because BouncyCastle do not support this type of keystore and
       * then store the normal certificate private key into it
       */
      System.out.printf("Create the keystore to the temporary file '%s'\n", keystoreTemporaryStorageFile.getAbsolutePath());
      // --Initialize the keystore in order to set the keystore access
      // password
      KeyStore keyStoreForWrite = KeyStore.getInstance("JKS", Security.getProvider("SUN"));
      keyStoreForWrite.load(null, KEYSTORE_ACCESS_PASSWORD.toCharArray());
      // --Create a certificates array representing the normal certificate
      // identification/validation chain
      Certificate[] validationChain = { rootCertificateInfo.getRootCertificate(), certificateContainer.getCertificate() };
      // --Save the normal certificate private key in the keystore
      System.out.printf("Save the normal certificate private key below into it :\n%s\n", certificateContainer.getCertificatePrivateKey());
      keyStoreForWrite.setKeyEntry(NORMAL_CERTIFICATE_PRIVATEKEY_IDENTIFICATION_ALIAS, certificateContainer.getCertificatePrivateKey(), NORMAL_CERTIFICATE_PRIVATEKEY_ACCESS_PASSWORD.toCharArray(), validationChain);
      // --Save the keystore to a temporary file used for this sample
      keyStoreForWrite.store(keystoreTemporaryStorageFileOS, KEYSTORE_ACCESS_PASSWORD.toCharArray());
View Full Code Here

TOP

Related Classes of com.drighetto.essai.bouncycastle.certificate.RootCertificateVO

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.