Package com.sun.net.ssl

Examples of com.sun.net.ssl.KeyManagerFactory


            {
                log.error("Exception occurred",ee);
            }
            try
            {
                KeyManagerFactory managerFactory =
                    KeyManagerFactory.getInstance("SunX509");
                JmeterKeyStore keys = this.getKeyStore();
                managerFactory.init(null, this.defaultpw.toCharArray());
                KeyManager[] managers = managerFactory.getKeyManagers();
                log.info(keys.getClass().toString());
                for (int i = 0; i < managers.length; i++)
                {
                    if (managers[i] instanceof X509KeyManager)
                    {
View Full Code Here


        // Create an SSL context used to create an SSL socket factory
        SSLContext context = SSLContext.getInstance(protocol);

        // Create the key manager factory used to extract the server key
        KeyManagerFactory keyManagerFactory =
            KeyManagerFactory.getInstance(algorithm);
        keyManagerFactory.init(keyStore, keystorePass.toCharArray());

        // Create the trust manager factory used for checking certificates
        /*
          trustManagerFactory = TrustManagerFactory.getInstance(algorithm);
          trustManagerFactory.init(keyStore);
        */

        // Initialize the context with the key managers
        context.init(keyManagerFactory.getKeyManagers(), null,
                     new java.security.SecureRandom());

        // Create the proxy and return
        sslProxy = context.getServerSocketFactory();

View Full Code Here

        try {
            ClassLoader cl = SimpleSocketFactory.class.getClassLoader();
            URL url = cl.getResource("org/apache/commons/httpclient/ssl/simpleserver.keystore");
            KeyStore keystore  = KeyStore.getInstance("jks");
            keystore.load(url.openStream(), "nopassword".toCharArray());
            KeyManagerFactory kmfactory = KeyManagerFactory.getInstance(
                    KeyManagerFactory.getDefaultAlgorithm());
            kmfactory.init(keystore, "nopassword".toCharArray());
            KeyManager[] keymanagers = kmfactory.getKeyManagers();
            SSLContext sslcontext = SSLContext.getInstance("TLS");
            sslcontext.init(keymanagers, null, null);
            return sslcontext;
        } catch (Exception ex) {
            // this is not the way a sane exception handling should be done
View Full Code Here

    {
        if (keystore == null) {
            throw new IllegalArgumentException("Keystore may not be null");
        }
        LOG.debug("Initializing key manager");
        KeyManagerFactory kmfactory = KeyManagerFactory.getInstance(
            KeyManagerFactory.getDefaultAlgorithm());
        kmfactory.init(keystore, password != null ? password.toCharArray(): null);
        return kmfactory.getKeyManagers();
    }
View Full Code Here

    {
        if (keystore == null) {
            throw new IllegalArgumentException("Keystore may not be null");
        }
        LOG.debug("Initializing key manager");
        KeyManagerFactory kmfactory = KeyManagerFactory.getInstance(
            KeyManagerFactory.getDefaultAlgorithm());
        kmfactory.init(keystore, password != null ? password.toCharArray(): null);
        return kmfactory.getKeyManagers();
    }
View Full Code Here

        {
        }
      }
      try
      {
        KeyManagerFactory managerFactory =
          KeyManagerFactory.getInstance("SunX509");
        JmeterKeyStore keys = this.getKeyStore();
        managerFactory.init(null, this.defaultpw.toCharArray());
        KeyManager[] managers = managerFactory.getKeyManagers();
        log.info(keys.getClass().toString());
        for (int i = 0; i < managers.length; i++)
        {
          if (managers[i] instanceof X509KeyManager)
          {
View Full Code Here

    {
        SecurityTool.setup();
   
        SSLContext context = SSLContext.getInstance(SecurityTool.getSecurityProtocol());
         
        KeyManagerFactory keyManagerFactory =
            KeyManagerFactory.getInstance(SecurityTool.getKeyManagerType());
           
        KeyStore keyStore = KeyStore.getInstance(SecurityTool.getKeyStoreType());
           
        keyStore.load(new FileInputStream(SecurityTool.getKeyStore()),
            SecurityTool.getKeyStorePassword().toCharArray());
           
        keyManagerFactory.init(keyStore, SecurityTool.getKeyStorePassword().toCharArray());
           
        context.init(keyManagerFactory.getKeyManagers(), null, null);
        SSLServerSocketFactory sslSrvFact = context.getServerSocketFactory();
        return (SSLServerSocket) sslSrvFact.createServerSocket(port);
    }
View Full Code Here

        // Create an SSL context used to create an SSL socket factory
        SSLContext context = SSLContext.getInstance(protocol);

        // Create the key manager factory used to extract the server key
        KeyManagerFactory keyManagerFactory =
            KeyManagerFactory.getInstance(algorithm);
        keyManagerFactory.init(keyStore, keystorePass.toCharArray());

        // Create the trust manager factory used for checking certificates
        /*
          trustManagerFactory = TrustManagerFactory.getInstance(algorithm);
          trustManagerFactory.init(keyStore);
        */

        // Initialize the context with the key managers
        context.init(keyManagerFactory.getKeyManagers(), null,
                     new java.security.SecureRandom());

        // Create the proxy and return
        sslProxy = context.getServerSocketFactory();

View Full Code Here

        try {
            ClassLoader cl = SimpleSocketFactory.class.getClassLoader();
            URL url = cl.getResource("org/apache/commons/httpclient/ssl/simpleserver.keystore");
            KeyStore keystore  = KeyStore.getInstance("jks");
            keystore.load(url.openStream(), "nopassword".toCharArray());
            KeyManagerFactory kmfactory = KeyManagerFactory.getInstance(
                    KeyManagerFactory.getDefaultAlgorithm());
            kmfactory.init(keystore, "nopassword".toCharArray());
            KeyManager[] keymanagers = kmfactory.getKeyManagers();
            SSLContext sslcontext = SSLContext.getInstance("TLS");
            sslcontext.init(keymanagers, null, null);
            return sslcontext;
        } catch (Exception ex) {
            // this is not the way a sane exception handling should be done
View Full Code Here

    {
        if (keystore == null) {
            throw new IllegalArgumentException("Keystore may not be null");
        }
        LOG.debug("Initializing key manager");
        KeyManagerFactory kmfactory = KeyManagerFactory.getInstance(
            KeyManagerFactory.getDefaultAlgorithm());
        kmfactory.init(keystore, password != null ? password.toCharArray(): null);
        return kmfactory.getKeyManagers();
    }
View Full Code Here

TOP

Related Classes of com.sun.net.ssl.KeyManagerFactory

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.