Examples of KeyStore


Examples of java.security.KeyStore

     *
     * @param args the command line parameters
     */
    public static void main(String... args) throws Exception {
        String password = CipherFactory.KEYSTORE_PASSWORD;
        KeyStore store = CipherFactory.getKeyStore(password);
        printKeystore(store, password);
    }
View Full Code Here

Examples of java.security.KeyStore

        file = new File(file, "security");
        file = new File(file, "cacerts");
        FileInputStream fin = null;
        try {
            fin = new FileInputStream(file);
            KeyStore k;
            if (provider == null)
                k = KeyStore.getInstance("JKS");
            else
                k = KeyStore.getInstance("JKS", provider);
            k.load(fin, null);
            return k;
        }
        catch (Exception e) {
            throw new ExceptionConverter(e);
        }
View Full Code Here

Examples of java.security.KeyStore

        algorithm = KeyManagerFactory.getDefaultAlgorithm();
      }
        // Configure the Keystore Manager
        KeyManager[] keyManagers = null;
        if (keystore != null) {
            KeyStore ks = loadKeyStore(keystore, password, keystoreType);
            if (ks != null) {
                KeyManagerFactory kmf = KeyManagerFactory.getInstance(algorithm);
                kmf.init(ks, password.toCharArray());
                keyManagers = kmf.getKeyManagers();
            }
        }
       
        // Configure the Trust Store Manager
        TrustManager[] trustManagers = null;
        if (truststore != null) {
            KeyStore ks = loadKeyStore(truststore, truststorePassword, keystoreType);
            if (ks != null) {
                TrustManagerFactory tmf = TrustManagerFactory.getInstance(algorithm);
                tmf.init(ks);
                trustManagers = tmf.getTrustManagers();
            }
View Full Code Here

Examples of java.security.KeyStore

                exception.initCause(e);
                throw exception;
            }
        }
               
        KeyStore ks = KeyStore.getInstance(type);       
        try {
          ks.load(stream, password != null ? password.toCharArray() : null);
        } finally {
        stream.close();
        }
        return ks;
    }
View Full Code Here

Examples of java.security.KeyStore

        try {
            File keystoreFile = new File(KEYSTORE_OPTION.getProperty(server,endpointName));
            String storepass = STOREPASS_OPTION.getProperty(server,endpointName);
            String keypass = KEYPASS_OPTION.getProperty(server, endpointName );
            keypass = keypass == null ? storepass : keypass;
            KeyStore keystore = loadKeystoreFromFile(keystoreFile, storepass.toCharArray());

            SSLContext context = SSLContext.getInstance("SSL");
            context.init(getKeyManagers(keystore, keypass.toCharArray(), ALIAS_OPTION.getProperty( server, endpointName ) ), getTrustManagers(keystore), null);
            factory = context.getServerSocketFactory();
        } catch (GeneralSecurityException e) {
View Full Code Here

Examples of java.security.KeyStore

        }
        return serverSocket;
    }

    private KeyStore loadKeystoreFromFile(File file, char[] password) throws IOException, GeneralSecurityException {
        KeyStore keystore = KeyStore.getInstance("JKS");
        InputStream stream = new FileInputStream(file);
        keystore.load(stream, password);
        stream.close();

        return keystore;
    }
View Full Code Here

Examples of java.security.KeyStore

  }

  public DummyTrustManager() throws Exception {
    TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509", "SunJSSE");

    KeyStore ks = null;
    tmf.init((KeyStore) null);

    TrustManager tms[] = tmf.getTrustManagers();

    /*
 
View Full Code Here

Examples of java.security.KeyStore

        setTrustManager(new TrustManager[]{DummyTrustManager.getInstance()});
      }
     
      KeyManager km[] = null;
      if(getClientAuthKeystoreInputStream()!=null) {
        KeyStore keyStore = KeyStore.getInstance("JKS");
        keyStore.load(getClientAuthKeystoreInputStream(), getClientAuthKeystorePassword());
        KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
        kmf.init(keyStore, getClientAuthKeyPassword());
        km = kmf.getKeyManagers();
      } else {
        km = new KeyManager[0];
View Full Code Here

Examples of java.security.KeyStore

    @Override
    protected FTPSClient createFTPClient() throws Exception {
        FTPSClient client = new FTPSClient(useImplicit());
        client.setNeedClientAuth(true);

        KeyStore ks = KeyStore.getInstance("JKS");
        FileInputStream fis = new FileInputStream(FTPCLIENT_KEYSTORE);
        ks.load(fis, KEYSTORE_PASSWORD.toCharArray());
        fis.close();

        KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory
                .getDefaultAlgorithm());
        kmf.init(ks, KEYSTORE_PASSWORD.toCharArray());
View Full Code Here

Examples of java.security.KeyStore

    @Override
    protected FTPSClient createFTPClient() throws Exception {
        FTPSClient ftpsClient = new FTPSClient(useImplicit());

        FileInputStream fin = new FileInputStream(FTPCLIENT_KEYSTORE);
        KeyStore store = KeyStore.getInstance("jks");
        store.load(fin, KEYSTORE_PASSWORD.toCharArray());
        fin.close();

        // initialize key manager factory
        KeyManagerFactory keyManagerFactory = KeyManagerFactory
                .getInstance(KeyManagerFactory.getDefaultAlgorithm());
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.