Examples of HttpsURLConnection


Examples of javax.net.ssl.HttpsURLConnection

        url = new URL(baseHttpsUrl + address);
       
        requestInput = JaxWSTest.class.getResourceAsStream("/request1.xml");
        assertNotNull("SOAP request not specified", requestInput);
       
        HttpsURLConnection conn2 = (HttpsURLConnection) url.openConnection();
        conn2.setHostnameVerifier(new TestUtils.TestHostnameVerifier());
        try {
            checkResponse(requestInput, conn2);
        } finally {
            TestUtils.unset("javax.net.ssl.trustStore", oldTrustStore);
            TestUtils.unset("javax.net.ssl.trustStorePassword", oldTrustStorePassword);
           
            conn2.disconnect();
        }
    }
View Full Code Here

Examples of javax.net.ssl.HttpsURLConnection

        System.setProperty("javax.net.ssl.trustStore", keyStore.getAbsolutePath());
        System.setProperty("javax.net.ssl.trustStorePassword", "secret");
       
        url = new URL(baseHttpsUrl + "BeanHttps/ejb?wsdl");
               
        HttpsURLConnection conn2 = (HttpsURLConnection) url.openConnection();
        conn2.setHostnameVerifier(new TestUtils.TestHostnameVerifier());
        try {
            checkWSDL(conn2);
        } finally {
            TestUtils.unset("javax.net.ssl.trustStore", oldTrustStore);
            TestUtils.unset("javax.net.ssl.trustStorePassword", oldTrustStorePassword);
           
            conn2.disconnect();
        }
    }
View Full Code Here

Examples of javax.net.ssl.HttpsURLConnection

    @Override
    protected void prepareConnection(HttpURLConnection connection) throws IOException {
        super.prepareConnection(connection);
        if (connection instanceof HttpsURLConnection) {
            HttpsURLConnection httpsConnection = (HttpsURLConnection) connection;
            httpsConnection.setSSLSocketFactory(createSslSocketFactory());

            if (hostnameVerifier != null) {
                httpsConnection.setHostnameVerifier(hostnameVerifier);
            }
        }
    }
View Full Code Here

Examples of javax.net.ssl.HttpsURLConnection

  protected HttpURLConnection openConnection(String path, String query)
      throws IOException {
    try {
      final URL url = new URI("https", null, nnAddr.getHostName(),
          nnAddr.getPort(), path, query, null).toURL();
      HttpsURLConnection conn = (HttpsURLConnection)url.openConnection();
      // bypass hostname verification
      conn.setHostnameVerifier(new DummyHostnameVerifier());
      return (HttpURLConnection)conn;
    } catch (URISyntaxException e) {
      throw (IOException)new IOException().initCause(e);
    }
  }
View Full Code Here

Examples of javax.net.ssl.HttpsURLConnection

            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

Examples of javax.net.ssl.HttpsURLConnection

    Configuration conf = createConfiguration(false, true);
    conf.set(SSLFactory.SSL_HOSTNAME_VERIFIER_KEY, "STRICT_IE6");
    SSLFactory sslFactory = new SSLFactory(SSLFactory.Mode.CLIENT, conf);
    try {
      sslFactory.init();
      HttpsURLConnection sslConn =
          (HttpsURLConnection) new URL("https://foo").openConnection();
      Assert.assertNotSame("STRICT_IE6",
                           sslConn.getHostnameVerifier().toString());
      sslFactory.configure(sslConn);
      Assert.assertEquals("STRICT_IE6",
                          sslConn.getHostnameVerifier().toString());
    } finally {
      sslFactory.destroy();
    }
  }
View Full Code Here

Examples of javax.net.ssl.HttpsURLConnection

  @Test
  public void testHttpsCookie() throws IOException, GeneralSecurityException {
    URL base = new URL("https://" + NetUtils.getHostPortString(server
            .getConnectorAddress(1)));
    HttpsURLConnection conn = (HttpsURLConnection) new URL(base,
            "/echo").openConnection();
    conn.setSSLSocketFactory(clientSslFactory.createSSLSocketFactory());

    String header = conn.getHeaderField("Set-Cookie");
    List<HttpCookie> cookies = HttpCookie.parse(header);
    Assert.assertTrue(!cookies.isEmpty());
    Assert.assertTrue(header.contains("; HttpOnly"));
    Assert.assertTrue(cookies.get(0).getSecure());
    Assert.assertTrue("token".equals(cookies.get(0).getValue()));
View Full Code Here

Examples of javax.net.ssl.HttpsURLConnection

      throws IOException {
    final TrustManager[] trustAllCerts = new TrustManager[] { new DummyX509TrustManager() };
    try {
      SSLContext ctx = SSLContext.getInstance("SSL");
      ctx.init(null, trustAllCerts, null);
      final HttpsURLConnection sslConn = (HttpsURLConnection) conn;
      sslConn.setSSLSocketFactory(ctx.getSocketFactory());
    } catch (KeyManagementException e) {
      throw new IOException(e.getMessage());
    } catch (NoSuchAlgorithmException e) {
      throw new IOException(e.getMessage());
    }
View Full Code Here

Examples of javax.net.ssl.HttpsURLConnection

  }

  private void setSSLChecks(URL url, HttpURLConnection connection) {
    if (isHttps(url)
        && !sslChecks) {
      HttpsURLConnection httpsConnection = (HttpsURLConnection) connection;
      httpsConnection.setHostnameVerifier(new NoopHostnameVerifier());
      setPermissiveSSLSocketFactory(httpsConnection);
    }
  }
View Full Code Here

Examples of javax.net.ssl.HttpsURLConnection

            connection.setInstanceFollowRedirects(false);
            connection.setUseCaches(false);

            if (connection instanceof HttpsURLConnection
                && hostnameVerifier != null) {
                HttpsURLConnection httpsConnection = (HttpsURLConnection) connection;
                httpsConnection.setHostnameVerifier(hostnameVerifier);
            }

            // Set the request headers
            if (method == Method.POST || method == Method.PUT) {
                connection.setRequestProperty("Content-Type", serializer.getMIMEType(value));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.