| | |
| | | FacesUtils.warn("用户名不存在"); |
| | | return null; |
| | | } catch (ExcessiveAttemptsException e) { |
| | | FacesUtils.warn("登陆失败,密码连续输入错误超过5次,锁定5分钟!"); |
| | | FacesUtils.warn("登陆失败,密码连续输入错误超过8次,锁定1分钟!"); |
| | | return null; |
| | | } catch (Exception e) { |
| | | logger.error("登陆失败", e); |
| | |
| | | retryCount = new AtomicInteger(0); |
| | | passwordRetryCache.put(username, retryCount); |
| | | } |
| | | if(retryCount.incrementAndGet() > 5) { |
| | | if(retryCount.incrementAndGet() > 8) { |
| | | //if retry count > 5 throw |
| | | logger.warn("username: " + username + " tried to login more than 5 times in period"); |
| | | logger.warn("username: " + username + " tried to login more than 8 times in period"); |
| | | // FacesUtils.warn("用户名: " + username + " 密码连续输入错误超过5次,锁定5分钟!"); |
| | | throw new ExcessiveAttemptsException("用户名: " + username + " 密码连续输入错误超过5次,锁定5分钟!"); |
| | | throw new ExcessiveAttemptsException("用户名: " + username + " 密码连续输入错误超过8次,锁定1分钟!"); |
| | | } |
| | | |
| | | boolean matches = super.doCredentialsMatch(authcToken, info); |
| | |
| | | statistics="true"> |
| | | </cache> |
| | | |
| | | <!-- 缓存1min --> |
| | | <cache name="oneMin" |
| | | maxElementsInMemory="10000" |
| | | maxElementsOnDisk="100000" |
| | | eternal="false" |
| | | timeToIdleSeconds="60" |
| | | timeToLiveSeconds="60" |
| | | overflowToDisk="false" |
| | | diskPersistent="false" /> |
| | | |
| | | <!-- 缓存5min --> |
| | | <cache name="fivMin" |
| | | maxElementsInMemory="10000" |
| | |
| | | <!-- 密码错误5次锁定5min --> |
| | | <bean id="credentialsMatcher" class="com.nanometer.smartlab.realm.RetryLimitCredentialsMatcher"> |
| | | <constructor-arg ref="shiroSpringCacheManager"/> |
| | | <property name="retryLimitCacheName" value="fivMin"/> |
| | | <property name="retryLimitCacheName" value="oneMin"/> |
| | | <!-- 密码加密 1次md5,增强密码可修改此处 --> |
| | | <property name="hashAlgorithmName" value="MD5"/> |
| | | <property name="storedCredentialsHexEncoded" value="true"/> |