我在代码中使用以下代码来通过 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
最佳答案
since the StartTLSResponse class is abstract class and its methods like negotiate and close are abstract. Do i need to implement this methods
没有。您将获得已经执行此操作的类的具体实例。
or simply using the above code will work.
代码有效。我昨天试过了。
关于java - 通过 TLS 实现 LDAP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18869437/