javax.net.ssl
public abstract class HttpsURLConnection extends HttpURLConnection
This class may be used in the same way as HttpURLConnection
, and it will transparently negotiate the SSL
connection.
Modifier and Type | Field and Description |
---|---|
protected HostnameVerifier |
hostnameVerifier
The hostname verifier used for this connection.
|
HTTP_ACCEPTED, HTTP_BAD_GATEWAY, HTTP_BAD_METHOD, HTTP_BAD_REQUEST, HTTP_CLIENT_TIMEOUT, HTTP_CONFLICT, HTTP_CREATED, HTTP_ENTITY_TOO_LARGE, HTTP_FORBIDDEN, HTTP_GATEWAY_TIMEOUT, HTTP_GONE, HTTP_INTERNAL_ERROR, HTTP_LENGTH_REQUIRED, HTTP_MOVED_PERM, HTTP_MOVED_TEMP, HTTP_MULT_CHOICE, HTTP_NO_CONTENT, HTTP_NOT_ACCEPTABLE, HTTP_NOT_AUTHORITATIVE, HTTP_NOT_FOUND, HTTP_NOT_IMPLEMENTED, HTTP_NOT_MODIFIED, HTTP_OK, HTTP_PARTIAL, HTTP_PAYMENT_REQUIRED, HTTP_PRECON_FAILED, HTTP_PROXY_AUTH, HTTP_REQ_TOO_LONG, HTTP_RESET, HTTP_SEE_OTHER, HTTP_SERVER_ERROR, HTTP_UNAUTHORIZED, HTTP_UNAVAILABLE, HTTP_UNSUPPORTED_TYPE, HTTP_USE_PROXY, HTTP_VERSION, instanceFollowRedirects, method, responseCode, responseMessage
allowUserInteraction, connected, doInput, doOutput, ifModifiedSince, url, useCaches
Modifier | Constructor and Description |
---|---|
protected |
HttpsURLConnection(URL url)
Creates a new HTTPS URL connection.
|
Modifier and Type | Method and Description |
---|---|
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.
|
Principal |
getLocalPrincipal()
Returns the local principal for this connection.
|
Principal |
getPeerPrincipal()
Returns the remote peer's principal for this connection.
|
abstract Certificate[] |
getServerCertificates()
Returns the certificates sent by the other party.
|
SSLSocketFactory |
getSSLSocketFactory()
Returns the current SSL socket factory for this instance.
|
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.
|
disconnect, getErrorStream, getFollowRedirects, getHeaderFieldDate, getInstanceFollowRedirects, getPermission, getRequestMethod, getResponseCode, getResponseMessage, setFollowRedirects, setInstanceFollowRedirects, setRequestMethod, usingProxy
addRequestProperty, connect, getAllowUserInteraction, getConnectTimeout, getContent, getContent, getContentEncoding, getContentLength, getContentType, getDate, getDefaultAllowUserInteraction, getDefaultRequestProperty, getDefaultUseCaches, getDoInput, getDoOutput, getExpiration, getFileNameMap, getHeaderField, getHeaderField, getHeaderFieldInt, getHeaderFieldKey, getHeaderFields, getIfModifiedSince, getInputStream, getLastModified, getOutputStream, getReadTimeout, getRequestProperties, getRequestProperty, getURL, getUseCaches, guessContentTypeFromName, guessContentTypeFromStream, setAllowUserInteraction, setConnectTimeout, setContentHandlerFactory, setDefaultAllowUserInteraction, setDefaultRequestProperty, setDefaultUseCaches, setDoInput, setDoOutput, setFileNameMap, setIfModifiedSince, setReadTimeout, setRequestProperty, setUseCaches, toString
protected HostnameVerifier hostnameVerifier
protected HttpsURLConnection(URL url)
url
- The URL of the connection being established.public static HostnameVerifier getDefaultHostnameVerifier()
public static void setDefaultHostnameVerifier(HostnameVerifier newDefault)
newDefault
- The new default hostname verifier.IllegalArgumentException
- If newDefault is null.SecurityException
- If there is a security manager
currently installed and the caller does not have the SSLPermission
"setHostnameVerifier".public static SSLSocketFactory getDefaultSSLSocketFactory()
public static void setDefaultSSLSocketFactory(SSLSocketFactory newDefault)
newDefault
- The new socket factory.IllegalArgumentException
- If newDefault is null.SecurityException
- If there is a security manager
installed and a call to SecurityManager.checkSetFactory()
fails.public HostnameVerifier getHostnameVerifier()
public void setHostnameVerifier(HostnameVerifier hostnameVerifier)
hostnameVerifier
- The new verifier.IllegalArgumentException
- If hostnameVerifier is
null.public SSLSocketFactory getSSLSocketFactory()
public void setSSLSocketFactory(SSLSocketFactory factory)
factory
- The new factory.IllegalArgumentException
- If factory is null.public Principal getLocalPrincipal()
The default implementation will return the javax.security.x500.X500Principal
for the end entity certificate
in the local certificate chain if those certificates are of type
X509Certificate
. Otherwise, this
method returns null
.
public Principal getPeerPrincipal() throws SSLPeerUnverifiedException
The default implementation will return the javax.security.x500.X500Principal
for the end entity certificate
in the remote peer's certificate chain if those certificates are
of type X509Certificate
. Otherwise,
this method returns null
.
SSLPeerUnverifiedException
- If the remote peer has not
been verified.public abstract String getCipherSuite()
IllegalStateException
- If the connection has not yet been
established.public abstract Certificate[] getLocalCertificates()
IllegalStateException
- If the connection has not yet been
established.public abstract Certificate[] getServerCertificates() throws SSLPeerUnverifiedException
IllegalStateException
- If the connection has not yet been
established.SSLPeerUnverifiedException
- If the peer could not be
verified.