javax.net.ssl

Class HttpsURLConnection


public abstract class HttpsURLConnection
extends HttpURLConnection

A URL connection that connects via the Secure Socket Layer (SSL) for HTTPS connections.

This class may be used in the same way as HttpURLConnection, and it will transparently negotiate the SSL connection.

Author:
Casey Marshall (rsdio@metastatic.org)

Field Summary

protected HostnameVerifier
hostnameVerifier
The hostname verifier used for this connection.

Constructor Summary

HttpsURLConnection(URL url)
Creates a new HTTPS URL connection.

Method Summary

abstract String
getCipherSuite()
Returns the cipher name negotiated for this connection.
static HostnameVerifier
getDefaultHostnameVerifier()
Returns the default hostname verifier used in all new connections.
static SSLSocketFactory
getDefaultSSLSocketFactory()
Returns the default SSL socket factory used in all new connections.
HostnameVerifier
getHostnameVerifier()
Returns the current hostname verifier for this instance.
abstract Certificate[]
getLocalCertificates()
Returns the certificates used on the local side in this connection.
SSLSocketFactory
getSSLSocketFactory()
Returns the current SSL socket factory for this instance.
abstract Certificate[]
getServerCertificates()
Returns the certificates sent by the other party.
static void
setDefaultHostnameVerifier(HostnameVerifier newDefault)
Sets the default hostname verifier to be used in all new connections.
static void
setDefaultSSLSocketFactory(SSLSocketFactory newDefault)
Sets the default SSL socket factory to be used in all new connections.
void
setHostnameVerifier(HostnameVerifier hostnameVerifier)
Sets the hostname verifier for this instance.
void
setSSLSocketFactory(SSLSocketFactory factory)
Sets the SSL socket factory for this instance.

Field Details

hostnameVerifier

protected HostnameVerifier hostnameVerifier
The hostname verifier used for this connection.

Constructor Details

HttpsURLConnection

protected HttpsURLConnection(URL url)
            throws IOException
Creates a new HTTPS URL connection.
Parameters:
url - The URL of the connection being established.

Method Details

getCipherSuite

public abstract String getCipherSuite()
Returns the cipher name negotiated for this connection.
Returns:
The cipher name.

getDefaultHostnameVerifier

public static HostnameVerifier getDefaultHostnameVerifier()
Returns the default hostname verifier used in all new connections.
Returns:
The default hostname verifier.

getDefaultSSLSocketFactory

public static SSLSocketFactory getDefaultSSLSocketFactory()
Returns the default SSL socket factory used in all new connections.
Returns:
The default SSL socket factory.

getHostnameVerifier

public HostnameVerifier getHostnameVerifier()
Returns the current hostname verifier for this instance.
Returns:
The hostname verifier.

getLocalCertificates

public abstract Certificate[] getLocalCertificates()
Returns the certificates used on the local side in this connection.
Returns:
The local certificates.

getSSLSocketFactory

public SSLSocketFactory getSSLSocketFactory()
Returns the current SSL socket factory for this instance.
Returns:
The current SSL socket factory.

getServerCertificates

public abstract Certificate[] getServerCertificates()
            throws SSLPeerUnverifiedException
Returns the certificates sent by the other party.
Returns:
The peer's certificates.
Throws:
SSLPeerUnverifiedException - If the peer could not be verified.

setDefaultHostnameVerifier

public static void setDefaultHostnameVerifier(HostnameVerifier newDefault)
Sets the default hostname verifier to be used in all new connections.
Parameters:
newDefault - The new default hostname verifier.

setDefaultSSLSocketFactory

public static void setDefaultSSLSocketFactory(SSLSocketFactory newDefault)
Sets the default SSL socket factory to be used in all new connections.
Parameters:
newDefault - The new socket factory.

setHostnameVerifier

public void setHostnameVerifier(HostnameVerifier hostnameVerifier)
Sets the hostname verifier for this instance.
Parameters:
hostnameVerifier - The new verifier.

setSSLSocketFactory

public void setSSLSocketFactory(SSLSocketFactory factory)
Sets the SSL socket factory for this instance.
Parameters:
factory - The new factory.