HttpsURLConnection


HttpsURLConnection javax.net.ssl

Java 1.4

This class is a java.net.URLConnection for a URL that uses the https : protocol. It extends java.net.HttpURLConnection and, in addition to inheriting the methods of its superclasses, it defines methods for specifying the SSLSocketFactory and HostnameVerifier to use when establishing the connection. Static versions of these methods allow you to specify a default factory and verifier objects for use with all HttpsURLConnection objects. After the connection has been established, several other methods exist to obtain information (such as the cipher suite and the server certificates) about the connection itself.

Obtain a HttpsURLConnection object by calling the openConnection( ) method of a URL that uses the https:// protocol specifier , and casting the returned value to this type. The HttpsURLConnection object is unconnected at this point, and you can call setHostnameVerifier( ) and setSSLSocketFactory( ) to customize the way the connection is made. (If you do not specify a HostnameVerifier for the instance, or a default one for the class, then hostname mismatches will always cause the connection to fail. If you do not specify an SSLSocketFactory for the instance or class, then a default one will be used.) To connect, call the inherited connect( ) method, and then call the inherited getContent( ) to retrieve the content of the URL as an object, or use the inherited getInputStream( ) to obtain a java.io.InputStream with which you can read the content of the URL.

Figure 18-4. javax.net.ssl.HttpsURLConnection

 public abstract class  HttpsURLConnection  extends java.net.HttpURLConnection {  // Protected Constructors  protected  HttpsURLConnection  (java.net.URL  url  );  // Public Class Methods  public static HostnameVerifier  getDefaultHostnameVerifier  ( );        public static SSLSocketFactory  getDefaultSSLSocketFactory  ( );        public static void  setDefaultHostnameVerifier  (HostnameVerifier  v  );        public static void  setDefaultSSLSocketFactory  (SSLSocketFactory  sf  );  // Public Instance Methods  public abstract String  getCipherSuite  ( );        public HostnameVerifier  getHostnameVerifier  ( );        public abstract java.security.cert.Certificate[ ]  getLocalCertificates  ( );  5.0  public java.security.Principal  getLocalPrincipal  ( );  5.0  public java.security.Principal  getPeerPrincipal  ( )          throws SSLPeerUnverifiedException;        public abstract java.security.cert.Certificate[ ]  getServerCertificates  ( )          throws SSLPeerUnverifiedException;        public SSLSocketFactory  getSSLSocketFactory  ( );        public void  setHostnameVerifier  (HostnameVerifier  v  );        public void  setSSLSocketFactory  (SSLSocketFactory  sf  );  // Protected Instance Fields  protected HostnameVerifier  hostnameVerifier  ;   } 



Java In A Nutshell
Java In A Nutshell, 5th Edition
ISBN: 0596007736
EAN: 2147483647
Year: 2004
Pages: 1220

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net