@Exported 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, 2018, Oracle and/or its affiliates. All rights reserved.