public abstract class HttpsURLConnection extends HttpURLConnection
HttpsURLConnection延伸
HttpURLConnection与特定功能支持HTTPS。
见的HTTPS规范更多的细节 http://www.w3.org/pub/WWW/Protocols/和 RFC 2818 。
这类使用HostnameVerifier和SSLSocketFactory。有两类定义的默认实现。然而,实现可以被替换为一个类(静态)或每一个实例的基础上。所有新的HttpsURLConnections实例将被分配的“默认”的静态值在创建实例,但它们可以被调用适当的每个实例的设置方法(S)在connecting。
| Modifier and Type | Field and Description |
|---|---|
protected HostnameVerifier |
hostnameVerifier
此对象的
hostnameVerifier。
|
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_SERVER_ERROR, HTTP_UNAUTHORIZED, HTTP_UNAVAILABLE, HTTP_UNSUPPORTED_TYPE, HTTP_USE_PROXY, HTTP_VERSION, instanceFollowRedirects, method, responseCode, responseMessageallowUserInteraction, connected, doInput, doOutput, ifModifiedSince, url, useCaches| Modifier | Constructor and Description |
|---|---|
protected |
HttpsURLConnection(URL url)
创建一个
HttpsURLConnection使用指定的URL。
|
| Modifier and Type | Method and Description |
|---|---|
abstract String |
getCipherSuite()
返回此连接使用的密码套件。
|
static HostnameVerifier |
getDefaultHostnameVerifier()
获取默认
HostnameVerifier是由这类的新实例继承。
|
static SSLSocketFactory |
getDefaultSSLSocketFactory()
获取默认静态
SSLSocketFactory是由这类的新实例继承。
|
HostnameVerifier |
getHostnameVerifier()
得到
HostnameVerifier到位这个实例。
|
abstract Certificate[] |
getLocalCertificates()
返回证书(S),在握手时发送到服务器。
|
Principal |
getLocalPrincipal()
返回主是在握手时发送到服务器。
|
Principal |
getPeerPrincipal()
返回服务器的主要部分,这是作为定义会话的一部分而建立的。
|
abstract Certificate[] |
getServerCertificates()
返回作为定义会话的一部分而建立的服务器的证书链。
|
SSLSocketFactory |
getSSLSocketFactory()
获取SSL套接字工厂来创建安全的HTTPS URL连接插座使用时。
|
static void |
setDefaultHostnameVerifier(HostnameVerifier v)
设置默认
HostnameVerifier由这个类的一个新实例继承。
|
static void |
setDefaultSSLSocketFactory(SSLSocketFactory sf)
设置默认
SSLSocketFactory这个类的新实例继承。
|
void |
setHostnameVerifier(HostnameVerifier v)
将此实例的
HostnameVerifier。
|
void |
setSSLSocketFactory(SSLSocketFactory sf)
将此实例创建时使用安全的HTTPS URL连接插座的
SSLSocketFactory。
|
disconnect, getErrorStream, getFollowRedirects, getHeaderField, getHeaderFieldDate, getHeaderFieldKey, getInstanceFollowRedirects, getPermission, getRequestMethod, getResponseCode, getResponseMessage, setChunkedStreamingMode, setFixedLengthStreamingMode, setFixedLengthStreamingMode, setFollowRedirects, setInstanceFollowRedirects, setRequestMethod, usingProxyaddRequestProperty, connect, getAllowUserInteraction, getConnectTimeout, getContent, getContent, getContentEncoding, getContentLength, getContentLengthLong, getContentType, getDate, getDefaultAllowUserInteraction, getDefaultRequestProperty, getDefaultUseCaches, getDoInput, getDoOutput, getExpiration, getFileNameMap, getHeaderField, getHeaderFieldInt, getHeaderFieldLong, 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, toStringprotected HostnameVerifier hostnameVerifier
hostnameVerifier。
protected HttpsURLConnection(URL url)
HttpsURLConnection使用指定的URL。
url的URL
public abstract String getCipherSuite()
IllegalStateException -如果这种方法之前已建立连接称为。
public abstract Certificate[] getLocalCertificates()
注:此方法仅在使用基于证书的密码套件时是有用的。
当多个证书可用于握手时,实现选择它认为“最好的”证书链可用,并将其发送到另一方。此方法允许调用方知道实际发送的证书链。
IllegalStateException -如果这种方法之前已建立连接称为。
getLocalPrincipal()
public abstract Certificate[] getServerCertificates() throws SSLPeerUnverifiedException
注:此方法可用于只有当使用基于证书的密码套件;使用基于无证书密码套件,如Kerberos,将抛出一个sslpeerunverifiedexception。
SSLPeerUnverifiedException如果同伴未验证。
IllegalStateException -如果这种方法之前已建立连接称为。
getPeerPrincipal()
public Principal getPeerPrincipal() throws SSLPeerUnverifiedException
注:子类应重写此方法。如果不重写,它将默认返回服务器端实体证书的基于证书的密码套件的x500principal,或把基于无证书的密码套件sslpeerunverifiedexception,如Kerberos。
SSLPeerUnverifiedException如果同伴没有验证
IllegalStateException -如果这种方法之前已建立连接称为。
getServerCertificates(),
getLocalPrincipal()
public Principal getLocalPrincipal()
注:子类应重写此方法。如果不重写,它将默认返回的终端实体证书,被派到基于证书的密码套件服务器或x500principal,返回基于无证书无效的密码套件,如Kerberos。
IllegalStateException -如果这种方法之前已建立连接称为。
getLocalCertificates(),
getPeerPrincipal()
public static void setDefaultHostnameVerifier(HostnameVerifier v)
HostnameVerifier由这个类的一个新实例继承。
如果不调用此方法,默认HostnameVerifier假设连接不应允许。
v -默认主机名验证
IllegalArgumentException -如果
HostnameVerifier参数为空。
SecurityException -如果存在一个安全管理及其
checkPermission方法不允许
SSLPermission("setHostnameVerifier")
getDefaultHostnameVerifier()
public static HostnameVerifier getDefaultHostnameVerifier()
HostnameVerifier是由这类的新实例继承。
setDefaultHostnameVerifier(HostnameVerifier)
public void setHostnameVerifier(HostnameVerifier v)
HostnameVerifier。
这一类的新实例继承默认静态主机名验证通过setDefaultHostnameVerifier。调用此方法替换此对象的HostnameVerifier。
v -主机名验证
IllegalArgumentException -如果
HostnameVerifier参数为空。
getHostnameVerifier(),
setDefaultHostnameVerifier(HostnameVerifier)
public HostnameVerifier getHostnameVerifier()
HostnameVerifier到位这个实例。
public static void setDefaultSSLSocketFactory(SSLSocketFactory sf)
SSLSocketFactory这个类的新实例继承。
套接字工厂创建安全的HTTPS URL连接插座使用时。
sf -默认SSL套接字工厂
IllegalArgumentException如果SSLSocketFactory参数为空。
SecurityException -如果存在一个安全管理及其
checkSetFactory方法不允许一个套接字工厂被指定。
getDefaultSSLSocketFactory()
public static SSLSocketFactory getDefaultSSLSocketFactory()
SSLSocketFactory是由这类的新实例继承。
套接字工厂创建安全的HTTPS URL连接插座使用时。
SSLSocketFactory
setDefaultSSLSocketFactory(SSLSocketFactory)
public void setSSLSocketFactory(SSLSocketFactory sf)
SSLSocketFactory。
这一类的新实例继承默认静态SSLSocketFactory由setDefaultSSLSocketFactory。调用此方法替换此对象的SSLSocketFactory。
sf - SSL套接字工厂
IllegalArgumentException -如果
SSLSocketFactory参数为空。
SecurityException -如果存在一个安全管理及其
checkSetFactory方法不允许一个套接字工厂被指定。
getSSLSocketFactory()
public SSLSocketFactory getSSLSocketFactory()
SSLSocketFactory
setSSLSocketFactory(SSLSocketFactory)
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.