モジュール jdk.security.auth

クラスJndiLoginModule

  • すべての実装されたインタフェース:
    LoginModule


    public class JndiLoginModule
    extends Object
    implements LoginModule
    ユーザー名とパスワードの入力を要求し、JNDI下で構成されたディレクトリ・サービスに格納されているパスワードで、入力されたパスワードを確認します。

    このLoginModuleは、仕様に準拠したJNDIサービス・プロバイダと相互運用します。 特定のJNDIサービス・プロバイダを使用するためにこのLoginModuleを構成するには、このLoginModuleのログインConfigurationで2つのオプションを指定する必要があります。

          user.provider.url=name_service_url
          group.provider.url=name_service_url
     
    name_service_urlには、このLoginModuleが関連するユーザーとグループの情報にアクセスするための、ディレクトリ・サービスとパスを指定します。 このLoginModuleでは関連ユーザー情報の検索に単一レベル検索を実行するだけなので、ディレクトリ・サービスでユーザーとグループの情報が格納されているディレクトリの1レベル上をURLで指している必要があります。 たとえば、NISサーバーに接続するようにこのLoginModuleを構成するには、次のURLを指定する必要があります。
        user.provider.url="nis://NISServerHostName/NISDomain/user"
        group.provider.url="nis://NISServerHostName/NISDomain/system/group"
     
    NISServerHostNameはNISサーバーのサーバー・ホスト名(nis.sun.comなど)、NISDomainはそのNISサーバーのドメイン(jaas.sun.comなど)を指定します。 LDAPサーバーにアクセスするには、次のURLを指定します。
        user.provider.url="ldap://LDAPServerHostName/LDAPName"
        group.provider.url="ldap://LDAPServerHostName/LDAPName"
     
    LDAPServerHostNameはLDAPサーバーのホスト名でポート番号を含むことがあり(ldap.sun.com:389など)、LDAPNameはLDAPディレクトリでのエントリ名(ユーザー情報はou=People,o=Sun,c=US、グループ情報はou=Groups,o=Sun,c=USなど)になります。

    ディレクトリ・サービスに格納されるユーザー情報の形式はRFC 2307で規定されています。 具体的には、このLoginModuleは、ユーザーのuid属性を使用してディレクトリ・サービスでユーザーのエントリを検索します(ここでuid=username)。 検索が成功すると、このLoginModuleによってuserPassword属性を使用して取得したエントリから、ユーザーの暗号化されたパスワードが入手されます。 このLoginModuleでは、パスワードがバイト配列で格納されていると想定されています。パスワードはStringに変換すると次の形式になります。

          "{crypt}encrypted_password"
     
    LDAPディレクトリ・サーバーは、userPassword属性の読取りアクセスが許可されるように構成する必要があります。 ユーザーが有効なユーザー名とパスワードを入力すると、このLoginModuleではUnixPrincipalUnixNumericUserPrincipal、および関連するUnixNumericGroupPrincipalsをSubjectと関連付けます。

    このLoginModuleは、次のConfigurationオプションも認識します。

        debug          if, true, debug messages are output to System.out.
    
        useFirstPass   if, true, this LoginModule retrieves the
                       username and password from the module's shared state,
                       using "javax.security.auth.login.name" and
                       "javax.security.auth.login.password" as the respective
                       keys.  The retrieved values are used for authentication.
                       If authentication fails, no attempt for a retry is made,
                       and the failure is reported back to the calling
                       application.
    
        tryFirstPass   if, true, this LoginModule retrieves the
                       the username and password from the module's shared state,
                       using "javax.security.auth.login.name" and
                       "javax.security.auth.login.password" as the respective
                       keys.  The retrieved values are used for authentication.
                       If authentication fails, the module uses the
                       CallbackHandler to retrieve a new username and password,
                       and another attempt to authenticate is made.
                       If the authentication fails, the failure is reported
                       back to the calling application.
    
        storePass      if, true, this LoginModule stores the username and password
                       obtained from the CallbackHandler in the module's
                       shared state, using "javax.security.auth.login.name" and
                       "javax.security.auth.login.password" as the respective
                       keys.  This is not performed if existing values already
                       exist for the username and password in the shared state,
                       or if authentication fails.
    
        clearPass     if, true, this LoginModule clears the
                      username and password stored in the module's shared state
                      after both phases of authentication (login and commit)
                      have completed.
     
    • コンストラクタの詳細

      • JndiLoginModule

        public JndiLoginModule​()
    • メソッドの詳細

      • initialize

        public void initialize​(Subject subject,
                               CallbackHandler callbackHandler,
                               Map<String,?> sharedState,
                               Map<String,?> options)
        このLoginModuleを初期化します。
        定義:
        initialize 、インタフェース: LoginModule
        パラメータ:
        subject - 認証対象のSubject
        callbackHandler - エンド・ユーザーとの通信(ユーザー名とパスワードの入力など)に使用されるCallbackHandler
        sharedState - 共有LoginModuleの状態。
        options - このLoginModule用にログインConfigurationで指定されたオプション。
      • login

        public boolean login​()
                      throws LoginException
        ユーザー名とパスワードの入力を要求します。 関連するネーム・サービスで入力されたパスワードを確認します。
        定義:
        login 、インタフェース: LoginModule
        戻り値:
        このLoginModuleを無視してはならないため、常にtrue。
        例外:
        FailedLoginException - 認証に失敗した場合。
        LoginException - このLoginModuleで認証が実行できない場合。
      • commit

        public boolean commit​()
                       throws LoginException
        認証プロセスをコミットする抽象メソッドです(フェーズ2)。

        LoginContextの認証全体が成功した場合(関連するREQUIRED、REQUISITE、SUFFICIENT、およびOPTIONALの各LoginModuleが成功した場合)に呼び出されます。

        このLoginModule自体の認証が成功(loginメソッドによって保存された、非公開状態を取得することでチェックされる)した場合は、UnixPrincipalLoginModule内のSubjectとが関連付けられます。 このLoginModule自体の認証が失敗した場合は、当初保存された状態を削除します。

        定義:
        commit 、インタフェース: LoginModule
        戻り値:
        このLoginModule自体のログインとコミットの試みが成功した場合はtrue、そうでない場合はfalse。
        例外:
        LoginException - コミットに失敗した場合
      • abort

        public boolean abort​()
                      throws LoginException
        このメソッドは、LoginContextの全体の認証に失敗した場合に呼び出されます。(関連するREQUIRED、REQUISITE、SUFFICIENT、およびOPTIONALの各LoginModuleが失敗した場合)。

        このLoginModule自体の認証が成功した場合は(loginメソッドとcommitメソッドによって保存された非公開状態を取得して調べる)、当初保存された状態を整理します。

        定義:
        abort 、インタフェース: LoginModule
        戻り値:
        このLoginModule自体のログインやコミットの試みが失敗した場合はfalse、そうでない場合はtrue。
        例外:
        LoginException - 中止に失敗した場合。
      • logout

        public boolean logout​()
                       throws LoginException
        ユーザーをログアウトさせます。

        commitメソッドで追加された主体を削除します。

        定義:
        logout 、インタフェース: LoginModule
        戻り値:
        このLoginModuleを無視してはならないため、常にtrue。
        例外:
        LoginException - ログアウトに失敗した場合。