Package com.sun.net.ssl

Examples of com.sun.net.ssl.HttpsURLConnection


   *
   *@param  conn  The new Context value
   */
  public void setContext(HttpURLConnection conn)
  {
    HttpsURLConnection secureConn = (HttpsURLConnection) conn;
    secureConn.setSSLSocketFactory(this.getContext().getSocketFactory());
    HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier()
    {
      public boolean verify(String urlHostname, String certHostname)
      {
        return true;
View Full Code Here


         * This test does not establish any connection to the specified
         * URL, hence a dummy URL is used.
         */
        URL foobar = new URL("https://example.com/");

        HttpsURLConnection urlc =
            (HttpsURLConnection) foobar.openConnection();

        try {
            urlc.getCipherSuite();
        } catch (IllegalStateException e) {
            System.out.print("Caught proper exception: ");
            System.out.println(e.getMessage());
        }

        try {
            urlc.getServerCertificateChain();
        } catch (IllegalStateException e) {
            System.out.print("Caught proper exception: ");
            System.out.println(e.getMessage());
        }

        try {
            urlc.setDefaultHostnameVerifier(null);
        } catch (IllegalArgumentException e) {
            System.out.print("Caught proper exception: ");
            System.out.println(e.getMessage());
        }

        try {
            urlc.setHostnameVerifier(null);
        } catch (IllegalArgumentException e) {
            System.out.print("Caught proper exception: ");
            System.out.println(e.getMessage());
        }

        try {
            urlc.setDefaultSSLSocketFactory(null);
        } catch (IllegalArgumentException e) {
            System.out.print("Caught proper exception: ");
            System.out.println(e.getMessage());
        }

        try {
            urlc.setSSLSocketFactory(null);
        } catch (IllegalArgumentException e) {
            System.out.print("Caught proper exception");
            System.out.println(e.getMessage());
        }
        System.out.println("TESTS PASSED");
View Full Code Here

TOP

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

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.