Java Code Examples for org.apache.shiro.cache.Cache#remove()

The following examples show how to use org.apache.shiro.cache.Cache#remove() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShiroCustomRealm.java    From phone with Apache License 2.0 6 votes vote down vote up
/**
 * 清除所有用户授权信息缓存.
 */
public void clearAllCachedAuthorizationInfo() {
	if (logger.isDebugEnabled()) {
		logger.debug("clearAllCachedAuthorizationInfo() - start"); //$NON-NLS-1$
	}

	Cache<Object, AuthorizationInfo> cache = getAuthorizationCache();
	if (cache != null) {
		for (Object key : cache.keys()) {
			cache.remove(key);
		}
	}

	if (logger.isDebugEnabled()) {
		logger.debug("clearAllCachedAuthorizationInfo() - end"); //$NON-NLS-1$
	}
}
 
Example 2
Source File: CacheDelegator.java    From jsets-shiro-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
/**
 * 清扫账号对应的认证、授权缓存
 */
public void clearAuthCache(String account, String realmName) {
	synchronized (cacheMonitor) {
		Cache<String, AuthenticationInfo> authenticationCache = this.cacheManager
				.getCache(ShiroProperties.CACHE_NAME_AUTHENTICATION);
		Cache<Object, AuthorizationInfo> authorizationCache = this.cacheManager
				.getCache(ShiroProperties.CACHE_NAME_AUTHORIZATION);
		authenticationCache.remove(account);
		authorizationCache.remove(new SimplePrincipalCollection(account, realmName));
	}
}
 
Example 3
Source File: SSORealm.java    From kafka-eagle with Apache License 2.0 5 votes vote down vote up
public void clearAllCached() {
	Cache<Object, AuthorizationInfo> cache = this.getAuthorizationCache();
	if (cache != null) {
		for (Object key : cache.keys()) {
			cache.remove(key);
		}
	}
	LOG.info("SSOReaml - Clear all cached principal.");
}
 
Example 4
Source File: EHCacheManager.java    From mumu with Apache License 2.0 5 votes vote down vote up
/**
 * 删除缓存数据 缓存名称
 * @param cacheName 缓存key
 * @param key
 * @return
 */
@Override
public Object remove(String cacheName,String key){
	Cache<Object, Object> cache = cacheManager.getCache(cacheName);
	cacheManager.getCacheManager().removeCache(cacheName);
	return cache.remove(key);
}
 
Example 5
Source File: CacheUtils.java    From easyweb with Apache License 2.0 5 votes vote down vote up
/**
 * 从缓存中移除所有
 * @param cacheName
 */
public static void removeAll(String cacheName) {
	Cache<String, Object> cache = getCache(cacheName);
	Set<String> keys = cache.keys();
	for (Iterator<String> it = keys.iterator(); it.hasNext();){
		cache.remove(it.next());
	}
	logger.info("清理缓存: {} => {}", cacheName, keys);
}
 
Example 6
Source File: shiroDbRealm.java    From PhrackCTF-Platform-Team with Apache License 2.0 5 votes vote down vote up
/**
 * 清除所有用户授权信息缓存.
 */
public void clearAllCachedAuthorizationInfo() {
	Cache<Object, AuthorizationInfo> cache = getAuthorizationCache();
	if (cache != null) {
		for (Object key : cache.keys()) {
			cache.remove(key);
		}
	}
}
 
Example 7
Source File: shiroDbRealm.java    From PhrackCTF-Platform-Personal with Apache License 2.0 5 votes vote down vote up
/**
 * 清除所有用户授权信息缓存.
 */
public void clearAllCachedAuthorizationInfo() {
	Cache<Object, AuthorizationInfo> cache = getAuthorizationCache();
	if (cache != null) {
		for (Object key : cache.keys()) {
			cache.remove(key);
		}
	}
}
 
Example 8
Source File: ShiroJdbcRealm.java    From jee-universal-bms with Apache License 2.0 5 votes vote down vote up
/**
 * 清除所有用户授权信息缓存.
 */
public void clearAllCachedAuthorizationInfo() {
    Cache<Object, AuthorizationInfo> cache = getAuthorizationCache();
    if (cache != null) {
        for (Object key : cache.keys()) {
            cache.remove(key);
        }
    }
}
 
Example 9
Source File: ShiroCacheUtils.java    From jboot-admin with Apache License 2.0 4 votes vote down vote up
/**
 * 清除用户的授权信息
 * 
 * @param username
 */
public static void clearAuthorizationInfo(String username)
{
	Cache<Object, Object> cache = cacheManager.getCache(CacheKey.CACHE_SHIRO_AUTH);
	cache.remove(username);
}
 
Example 10
Source File: ShiroCacheUtils.java    From jboot-admin with Apache License 2.0 4 votes vote down vote up
/**
 * 清除session(认证信息)
 * 
 * @param sessionId
 */
public static void clearSession(Serializable sessionId)
{
	Cache<Object, Object> cache = cacheManager.getCache(CacheKey.CACHE_SHIRO_ACTIVESESSION);
	cache.remove(sessionId);
}
 
Example 11
Source File: MyRealm.java    From watchdog-framework with MIT License 4 votes vote down vote up
public void clearAuthByUserId(String uid,Boolean author, Boolean out){
    //获取所有session
    Cache<Object, Object> cache = cacheManager
            .getCache(MyRealm.class.getName()+".authorizationCache");
    cache.remove(uid);
}
 
Example 12
Source File: CacheDelegator.java    From jsets-shiro-spring-boot-starter with Apache License 2.0 4 votes vote down vote up
/**
 * 清扫密码重试次数
 */
public void cleanPasswdRetryCount(String account) {
	Cache<String, AtomicInteger> cache = this.cacheManager.getCache(ShiroProperties.CACHE_NAME_PASSWORD_RETRY);
	cache.remove(account);
}