Package java.security

Examples of java.security.KeyStore.load()


            final KeyStore ks = KeyStore.getInstance("JKS");
           
            // loading keystore data from file
            if (this.log.isFine()) this.log.logFine("Loading keystore file " + keyStoreFileName);
            final FileInputStream stream = new FileInputStream(keyStoreFileName);           
            ks.load(stream, keyStorePwd.toCharArray());
            stream.close();
           
            // creating a keystore factory
            if (this.log.isFine()) this.log.logFine("Initializing key manager factory ...");
            final KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
View Full Code Here


            System.err.println("Loading java keystore from file '" + jksFile + "'");
            jksFileIn = new FileInputStream(jksFile);
        } else{
            System.err.println("Creating new java keystore '" + jksFile + "'");
        }
        jks.load(jksFileIn,(jksPassword!=null)?jksPassword.toCharArray():null);
        if (jksFileIn != null) jksFileIn.close();
        
        final Enumeration<String> pkcs12Aliases = aliases();
        while (pkcs12Aliases.hasMoreElements()) {
           final String strAlias = pkcs12Aliases.nextElement();
View Full Code Here

   */
  public static boolean checkServerCertValidity(int daysFromNow) {
    KeyStore keyStore;
      try {
        keyStore = KeyStore.getInstance(LDAPLoginModule.getTrustStoreType());
        keyStore.load(new FileInputStream(LDAPLoginModule.getTrustStoreLocation()), (LDAPLoginModule.getTrustStorePwd() != null) ? LDAPLoginModule.getTrustStorePwd().toCharArray() : null);
        Enumeration aliases = keyStore.aliases();
        while (aliases.hasMoreElements()) {
          String alias = (String) aliases.nextElement();
          Certificate cert = keyStore.getCertificate(alias);
          if (cert instanceof X509Certificate) {
View Full Code Here

        }
       
        // Step 5: load keys into keystore
        try
        {
            myKeys.load(is, keyPassPhrase);
           
        } catch (Exception eload)
        {
            throw new ConfigurationException(
                            KEYSTORE_KEY + "," + KEYSTOREPASS_KEY,
View Full Code Here

    char[] password = antProp.getProperty("keystore.password").toCharArray();
    is = UpdatePropUpdater.class.getClassLoader().getResourceAsStream("keystore.ks");
    if (is == null) {
      throw new IOException("No keystore.ks in root folder.");
    }
    ks.load(is, password);
    is.close();

    // get my private key
    KeyStore.PasswordProtection protection = new KeyStore.PasswordProtection(password);
    KeyStore.PrivateKeyEntry pkEntry = (KeyStore.PrivateKeyEntry) ks.getEntry(antProp.getProperty("keystore.alias"), protection);
View Full Code Here

      // load the KeyStore.
      String java_home = System.getProperty("java.home");
      String library_file = java_home + File.separator + "lib" + File.separator + "security" + File.separator + "cacerts";
      String passwd = "changeit";
     
      defaultKeyStore.load(new FileInputStream(library_file), passwd.toCharArray());

      KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
      kmf.init(defaultKeyStore, passwd.toCharArray());

      KeyManager[] keyManagers = kmf.getKeyManagers();
View Full Code Here

        /* open first time */
       
        PDDocument docOpen1 = PDDocument.load(output);
       
        KeyStore ks1 = KeyStore.getInstance("PKCS12");       
        ks1.load(new FileInputStream(privateCert1), password1.toCharArray());           
        PublicKeyDecryptionMaterial pdm = new PublicKeyDecryptionMaterial(ks1, null, password1);       
        docOpen1.openProtection(pdm);       
        docOpen1.close();

        /* open second time */
 
View Full Code Here

        /* open second time */
       
        PDDocument docOpen2 = PDDocument.load(output);
       
        KeyStore ks2 = KeyStore.getInstance("PKCS12");       
        ks2.load(new FileInputStream(privateCert2), password2.toCharArray());           
        PublicKeyDecryptionMaterial pdm2 = new PublicKeyDecryptionMaterial(ks2, null, password2);       
        docOpen2.openProtection(pdm2);       
        docOpen2.close();
               
    }
View Full Code Here

   
   
    private void open(PDDocument doc, String certPath, String password) throws Exception
    {   
        KeyStore ks = KeyStore.getInstance("PKCS12");
        ks.load(new FileInputStream(certPath), password.toCharArray());
       
        PublicKeyDecryptionMaterial pdm = new PublicKeyDecryptionMaterial(ks, null, password);
       
        doc.openProtection(pdm);
View Full Code Here

                {
                    DecryptionMaterial decryptionMaterial = null;
                    if( keyStore != null )
                    {
                        KeyStore ks = KeyStore.getInstance("PKCS12");      
                        ks.load(new FileInputStream(keyStore), password.toCharArray());
                           
                        decryptionMaterial = new PublicKeyDecryptionMaterial(ks, alias, password);
                    }
                    else
                    {
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.