} else {
captchaPassed = true;
}
if (captchaPassed) {
resetCaptchaFields();
CapUserDetails user;
try {
user = (CapUserDetails) userService
.loadUserByUsername(username);
} catch (Exception e) {
throw new CapAuthenticationException(e.getMessage(),
captchaEnabled, forceChangePwd);
}
boolean currentPwdVerified = verifyPassword(username,
authentication.getCredentials().toString(),
user.getPassword());
if (currentPwdVerified) {
setWrountCount(username, 0);
String authedPwd = checkStatus(user, username, password,
policy, captchaEnabled, forceChangePwd);
// 登入成功
setForceChangePwd(username, false);
// 檢核是否要提醒使用者變更密碼
notifyPasswordChange(username, captchaEnabled,
forceChangePwd);
accessControlService.login(username);
return new UsernamePasswordAuthenticationToken(user,
authedPwd, user.getAuthorities());
} else {
setWrountCount(username, getWrountCount(username) + 1);
// 連錯 N 次,enable captcha
if (wrongCount >= Integer.parseInt(policy
.get(PwdPloicyKeys.PWD_CAPTCHA_ENABLE.toString()