Package com.sun.net.ssl

Examples of com.sun.net.ssl.SSLContext


                        }
                    }
                }
                trustmanagers = createTrustManagers(keystore);
            }
            SSLContext sslcontext = SSLContext.getInstance("SSL");
            sslcontext.init(keymanagers, trustmanagers, null);
            return sslcontext;
        } catch (NoSuchAlgorithmException e) {
            LOG.error(e.getMessage(), e);
            throw new AuthSSLInitializationError("Unsupported algorithm exception: " + e.getMessage());
        } catch (KeyStoreException e) {
View Full Code Here


        super();
    }

    private static SSLContext createEasySSLContext() {
        try {
            SSLContext context = SSLContext.getInstance("SSL");
            context.init(
              null,
              new TrustManager[] {new EasyX509TrustManager(null)},
              null);
            return context;
        } catch (Exception e) {
View Full Code Here

        super();
    }

    private static SSLContext createEasySSLContext() {
        try {
            SSLContext context = SSLContext.getInstance("SSL");
            context.init(
              null,
              new TrustManager[] {new EasyX509TrustManager(null)},
              null);
            return context;
        } catch (Exception e) {
View Full Code Here

            trustFactory = TrustManagerFactory.getInstance(m_trustManagerAlgorithm);
            trustFactory.init(trustStore);
         }

         SSLContext context = SSLContext.getInstance(m_sslProtocol);
         // Below call does not handle TrustManagers, needed when server must authenticate clients.
         context.init(keyFactory.getKeyManagers(), trustFactory == null ? null : trustFactory.getTrustManagers(), null);

         SSLServerSocketFactory ssf = context.getServerSocketFactory();
         SSLServerSocket serverSocket = (SSLServerSocket)ssf.createServerSocket(port, backlog, InetAddress.getByName(host));

         return serverSocket;
      }
      catch (IOException x)
View Full Code Here

            }
            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
            // but for our simple HTTP testing framework this will suffice
            LOG.error(ex.getMessage(), ex);
View Full Code Here

            }
            TrustManagerFactory tmfactory = TrustManagerFactory.getInstance(
                    TrustManagerFactory.getDefaultAlgorithm());
            tmfactory.init(keystore);
            TrustManager[] trustmanagers = tmfactory.getTrustManagers();
            SSLContext sslcontext = SSLContext.getInstance("TLS");
            sslcontext.init(null, trustmanagers, null);
            return sslcontext;
        } catch (Exception ex) {
            // this is not the way a sane exception handling should be done
            // but for our simple HTTP testing framework this will suffice
            LOG.error(ex.getMessage(), ex);
View Full Code Here

    public SunSSLTransportFactory(Properties properties)
    throws GeneralSecurityException
    {
        X509TrustManager trustManager;
        HostnameVerifier hostnameVerifier;
        SSLContext sslContext;

        Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());

        url = (URL) properties.get(XmlRpcTransportFactory.TRANSPORT_URL);
        auth = properties.getProperty(XmlRpcTransportFactory.TRANSPORT_AUTH);

        trustManager = (X509TrustManager) properties.get(TRANSPORT_TRUSTMANAGER);
        if (trustManager == null)
        {
            trustManager = openTrustManager;
        }

        hostnameVerifier = (HostnameVerifier) properties.get(TRANSPORT_HOSTNAMEVERIFIER);
        if (hostnameVerifier == null)
        {
            hostnameVerifier = openHostnameVerifier;
       

        sslContext = SSLContext.getInstance(SecurityTool.getSecurityProtocol());
        X509TrustManager[] tmArray = new X509TrustManager[] { trustManager };
        sslContext.init(null, tmArray, new SecureRandom());

        // Set the default SocketFactory and HostnameVerifier
        // for javax.net.ssl.HttpsURLConnection
        if (sslContext != null)
        {
            HttpsURLConnection.setDefaultSSLSocketFactory(
                sslContext.getSocketFactory());
        }
        HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);
    }
View Full Code Here

    protected ServerSocket createServerSocket(int port, int backlog, InetAddress add)
        throws Exception
    {
        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

            }
            TrustManagerFactory tmfactory = TrustManagerFactory.getInstance(
                    TrustManagerFactory.getDefaultAlgorithm());
            tmfactory.init(keystore);
            TrustManager[] trustmanagers = tmfactory.getTrustManagers();
            SSLContext sslcontext = SSLContext.getInstance("TLS");
            sslcontext.init(null, trustmanagers, null);
            return sslcontext;
        } catch (Exception ex) {
            // this is not the way a sane exception handling should be done
            // but for our simple HTTP testing framework this will suffice
            LOG.error(ex.getMessage(), ex);
View Full Code Here

            }
            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
            // but for our simple HTTP testing framework this will suffice
            LOG.error(ex.getMessage(), ex);
View Full Code Here

TOP

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

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.