org.apache.shiro.biz.authc.credential.CredentialsRetryLimitCredentialsMatcher Maven / Gradle / Ivy
The newest version!
/*
* Copyright (c) 2018 (https://github.com/hiwepy).
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.apache.shiro.biz.authc.credential;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.ExcessiveAttemptsException;
import org.apache.shiro.authc.credential.HashedCredentialsMatcher;
import org.apache.shiro.cache.Cache;
import org.apache.shiro.cache.CacheManager;
import java.util.concurrent.atomic.AtomicInteger;
/**
* 密码校验器,支持重复提交次数校验,防范暴力破解
* @author hiwepy
*/
public class CredentialsRetryLimitCredentialsMatcher extends HashedCredentialsMatcher {
/**
* The default active retry times cache name, equal to {@code shiro-activeSessionCache}.
*/
public static final String CREDENTIALS_RETRY_CACHE_NAME = "shiro-credentialsRetryCache";
public static final int CREDENTIALS_RETRY_TIMES_LIMIT = 5;
/**
* The CacheManager to use to acquire the retry times.
*/
private CacheManager cacheManager;
/**
* The Cache instance responsible for caching retry times.
*/
private Cache