Package javax.net.ssl

Examples of javax.net.ssl.HttpsURLConnection$DefaultHostnameVerifier


     */
    public HttpsURLConnectionInfo(HttpURLConnection connection)
        throws IOException {
        super(connection);
        if (connection instanceof HttpsURLConnection) {
            HttpsURLConnection conn = (HttpsURLConnection) connection;
            enabledCipherSuite = conn.getCipherSuite();
            localCertificates  = conn.getLocalCertificates();
            localPrincipal     = conn.getLocalPrincipal();
            serverCertificates = conn.getServerCertificates();
            peerPrincipal      = conn.getPeerPrincipal();
        } else {
            Exception ex = null;
            try {
                Method method = null;
                method = connection.getClass().getMethod("getCipherSuite", (Class[]) null);
View Full Code Here


            verifier = CertificateHostnameVerifier.DEFAULT;
        }
       
        if (connection instanceof HttpsURLConnection) {
            // handle the expected case (javax.net.ssl)
            HttpsURLConnection conn = (HttpsURLConnection) connection;
            conn.setHostnameVerifier(verifier);
            conn.setSSLSocketFactory(socketFactory);
        } else {
            // handle the deprecated sun case and other possible hidden API's
            // that are similar to the Sun cases
            try {
                Method method = connection.getClass().getMethod("getHostnameVerifier");
View Full Code Here

            //create java.net URL pointing to remote resource
            URL url = new URL(uri);
            XMLStreamReader parser;
            // if the policy reference is a https URI
            if ("https".equals(url.getProtocol())) {
                HttpsURLConnection connection;
                connection = (HttpsURLConnection) url.openConnection();
                // implement a new HostnameVerifier which ignores the hostname information
                connection.setHostnameVerifier(new HostnameVerifier() {
                    public boolean verify(String s, SSLSession sslSession) {
                        return true;
                    }
                });
                connection.setDoInput(true);
                //create stax parser with the url content
                parser = XMLInputFactory.newInstance().createXMLStreamReader(connection.getInputStream());
            } else {
                URLConnection connection;
                connection = url.openConnection();
                connection.setDoInput(true);

                //create stax parser with the url content
                parser = XMLInputFactory.newInstance().createXMLStreamReader(connection.getInputStream());
            }

            //get the root element (in this case the envelope)
            StAXOMBuilder builder = new StAXOMBuilder(parser);
            documentElement = builder.getDocumentElement();
View Full Code Here

      public Reader open()
         throws IOException
      {
         URLConnection connection = location.toURL().openConnection();
         if (connection instanceof HttpsURLConnection) {
            HttpsURLConnection https = (HttpsURLConnection)connection;
            https.setHostnameVerifier(org.apache.commons.ssl.HostnameVerifier.DEFAULT_AND_LOCALHOST);
         }
         if (username!=null) {
            connection.setRequestProperty("Authorization", "Basic " + Base64Coder.encode(username+':'+password));
         }
         String charset = "UTF-8";
View Full Code Here

      public Reader open()
         throws IOException
      {
         URLConnection connection = location.toURL().openConnection();
         if (connection instanceof HttpsURLConnection) {
            HttpsURLConnection https = (HttpsURLConnection)connection;
            https.setHostnameVerifier(org.apache.commons.ssl.HostnameVerifier.DEFAULT_AND_LOCALHOST);
         }
         if (username!=null) {
            connection.setRequestProperty("Authorization", "Basic " + Base64Coder.encode(username+':'+password));
         }
         String charset = "UTF-8";
View Full Code Here

   public void retrieve(File output,String username,String password)
      throws IOException
   {
      URLConnection connection = url.openConnection();
      if (connection instanceof HttpsURLConnection) {
         HttpsURLConnection https = (HttpsURLConnection)connection;
         https.setHostnameVerifier(org.apache.commons.ssl.HostnameVerifier.DEFAULT_AND_LOCALHOST);
      }
      if (username!=null) {
         connection.setRequestProperty("Authorization", "Basic " + Base64Coder.encode(username+':'+password));
      }
      String charset = "UTF-8";
View Full Code Here

      Reader open()
         throws IOException
      {
         URLConnection connection = location.toURL().openConnection();
         if (connection instanceof HttpsURLConnection) {
            HttpsURLConnection https = (HttpsURLConnection)connection;
            https.setHostnameVerifier(org.apache.commons.ssl.HostnameVerifier.DEFAULT_AND_LOCALHOST);
         }
         if (username!=null) {
            connection.setRequestProperty("Authorization", "Basic " + Base64Coder.encode(username+':'+password));
         }
         String charset = "UTF-8";
View Full Code Here

            //SSL is slow, open new thread to do this
            new Thread() {

                private String getPassportUrlSlow() throws IOException {
//                    log.debug("MSNDEBUG: Lets ask the nexus what passport url to use");
                    HttpsURLConnection conn = null;
                    try {
                        conn = (HttpsURLConnection) new URL(
                                "https://nexus.passport.com/rdr/pprdr.asp")
                                .openConnection();
                        conn.setUseCaches(false);
//                        log.debug("MSNDEBUG: Got password urls: "+conn.getHeaderField("PassportURLs"));
                        Matcher matcher = passportUrlPattern.matcher(conn
                                .getHeaderField("PassportURLs"));
                        if (matcher.matches()) {
//                            log.debug("MSNDEBUG: We're going to use url: "+matcher.group(1));
                            return "https://" + matcher.group(1);
                        }
//                        log.debug("MSNDEBUG: Crap, no url found?!");
                        return null;
                    } finally {
                        if (conn != null)
                            conn.disconnect();
                    }
                }

                private String getPassportUrl() throws IOException {
//                    log.debug("MSNDEBUG: Retrieving passport url");
                    if (JmlConstants.FAST_SSL_LOGIN)
                        return "https://login.live.com/login2.srf";
                    return getPassportUrlSlow();
                }

                private String getLoginTicket(String visitUrl, String passport,
                        String password, String challengeStr)
                        throws IOException {
//                    log.debug("MSNDEBUG: Retrieving the login ticket from url "+visitUrl+" and passport "+passport);
                    HttpsURLConnection conn = null;
                    try {
                        conn = (HttpsURLConnection) new URL(visitUrl)
                                .openConnection();
                        conn.setUseCaches(false);
//                        log.debug("MSNDEBUG: Setting request property");
                        conn.setRequestProperty("Authorization",
//                                "Passport1.4 OrgVerb=GET,OrgURL=http%3A%2F%2Fmessenger%2Emsn%2Ecom,sign-in="
                                "Passport1.4 OrgVerb=GET,OrgURL="
                                        + StringUtils.urlEncode(visitUrl)
                                        + ",sign-in="
                                        + StringUtils.urlEncode(passport)
                                        + ",pwd="
                                        + StringUtils.urlEncode(password) + ","
                                        + challengeStr);
//                        log.debug("MSNDEBUG: Request property is "+conn.getRequestProperty("Authorization"));
                        switch (conn.getResponseCode()) {
                            case 200: //success
//                                log.debug("MSNDEBUG: Response code is 200, success!");
                                Matcher matcher = ticketPattern.matcher(conn
                                        .getHeaderField("Authentication-Info"));
                                if (matcher.matches()) {
                                    return matcher.group(1);
                                }
                                return null;
                            case 302: //redirect
//                                log.debug("MSNDEBUG: Response code is 302, being redirected!");
                                visitUrl = conn.getHeaderField("Location");
//                                log.debug("MSNDEBUG: Redirect to "+visitUrl);
                                return getLoginTicket(visitUrl, passport, password,
                                        challengeStr);
                            case 401: //failed
//                                log.debug("MSNDEBUG: Response code is 401, we failed?");
                                return null;
                            default:
//                                log.debug("MSNDEBUG: Response code (unknown) was "+conn.getResponseCode());
                        }
                    } finally {
                        if (conn != null) {
                            conn.disconnect();
                        }
                    }
                    return null;
                }
View Full Code Here

    */
   protected HttpURLConnection initConnection(HttpRequest request) throws IOException {
      URL url = request.getEndpoint().toURL();
      HttpURLConnection connection = (HttpURLConnection) url.openConnection(proxyForURI.apply(request.getEndpoint()));
      if (connection instanceof HttpsURLConnection) {
         HttpsURLConnection sslCon = (HttpsURLConnection) connection;
         if (utils.relaxHostname())
            sslCon.setHostnameVerifier(verifier);
         if (sslContextSupplier != null) {
             // used for providers which e.g. use certs for authentication (like FGCP)
             // Provider provides SSLContext impl (which inits context with key manager)
             sslCon.setSSLSocketFactory(sslContextSupplier.get().getSocketFactory());
         } else if (utils.trustAllCerts()) {
             sslCon.setSSLSocketFactory(untrustedSSLContextProvider.get().getSocketFactory());
         }
      }
      return connection;
   }
View Full Code Here

            System.clearProperty("javax.net.ssl.keyStorePassword");
        }
        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;
            }}
        );

        conn.connect();
        read(conn.getInputStream());
       
        service.stop();
        assertTrue(servlet.invoked);

    }
View Full Code Here

TOP

Related Classes of javax.net.ssl.HttpsURLConnection$DefaultHostnameVerifier

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.