代码正在尝试针对LDAP服务器进行身份验证。当用户的密码或帐户过期时,它必须抛出错误。
当我尝试使用过期的密码/帐户登录时,会抛出FailedLoginException
:
FailedLoginException! Password Incorrect/Password Required.
文档说明它应该抛出AccountExpiredException
或CredentialExpiredException
。
如何找到密码或帐户是否已过期?
以下是我的代码(简化)。
//Create login context
LoginContext lc = null;
try {
lc = new LoginContext("applicationPolicyName", new UsernamePasswordHandler(username, password));
} catch(LoginException le) {
log.info("LoginContext cannot be created. "+ le.getMessage());
} catch(SecurityException se) {
log.info("LoginContext cannot be created. "+ se.getMessage());
}
try {
lc.login();
} catch (AccountExpiredException e) {
log.info("AccountExpiredException!. "+ e.getMessage());
} catch (CredentialExpiredException e) {
log.info("CredentialExpiredException!. "+ e.getMessage());
} catch (FailedLoginException e) {
log.info("FailedLoginException!. "+ e.getMessage());
} catch(LoginException le) {
log.info("Authentication failed. " + le.getMessage());
}