public abstract class

HttpsURLConnection

extends HttpURLConnection
java.lang.Object
   ↳ java.net.URLConnection
     ↳ java.net.HttpURLConnection
       ↳ javax.net.ssl.HttpsURLConnection

Class Overview

This abstract subclass of HttpURLConnection defines methods for managing HTTPS connections according to the description given by RFC 2818.

Summary

[Expand]
Inherited Constants
From class java.net.HttpURLConnection
Fields
protected HostnameVerifier hostnameVerifier The host name verifier used by this connection.
[Expand]
Inherited Fields
From class java.net.HttpURLConnection
From class java.net.URLConnection
Protected Constructors
HttpsURLConnection(URL url)
Creates a new HttpsURLConnection with the specified URL.
Public Methods
abstract String getCipherSuite()
Returns the name of the cipher suite negotiated during the SSL handshake.
static HostnameVerifier getDefaultHostnameVerifier()
Returns the default hostname verifier.
static SSLSocketFactory getDefaultSSLSocketFactory()
Returns the default SSL socket factory for new instances.
HostnameVerifier getHostnameVerifier()
Returns the hostname verifier used by this instance.
abstract Certificate[] getLocalCertificates()
Returns the list of local certificates used during the handshake.
Principal getLocalPrincipal()
Returns the Principal used to identify the local host during the handshake.
Principal getPeerPrincipal()
Returns the Principal identifying the peer.
SSLSocketFactory getSSLSocketFactory()
Returns the SSL socket factory used by this instance.
abstract Certificate[] getServerCertificates()
Return the list of certificates identifying the peer during the handshake.
static void setDefaultHostnameVerifier(HostnameVerifier v)
Sets the default hostname verifier to be used by new instances.
static void setDefaultSSLSocketFactory(SSLSocketFactory sf)
Sets the default SSL socket factory to be used by new instances.
void setHostnameVerifier(HostnameVerifier v)
Sets the hostname verifier for this instance.
void setSSLSocketFactory(SSLSocketFactory sf)
Sets the SSL socket factory for this instance.
[Expand]
Inherited Methods
From class java.net.HttpURLConnection
From class java.net.URLConnection
From class java.lang.Object

Fields

protected HostnameVerifier hostnameVerifier

Since: API Level 1

The host name verifier used by this connection. It is initialized from the default hostname verifier setDefaultHostnameVerifier(HostnameVerifier) or getDefaultHostnameVerifier().

Protected Constructors

protected HttpsURLConnection (URL url)

Since: API Level 1

Creates a new HttpsURLConnection with the specified URL.

Parameters
url the URL to connect to.

Public Methods

public abstract String getCipherSuite ()

Since: API Level 1

Returns the name of the cipher suite negotiated during the SSL handshake.

Returns
  • the name of the cipher suite negotiated during the SSL handshake.
Throws
IllegalStateException if no connection has been established yet.

public static HostnameVerifier getDefaultHostnameVerifier ()

Since: API Level 1

Returns the default hostname verifier.

Returns
  • the default hostname verifier.

public static SSLSocketFactory getDefaultSSLSocketFactory ()

Since: API Level 1

Returns the default SSL socket factory for new instances.

Returns
  • the default SSL socket factory for new instances.

public HostnameVerifier getHostnameVerifier ()

Since: API Level 1

Returns the hostname verifier used by this instance.

Returns
  • the hostname verifier used by this instance.

public abstract Certificate[] getLocalCertificates ()

Since: API Level 1

Returns the list of local certificates used during the handshake. These certificates were sent to the peer.

Returns
  • Returns the list of certificates used during the handshake with the local identity certificate followed by CAs, or null if no certificates were used during the handshake.
Throws
IllegalStateException if no connection has been established yet.

public Principal getLocalPrincipal ()

Since: API Level 1

Returns the Principal used to identify the local host during the handshake.

Returns
  • the Principal used to identify the local host during the handshake, or null if none was used.
Throws
IllegalStateException if no connection has been established yet.

public Principal getPeerPrincipal ()

Since: API Level 1

Returns the Principal identifying the peer.

Returns
  • the Principal identifying the peer.
Throws
SSLPeerUnverifiedException if the identity of the peer has not been verified.
IllegalStateException if no connection has been established yet.

public SSLSocketFactory getSSLSocketFactory ()

Since: API Level 1

Returns the SSL socket factory used by this instance.

Returns
  • the SSL socket factory used by this instance.

public abstract Certificate[] getServerCertificates ()

Since: API Level 1

Return the list of certificates identifying the peer during the handshake.

Returns
  • the list of certificates identifying the peer with the peer's identity certificate followed by CAs.
Throws
SSLPeerUnverifiedException if the identity of the peer has not been verified..
IllegalStateException if no connection has been established yet.

public static void setDefaultHostnameVerifier (HostnameVerifier v)

Since: API Level 1

Sets the default hostname verifier to be used by new instances.

Parameters
v the new default hostname verifier
Throws
IllegalArgumentException if the specified verifier is null.

public static void setDefaultSSLSocketFactory (SSLSocketFactory sf)

Since: API Level 1

Sets the default SSL socket factory to be used by new instances.

Parameters
sf the new default SSL socket factory.
Throws
IllegalArgumentException if the specified socket factory is null.

public void setHostnameVerifier (HostnameVerifier v)

Since: API Level 1

Sets the hostname verifier for this instance.

Parameters
v the hostname verifier for this instance.
Throws
IllegalArgumentException if the specified verifier is null.

public void setSSLSocketFactory (SSLSocketFactory sf)

Since: API Level 1

Sets the SSL socket factory for this instance.

Parameters
sf the SSL socket factory to be used by this instance.
Throws
IllegalArgumentException if the specified socket factory is null.