- java.lang.Object
-
- com.sun.security.auth.module.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
ではUnixPrincipal
、UnixNumericUserPrincipal
、および関連する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.
-
-
フィールドのサマリー
フィールド 修飾子と型 フィールド 説明 String
GROUP_PROVIDER
String
USER_PROVIDER
JNDI Provider
-
コンストラクタのサマリー
コンストラクタ コンストラクタ 説明 JndiLoginModule()
-
メソッドのサマリー
すべてのメソッド インスタンス・メソッド 具象メソッド 修飾子と型 メソッド 説明 boolean
abort()
このメソッドは、LoginContextの全体の認証に失敗した場合に呼び出されます。boolean
commit()
認証プロセスをコミットする抽象メソッドです(フェーズ2)。void
initialize(Subject subject, CallbackHandler callbackHandler, Map<String,?> sharedState, Map<String,?> options)
このLoginModule
を初期化します。boolean
login()
ユーザー名とパスワードの入力を要求します。boolean
logout()
ユーザーをログアウトさせます。
-
-
-
メソッドの詳細
-
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
メソッドによって保存された、非公開状態を取得することでチェックされる)した場合は、UnixPrincipal
とLoginModule
内の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
- ログアウトに失敗した場合。
-
-