| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
URL url = …;
HttpsURLConnection con = (HttpsURLConnection)url.openConnection();
Based on 58 examples
public abstract class HttpsURLConnection extends HttpURLConnection
HttpsURLConnection
extends HttpURLConnection
with support for https-specific features.
See http://www.w3.org/pub/WWW/Protocols/ and RFC 2818 for more details on the https specification.
This class uses HostnameVerifier
and
SSLSocketFactory
.
There are default implementations defined for both classes.
However, the implementations can be replaced on a per-class (static) or
per-instance basis. All new HttpsURLConnection
s instances
will be assigned
the "default" static values at instance creation, but they can be overriden
by calling the appropriate per-instance set method(s) before
connect
ing.
Field Summary | |
---|---|
protected HostnameVerifier |
hostnameVerifier
The hostnameVerifier for this object. |
Fields inherited from class java.net.URLConnection |
---|
allowUserInteraction, connected, doInput, doOutput, ifModifiedSince, url, useCaches |
Constructor Summary | |
---|---|
protected |
HttpsURLConnection(URL url) Creates an HttpsURLConnection using the
URL specified.
|
Method Summary | |
---|---|
abstract String |
Returns the cipher suite in use on this connection. |
static HostnameVerifier |
Gets the default HostnameVerifier that is inherited
by new instances of this class.
|
static SSLSocketFactory |
Gets the default static SSLSocketFactory that is
inherited by new instances of this class.
|
HostnameVerifier |
Gets the HostnameVerifier in place on this instance.
|
abstract Certificate[] |
Returns the certificate(s) that were sent to the server during handshaking. |
Principal |
Returns the principal that was sent to the server during handshaking. |
Principal |
Returns the server's principal which was established as part of defining the session. |
abstract Certificate[] |
Returns the server's certificate chain which was established as part of defining the session. |
SSLSocketFactory |
Gets the SSL socket factory to be used when creating sockets for secure https URL connections. |
static void |
Sets the default HostnameVerifier inherited by a
new instance of this class.
|
static void |
Sets the default SSLSocketFactory inherited by new
instances of this class.
|
void |
Sets the HostnameVerifier for this instance.
|
void |
Sets the SSLSocketFactory to be used when this instance
creates sockets for secure https URL connections.
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected HostnameVerifier hostnameVerifier
hostnameVerifier
for this object.
Constructor Detail |
---|
protected HttpsURLConnection(URL url)
HttpsURLConnection
using the
URL specified.
url
- the URLMethod Detail |
---|
public abstract String getCipherSuite()
public static HostnameVerifier getDefaultHostnameVerifier()
HostnameVerifier
that is inherited
by new instances of this class.
public static SSLSocketFactory getDefaultSSLSocketFactory()
SSLSocketFactory
that is
inherited by new instances of this class.
The socket factories are used when creating sockets for secure https URL connections.
SSLSocketFactory
public HostnameVerifier getHostnameVerifier()
HostnameVerifier
in place on this instance.
public abstract Certificate[] getLocalCertificates()
Note: This method is useful only when using certificate-based cipher suites.
When multiple certificates are available for use in a handshake, the implementation chooses what it considers the "best" certificate chain available, and transmits that to the other side. This method allows the caller to know which certificate chain was actually sent.
public Principal getLocalPrincipal()
Note: Subclasses should override this method. If not overridden, it will default to returning the X500Principal of the end-entity certificate that was sent to the server for certificate-based ciphersuites or, return null for non-certificate based ciphersuites, such as Kerberos.
public Principal getPeerPrincipal() throws SSLPeerUnverifiedException
Note: Subclasses should override this method. If not overridden, it will default to returning the X500Principal of the server's end-entity certificate for certificate-based ciphersuites, or throw an SSLPeerUnverifiedException for non-certificate based ciphersuites, such as Kerberos.
SSLPeerUnverifiedException
- if the peer was not verifiedpublic abstract Certificate[] getServerCertificates() throws SSLPeerUnverifiedException
Note: This method can be used only when using certificate-based cipher suites; using it with non-certificate-based cipher suites, such as Kerberos, will throw an SSLPeerUnverifiedException.
SSLPeerUnverifiedException
- if the peer is not verified.public SSLSocketFactory getSSLSocketFactory()
SSLSocketFactory
public static void setDefaultHostnameVerifier(HostnameVerifier v)
HostnameVerifier
inherited by a
new instance of this class.
If this method is not called, the default
HostnameVerifier
assumes the connection should not
be permitted.
v
- the default host name verifierpublic static void setDefaultSSLSocketFactory(SSLSocketFactory sf)
SSLSocketFactory
inherited by new
instances of this class.
The socket factories are used when creating sockets for secure https URL connections.
sf
- the default SSL socket factorypublic void setHostnameVerifier(HostnameVerifier v)
HostnameVerifier
for this instance.
New instances of this class inherit the default static hostname
verifier set by {@link #setDefaultHostnameVerifier(HostnameVerifier)
setDefaultHostnameVerifier}. Calls to this method replace
this object's HostnameVerifier
.
v
- the host name verifierpublic void setSSLSocketFactory(SSLSocketFactory sf)
SSLSocketFactory
to be used when this instance
creates sockets for secure https URL connections.
New instances of this class inherit the default static
SSLSocketFactory
set by
{@link #setDefaultSSLSocketFactory(SSLSocketFactory)
setDefaultSSLSocketFactory}. Calls to this method replace
this object's SSLSocketFactory
.
sf
- the SSL socket factory
| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |