モジュール java.security.sasl
パッケージ javax.security.sasl

インタフェースSaslServer


public interface SaslServer
SASL認証をサーバーとして実行します。

LDAPサーバーのようなサーバーは、特定のSASLメカニズムによって定義された認証を実行するために、このクラスのインスタンスを取得します。 SaslServerインスタンスに対するメソッドを呼び出すと、SaslServerによって実装されたSASLメカニズムに従ってチャレンジが作成されます。 認証が処理されるときに、SASLサーバーの認証交換の状態が暗号化されます。

次に、LDAPサーバーがどのようにSaslServerを使用するかの例を示します。 まず、クライアントによって要求されたSASLメカニズムのSaslServerインスタンスを取得します。

 SaslServer ss = Sasl.createSaslServer(mechanism,
     "ldap", myFQDN, props, callbackHandler);
 
これで、サーバーを認証に使用できます。 たとえば、LDAPサーバーがSASLメカニズムの名前と初期応答(オプション)を含むLDAP BIND要求を受信したとします。 このとき、サーバーを次のように使用できます。

 while (!ss.isComplete()) {
     try {
         byte[] challenge = ss.evaluateResponse(response);
         if (ss.isComplete()) {
             status = ldap.sendBindResponse(mechanism, challenge, SUCCESS);
         } else {
             status = ldap.sendBindResponse(mechanism, challenge,
                 SASL_BIND_IN_PROGRESS);
             response = ldap.readBindRequest();
         }
     } catch (SaslException e) {
         status = ldap.sendErrorResponse(e);
         break;
     }
 }
 if (ss.isComplete() && status == SUCCESS) {
     String qop = (String) sc.getNegotiatedProperty(Sasl.QOP);
     if (qop != null
         && (qop.equalsIgnoreCase("auth-int")
             || qop.equalsIgnoreCase("auth-conf"))) {

         // Use SaslServer.wrap() and SaslServer.unwrap() for future
         // communication with client
         ldap.in = new SecureInputStream(ss, ldap.in);
         ldap.out = new SecureOutputStream(ss, ldap.out);
     }
 }
 

導入されたバージョン:
1.5
関連項目: