我在我的代码中使用以下代码来启用 ldap 上的 tls。
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;
我的问题是因为 StartTLSResponse 类是抽象类,它的协商和关闭方法是抽象的。我需要实现这个方法还是简单地使用上面的代码就可以了。
因为我从 http://docs.oracle.com/javase/7/docs/api/javax/naming/ldap/StartTlsResponse.html#close%28%29得到代码