public abstract class StartTlsResponse extends Object implements ExtendedResponse
启动TLS扩展请求和响应是用来在现有的LDAP连接JNDI上下文中调用相关的extendedOperation()建立TLS连接。通常,一个JNDI程序使用STARTTLS扩展请求和响应类如下。
import javax.naming.ldap.*; // Open an LDAP association LdapContext ctx = new InitialLdapContext(); // Perform a StartTLS extended operation StartTlsResponse tls = (StartTlsResponse) ctx.extendedOperation(new StartTlsRequest()); // Open a TLS connection (over the existing LDAP association) and get details // of the negotiated TLS session: cipher suite, peer certificate, ... SSLSession session = tls.negotiate(); // ... use ctx to perform protected LDAP operations // Close the TLS connection (revert back to the underlying LDAP association) tls.close(); // ... use ctx to perform unprotected LDAP operations // Close the LDAP association ctx.close;
StartTlsRequest
,
Serialized Form
Modifier and Type | Field and Description |
---|---|
static String |
OID
STARTTLS扩展响应指定的对象标识符是1.3.6.1.4.1.1466.20037。
|
Modifier | Constructor and Description |
---|---|
protected |
StartTlsResponse()
构建了STARTTLS扩展响应。
|
Modifier and Type | Method and Description |
---|---|
abstract void |
close()
关闭TLS连接优雅地恢复到基础连接。
|
byte[] |
getEncodedValue()
检索STARTTLS响应的ASN.1 BER编码的值1。
|
String |
getID()
检索的对象标识符的字符串将响应。
|
abstract SSLSession |
negotiate()
协商TLS会话使用默认SSL套接字工厂。
|
abstract SSLSession |
negotiate(SSLSocketFactory factory)
协商TLS会话使用SSL套接字工厂。
|
abstract void |
setEnabledCipherSuites(String[] suites)
重写密码套件使用TLS连接上启用默认的列表。
|
abstract void |
setHostnameVerifier(HostnameVerifier verifier)
设置主机名在TLS握手完成的
negotiate()使用校验和默认主机名验证失败。
|
public static final String OID
protected StartTlsResponse()
public String getID()
getID
接口
ExtendedResponse
public byte[] getEncodedValue()
getEncodedValue
接口
ExtendedResponse
public abstract void setEnabledCipherSuites(String[] suites)
suites
-非空列表的所有密码套件名称使。
negotiate()
public abstract void setHostnameVerifier(HostnameVerifier verifier)
verifier
-非空主机名验证回调。
negotiate()
public abstract SSLSession negotiate() throws IOException
这种方法相当于negotiate(null)。
IOException
-如果在建立TLS会话中遇到了一个IO错误。
setEnabledCipherSuites(java.lang.String[])
,
setHostnameVerifier(javax.net.ssl.HostnameVerifier)
public abstract SSLSession negotiate(SSLSocketFactory factory) throws IOException
创建使用提供的SSL套接字工厂SSL套接字和附加到现有的连接。执行TLS握手并返回谈判的会议信息。
如果密码套件已通过setEnabledCipherSuites然后TLS握手开始前启用。
主机名验证TLS握手完成后进行。默认主机名验证执行匹配的服务器的主机名和服务器证书中发现主机信息。如果验证失败,没有回调已经通过setHostnameVerifier然后谈判失败。如果验证失败,回调已经通过setHostnameVerifier,然后回调是用来确定谈判是否成功。
如果再发生错误的SSL套接字关闭并引发IOException。底层连接保持完整。
factory
-可能的空SSL套接字工厂使用。如果为空,默认使用SSL套接字工厂。
IOException
-如果在建立TLS会话中遇到了一个IO错误。
setEnabledCipherSuites(java.lang.String[])
,
setHostnameVerifier(javax.net.ssl.HostnameVerifier)
public abstract void close() throws IOException
IOException
如果同时关闭TLS连接时遇到了一个IO错误
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.