- java.lang.Object
-
- com.sun.security.auth.module.JndiLoginModule
-
- 实现的所有接口
-
LoginModule
public class JndiLoginModule extends Object implements LoginModule
模块会提示输入用户名和密码,然后根据存储在JNDI下配置的目录服务中的密码验证密码。此
LoginModule可与任何符合要求的JNDI服务提供商进行互操作。 要指示此LoginModule使用特定的JNDI服务提供程序,必须在登录Configuration中为此LoginModule指定两个选项。user.provider.url=name_service_url group.provider.url=name_service_urlname_service_url指定此LoginModule可以访问相关用户和组信息的目录服务和路径。 由于此LoginModule仅执行一级搜索以查找相关用户信息,因此URL必须指向上一级目录,其中用户和组信息存储在目录服务中。 例如,要指示此LoginModule联系NIS服务器,必须指定以下URL:user.provider.url="nis://NISServerHostName/NISDomain/user" group.provider.url="nis://NISServerHostName/NISDomain/system/group"NISServerHostName指定NIS服务器的服务器主机名(例如, , NISDomain指定该NIS服务器的域(例如, jaas.sun.com 。要联系LDAP服务器,必须是以下URL)规定:user.provider.url="ldap://LDAPServerHostName/LDAPName" group.provider.url="ldap://LDAPServerHostName/LDAPName"LDAPServerHostName指定LDAP服务器的服务器主机名,可以包含端口号(例如, ), 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,并与相关UnixNumericGroupPrincipalsSubject。此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, thisLoginModuleclears the username and password stored in the module's shared state after both phases of authentication (login and commit) have completed.
-
-
字段汇总
字段 变量和类型 字段 描述 StringGROUP_PROVIDERStringUSER_PROVIDERJNDI提供商
-
构造方法摘要
构造方法 构造器 描述 JndiLoginModule()
-
方法摘要
所有方法 实例方法 具体的方法 变量和类型 方法 描述 booleanabort()如果LoginContext的整体身份验证失败,则调用此方法。booleancommit()提交认证过程的抽象方法(阶段2)。voidinitialize(Subject subject, CallbackHandler callbackHandler, Map<String,?> sharedState, Map<String,?> options)初始化此LoginModule。booleanlogin()提示输入用户名和密码。booleanlogout()注销用户。
-
-
-
方法详细信息
-
initialize
public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String,?> sharedState, Map<String,?> options)
初始化这个LoginModule。- Specified by:
-
initialize接口LoginModule - 参数
-
subject- 要通过身份验证的Subject。 -
callbackHandler- 用于与最终用户通信的CallbackHandler(例如,提示输入用户名和密码)。 -
sharedState- 共享LoginModule州。 -
options- 此特定LoginModule的登录名Configuration指定的选项。
-
login
public boolean login() throws LoginException提示输入用户名和密码。 根据相关名称服务验证密码。- Specified by:
-
login在界面LoginModule - 结果
-
总是如此,因为这个
LoginModule不应该被忽略。 - 异常
-
FailedLoginException- 如果身份验证失败。 -
LoginException- 如果此LoginModule无法执行身份验证。
-
commit
public boolean commit() throws LoginException提交认证过程的抽象方法(阶段2)。如果LoginContext的整体身份验证成功(相关的REQUIRED,REQUISITE,SUFFICIENT和OPTIONAL LoginModules成功),则调用此方法。
如果此LoginModule自己的身份验证尝试成功(通过检索
login方法保存的私有状态进行检查),则此方法将UnixPrincipal与位于Subject中的LoginModule相关联。 如果此LoginModule自己的身份验证尝试失败,则此方法将删除最初保存的任何状态。- Specified by:
-
commit在界面LoginModule - 结果
- 如果此LoginModule自己的登录和提交尝试成功,则返回true,否则返回false。
- 异常
-
LoginException- 如果提交失败
-
abort
public boolean abort() throws LoginException如果LoginContext的整体身份验证失败,则调用此方法。 (相关的必需,要求,充足和可选的LoginModule没有成功)。如果此LoginModule自己的身份验证尝试成功(通过检索由
login和commit方法保存的私有状态进行检查),则此方法将清除最初保存的任何状态。- Specified by:
-
abort在界面LoginModule - 结果
- 如果此LoginModule自己的登录和/或提交尝试失败,则返回false,否则返回true。
- 异常
-
LoginException- 如果中止失败。
-
logout
public boolean logout() throws LoginException注销用户。此方法删除由
commit方法添加的commit。- Specified by:
-
logout在界面LoginModule - 结果
-
在所有情况下
LoginModuletrue,因为不应忽略此LoginModule。 - 异常
-
LoginException- 如果注销失败。
-
-