예제 #1
0
 /** 清除所有用户授权信息缓存. */
 public void clearAllCachedAuthorizationInfo() {
   Cache<Object, AuthorizationInfo> cache = getAuthorizationCache();
   if (cache != null) {
     for (Object key : cache.keys()) {
       cache.remove(key);
     }
   }
 }
예제 #2
0
 @Test
 public void testRemove() {
   cache.put("1", "one");
   cache.put("2", "two");
   assertEquals(2, cache.size());
   cache.remove("1");
   assertEquals(1, cache.size());
   assertNull(cache.get("1"));
 }
  @Override
  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.incrementAndGet() > 10) {
      throw new ExcessiveAttemptsException(String.valueOf(retryCount.get()));
    }

    boolean matches = super.doCredentialsMatch(token, info);
    if (matches) {
      passwordRetryCache.remove(username);
    }
    return matches;
  }
예제 #4
0
 // 删除菜单
 public void clearMenu(Long roleId) {
   Cache<Object, Object> cache = cacheManager.getCache(MENU_CACHE_KEY);
   cache.remove(roleId);
 }
 public void clearRetryCache(String username) {
   if (username == null) passwordRetryCache.clear();
   else passwordRetryCache.remove(username);
 }