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_urlname_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()
ユーザーをログアウトさせます。
|
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
で指定されたオプション。public boolean login() throws LoginException
ユーザー名とパスワードの入力を要求します。関連するネームサービスで入力されたパスワードを確認します。
login
、インタフェース: LoginModule
LoginModule
を無視してはならないため、常に true。FailedLoginException
- 認証に失敗した場合。 LoginException
- この LoginModule
で認証が実行できない場合。public boolean commit() throws LoginException
LoginContext の認証全体が成功した場合 (関連する REQUIRED、REQUISITE、SUFFICIENT、および OPTIONAL の各 LoginModule が成功した場合) に呼び出されます。
この LoginModule 自体の認証が成功 (login
メソッドによって保存された、非公開状態を取得することでチェックされる) した場合は、UnixPrincipal
と LoginModule
内の Subject
とが関連付けられます。この LoginModule 自体の認証が失敗した場合は、当初保存された状態を削除します。
commit
、インタフェース: LoginModule
LoginException
- コミットに失敗した場合public boolean abort() throws LoginException
このメソッドは、LoginContext の全体の認証に失敗した場合に呼び出されます。(関連する REQUIRED、REQUISITE、SUFFICIENT、および OPTIONAL の各 LoginModule が失敗した場合)。
この LoginModule 自体の認証が成功した場合は (login
メソッドと commit
メソッドによって保存された非公開状態を取得して調べる)、当初保存された状態を整理します。
abort
、インタフェース: LoginModule
LoginException
- 中止に失敗した場合。public boolean logout() throws LoginException
commit
メソッドで追加された主体を削除します。
logout
、インタフェース: LoginModule
LoginModule
を無視してはならないため、常に true。LoginException
- ログアウトに失敗した場合。
Copyright © 1998, 2013, Oracle and/or its affiliates. All rights reserved.