Package javax.net.ssl

Examples of javax.net.ssl.HostnameVerifier


                    {
                        try
                        {
                            StartTlsResponse tls = ( StartTlsResponse ) context
                                .extendedOperation( new StartTlsRequest() );
                            tls.setHostnameVerifier( new HostnameVerifier()
                            {
                                public boolean verify( String arg0, SSLSession arg1 )
                                {
                                    return true;
                                }
View Full Code Here


        } else {
           // ssl socket factory already initialized, reuse it to benefit of keep alive
        }
       
       
        HostnameVerifier verifier;
        if (tlsClientParameters.isUseHttpsURLConnectionDefaultHostnameVerifier()) {
            verifier = HttpsURLConnection.getDefaultHostnameVerifier();
        } else if (tlsClientParameters.isDisableCNCheck()) {
            verifier = CertificateHostnameVerifier.ALLOW_ALL;
        } else {
View Full Code Here

            HttpsURLConnection.setDefaultSSLSocketFactory(sslc.getSocketFactory());
        }
  if(HttpsURLConnection.getDefaultHostnameVerifier() instanceof AcceptAnyHostName) {
    return;
  }
        HostnameVerifier hv = new AcceptAnyHostName();
        HttpsURLConnection.setDefaultHostnameVerifier(hv);
    }
View Full Code Here

                conn = (HttpsURLConnection)url.openConnection(proxy);
            }else {
                conn = (HttpsURLConnection)url.openConnection();
            }
            conn.setSSLSocketFactory(sc.getSocketFactory());
            HostnameVerifier hnv = new SSLHostNameVerifier();
            conn.setDefaultHostnameVerifier(hnv);
        } catch(Exception e){
            if(_logger.isLoggable(Level.INFO))
                e.printStackTrace();
            throw new IOException(e.getMessage());
View Full Code Here

        }
        System.setProperty("javax.net.ssl.trustStore", "target/test-classes/tuscany.keyStore");
        System.setProperty("javax.net.ssl.trustStorePassword", "apache");
        URL url = new URL("https://127.0.0.1:8085/foo");
        HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
        conn.setHostnameVerifier(new HostnameVerifier() {
            public boolean verify(String hostname, SSLSession session) {
                return true;
            }}
        );
View Full Code Here

     *
     * @param config The current test context.
     */
    protected void installHostnameVerifier(final Configuration config) {
        LOG.info("Installing HostnameVerifier");
        HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier()
        {
            public boolean verify(String hostname, SSLSession sslSession) {
                LOG.info("Granting access for " + hostname);
                return true;
            }
View Full Code Here

                conn = (HttpsURLConnection) url.openConnection(proxy);
            } else {
                conn = (HttpsURLConnection) url.openConnection();
            }
            conn.setSSLSocketFactory(sc.getSocketFactory());
            HostnameVerifier hnv = new SSLHostNameVerifier();
            conn.setDefaultHostnameVerifier(hnv);
        } catch (Exception e) {
            throw new IOException(e.getMessage(), e);
        }
        return conn;
View Full Code Here

        if (uc instanceof HttpsURLConnection) {
            HttpsURLConnection suc = (HttpsURLConnection) uc;

            final JerseyClient client = request.getClient();
            final HostnameVerifier verifier = client.getHostnameVerifier();
            if (verifier != null) {
                suc.setHostnameVerifier(verifier);
            }
            suc.setSSLSocketFactory(client.getSslContext().getSocketFactory());
        }
View Full Code Here

                    {
                        try
                        {
                            StartTlsResponse tls = ( StartTlsResponse ) context
                                .extendedOperation( new StartTlsRequest() );
                            tls.setHostnameVerifier( new HostnameVerifier()
                            {
                                public boolean verify( String arg0, SSLSession arg1 )
                                {
                                    return true;
                                }
View Full Code Here

    }

    public static HostnameVerifier getHostnameVerifier(int level) {
        switch (level) {
            case HOSTCERT_MIN_CHECK:
                return new HostnameVerifier() {
                    public boolean verify(String hostname, SSLSession session) {
                        javax.security.cert.X509Certificate[] peerCerts;
                        try {
                            peerCerts = session.getPeerCertificateChain();
                        } catch (SSLPeerUnverifiedException e) {
                            // cert not verified
                            Debug.logWarning(e.getMessage(), module);
                            return false;
                        }
                        for (javax.security.cert.X509Certificate peerCert: peerCerts) {
                            Principal x500s = peerCert.getSubjectDN();
                            Map<String, String> subjectMap = KeyStoreUtil.getX500Map(x500s);

                            if (Debug.infoOn())
                                Debug.logInfo(peerCert.getSerialNumber().toString(16) + " :: " + subjectMap.get("CN"), module);

                            try {
                                peerCert.checkValidity();
                            } catch (Exception e) {
                                // certificate not valid
                                Debug.logWarning("Certificate is not valid!", module);
                                return false;
                            }
                        }
                        return true;
                    }
                };
            case HOSTCERT_NO_CHECK:
                return new HostnameVerifier() {
                    public boolean verify(String hostname, SSLSession session) {
                        return true;
                    }
                };
            default:
View Full Code Here

TOP

Related Classes of javax.net.ssl.HostnameVerifier

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.