2

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からコードを取得したので

4

1 に答える 1

2

StartTLSResponse クラスは抽象クラスであり、そのネゴシエートやクローズなどのメソッドは抽象であるためです。このメソッドを実装する必要がありますか

いいえ。すでにそれを行っているクラスの具体的なインスタンスを取得します。

または単に上記のコードを使用すると機能します。

コードは機能します。昨日やってみました。

于 2013-09-18T10:21:11.570 に答える