java - 通过 TLS 实现 LDAP

标签 java ssl

我在代码中使用以下代码来通过 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/

相关文章:

c# - 在 SslStream 中禁用不安全的重新协商

java - catalina.out 连续记录相同的错误

Apache 向非 SSL 站点提供内容

java - Ajax 不会在 wicket 中实现 ListView

Java - 使 jCheckBox 不可选中,反之亦然,而不禁用它

javascript - 对前端和后端使用相同的 mkcert 证书可以吗?

ssl - Indy 底层错误 14094416 :SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown 到底是什么意思

java - 从 Cocoa 应用程序调用 Java 程序

java - Jackson:反序列化枚举

java - 我想用java读取excel中的特定行