public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
String username = (String) token.getPrincipal();
AtomicInteger retryCount = passwordRetryCache.get(username);
if (retryCount == null) {
retryCount = new AtomicInteger(0);
passwordRetryCache.put(username, retryCount);
}
if (retryCount.get() >= 5) {
throw new ExcessiveAttemptsException("该账号已被锁定!");
}
boolean matches = super.doCredentialsMatch(token, info);
if (!matches) {
int number = 5 - retryCount.addAndGet(1);
System.out.println(retryCount.get() + ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
throw new ExcessiveAttemptsException("密码错误,还可以尝试" + number + "次!");
}
//clear retry count
passwordRetryCache.remove(username);
return true;
}
当断点开启时,执行一行代码 retryCount 就+1
不打断点,就是正常。
String username = (String) token.getPrincipal();
AtomicInteger retryCount = passwordRetryCache.get(username);
if (retryCount == null) {
retryCount = new AtomicInteger(0);
passwordRetryCache.put(username, retryCount);
}
if (retryCount.get() >= 5) {
throw new ExcessiveAttemptsException("该账号已被锁定!");
}
boolean matches = super.doCredentialsMatch(token, info);
if (!matches) {
int number = 5 - retryCount.addAndGet(1);
System.out.println(retryCount.get() + ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
throw new ExcessiveAttemptsException("密码错误,还可以尝试" + number + "次!");
}
//clear retry count
passwordRetryCache.remove(username);
return true;
}
当断点开启时,执行一行代码 retryCount 就+1
不打断点,就是正常。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货