Class HttpsURLConnection
- java.lang.Object
-
- java.net.URLConnection
-
- java.net.HttpURLConnection
-
- javax.net.ssl.HttpsURLConnection
-
- Direct Known Subclasses:
HttpsURLConnectionImpl
public abstract class HttpsURLConnection extends HttpURLConnection
HttpsURLConnectionextendsHttpURLConnectionwith 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
HostnameVerifierandSSLSocketFactory. There are default implementations defined for both classes. However, the implementations can be replaced on a per-class (static) or per-instance basis. All newHttpsURLConnections 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) beforeconnecting.- Since:
- 1.4
-
-
Field Summary
-
Fields inherited from class java.net.HttpURLConnection
chunkLength, fixedContentLength, fixedContentLengthLong, 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_UNAUTHORIZED, HTTP_UNAVAILABLE, HTTP_UNSUPPORTED_TYPE, HTTP_USE_PROXY, HTTP_VERSION, instanceFollowRedirects, method, responseCode, responseMessage
-
Fields inherited from class java.net.URLConnection
allowUserInteraction, connected, doInput, doOutput, url, useCaches
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedHttpsURLConnection(URL url)Creates anHttpsURLConnectionusing the URL specified.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SSLSocketFactorygetDefaultSSLSocketFactory()Gets the default staticSSLSocketFactorythat is inherited by new instances of this class.SSLSocketFactorygetSSLSocketFactory()Gets the SSL socket factory to be used when creating sockets for secure https URL connections.static voidsetDefaultSSLSocketFactory(SSLSocketFactory sf)Sets the defaultSSLSocketFactoryinherited by new instances of this class.voidsetSSLSocketFactory(SSLSocketFactory sf)Sets theSSLSocketFactoryto be used when this instance creates sockets for secure https URL connections.-
Methods inherited from class java.net.HttpURLConnection
disconnect, getErrorStream, getFollowRedirects, getHeaderField, getHeaderFieldKey, getInstanceFollowRedirects, getPermission, getRequestMethod, getResponseCode, getResponseMessage, setChunkedStreamingMode, setFixedLengthStreamingMode, setFixedLengthStreamingMode, setFollowRedirects, setInstanceFollowRedirects, setRequestMethod, usingProxy
-
Methods inherited from class java.net.URLConnection
addRequestProperty, connect, getAllowUserInteraction, getConnectTimeout, getContent, getContent, getContentEncoding, getContentLength, getContentLengthLong, getContentType, getDefaultAllowUserInteraction, getDefaultUseCaches, getDoInput, getDoOutput, getHeaderField, getHeaderFieldInt, getHeaderFieldLong, getHeaderFields, getInputStream, getOutputStream, getReadTimeout, getRequestProperties, getRequestProperty, getURL, getUseCaches, setAllowUserInteraction, setConnectTimeout, setContentHandlerFactory, setDefaultAllowUserInteraction, setDefaultUseCaches, setDoInput, setDoOutput, setReadTimeout, setRequestProperty, setUseCaches, toString
-
-
-
-
Constructor Detail
-
HttpsURLConnection
protected HttpsURLConnection(URL url)
Creates anHttpsURLConnectionusing the URL specified.- Parameters:
url- the URL
-
-
Method Detail
-
setDefaultSSLSocketFactory
public static void setDefaultSSLSocketFactory(SSLSocketFactory sf)
Sets the defaultSSLSocketFactoryinherited by new instances of this class.The socket factories are used when creating sockets for secure https URL connections.
- Parameters:
sf- the default SSL socket factory- Throws:
IllegalArgumentException- if the SSLSocketFactory parameter is null.SecurityException- if a security manager exists and itscheckSetFactorymethod does not allow a socket factory to be specified.- See Also:
getDefaultSSLSocketFactory()
-
getDefaultSSLSocketFactory
public static SSLSocketFactory getDefaultSSLSocketFactory()
Gets the default staticSSLSocketFactorythat is inherited by new instances of this class.The socket factories are used when creating sockets for secure https URL connections.
- Returns:
- the default
SSLSocketFactory - See Also:
setDefaultSSLSocketFactory(SSLSocketFactory)
-
setSSLSocketFactory
public void setSSLSocketFactory(SSLSocketFactory sf)
Sets theSSLSocketFactoryto be used when this instance creates sockets for secure https URL connections.New instances of this class inherit the default static
SSLSocketFactoryset bysetDefaultSSLSocketFactory. Calls to this method replace this object'sSSLSocketFactory.- Parameters:
sf- the SSL socket factory- Throws:
IllegalArgumentException- if theSSLSocketFactoryparameter is null.SecurityException- if a security manager exists and itscheckSetFactorymethod does not allow a socket factory to be specified.- See Also:
getSSLSocketFactory()
-
getSSLSocketFactory
public SSLSocketFactory getSSLSocketFactory()
Gets the SSL socket factory to be used when creating sockets for secure https URL connections.- Returns:
- the
SSLSocketFactory - See Also:
setSSLSocketFactory(SSLSocketFactory)
-
-