Package java.security

Examples of java.security.KeyStore$Builder


        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


                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

        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

        }
        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

  }

  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

        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

    @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

    @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

    private KeyManager km;

    @Override
    protected void setUp() throws Exception {
        KeyStore ks = KeyStore.getInstance("JKS");

        FileInputStream fis = new FileInputStream(
                "src/test/resources/keymanager-test.jks");
        ks.load(fis, "".toCharArray());

        KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
        kmf.init(ks, "".toCharArray());

        km = kmf.getKeyManagers()[0];
View Full Code Here

    private KeyManager km;

    @Override
    protected void setUp() throws Exception {
        KeyStore ks = KeyStore.getInstance("JKS");

        FileInputStream fis = new FileInputStream(
                "src/test/resources/keymanager-test.jks");
        ks.load(fis, "".toCharArray());

        KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
        kmf.init(ks, "".toCharArray());

        km = kmf.getKeyManagers()[0];
View Full Code Here

TOP

Related Classes of java.security.KeyStore$Builder

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.