public abstract class SSLSocketFactory extends SocketFactory
SSLSocketFactory创建
SSLSocket s。
SSLSocket
| Constructor and Description |
|---|
SSLSocketFactory()
构造方法仅由子类使用。
|
| Modifier and Type | Method and Description |
|---|---|
Socket |
createSocket(Socket s, InputStream consumed, boolean autoClose)
创建服务器模式 Socket分层在现有连接的套接字上,并且能够读取已经从Socket的底层InputStream中消耗/删除的数据。
|
abstract Socket |
createSocket(Socket s, String host, int port, boolean autoClose)
返回在给定端口上分层连接到指定主机的现有套接字上的套接字。
|
static SocketFactory |
getDefault()
返回默认的SSL套接字工厂。
|
abstract String[] |
getDefaultCipherSuites()
返回默认启用的密码套件列表。
|
abstract String[] |
getSupportedCipherSuites()
返回可以在SSL连接上使用的密码套件的名称。
|
createSocket, createSocket, createSocket, createSocket, createSocketpublic static SocketFactory getDefault()
第一次调用此方法时,会检查安全属性“ssl.SocketFactory.provider”。 如果它是非空的,则加载并实例化该名称的类。 如果这是成功的,并且该对象是SSLSocketFactory的实例,则它将成为默认的SSL套接字工厂。
否则,此方法返回SSLContext.getDefault().getSocketFactory() 。 如果该通话失败,则返回不工作的工厂。
SocketFactory
SSLContext.getDefault()
public abstract String[] getDefaultCipherSuites()
getSupportedCipherSuites()
public abstract String[] getSupportedCipherSuites()
getDefaultCipherSuites()
public abstract Socket createSocket(Socket s, String host, int port, boolean autoClose) throws IOException
s - 现有套接字
host - 服务器主机
port - 服务器端口
autoClose - 当此套接字关闭时关闭底层套接字
IOException - 创建套接字时是否发生I / O错误
NullPointerException - 如果参数s为空
public Socket createSocket(Socket s, InputStream consumed, boolean autoClose) throws IOException
Socket分层在现有连接的套接字上,并且能够读取已经从Socket的底层InputStream中消耗/删除的数据。
这种方法可以由需要观察入站数据的服务器应用程序使用,但仍然会创建有效的SSL / TLS连接:例如检查服务器名称指示(SNI)扩展(见第TLS Extensions (RFC6066)段 )。 已经从底层InputStream中删除的数据应该在调用此方法之前加载到consumed流中,也许使用ByteArrayInputStream 。 当此Socket开始握手,将读取的所有数据在consumed ,直到它到达EOF ,则所有的进一步的数据从底层读InputStream如常。
返回的套接字使用为此工厂建立的套接字选项进行配置,并在握手时设置为使用服务器模式(请参阅SSLSocket.setUseClientMode(boolean) )。
s - 现有套接字
consumed - 已经从现有的Socket InputStream中删除的已消耗的入站网络数据。
如果没有数据被删除,此参数可能为null 。
autoClose - 关闭当该套接字关闭时的底层套接字。
Socket符合该工厂建立的套接字选项
IOException - 如果在创建套接字时发生I / O错误
UnsupportedOperationException - 如果底层提供程序不实现该操作
NullPointerException - 如果
s是
null
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.