当前位置: 首页>>代码示例>>Java>>正文


Java CollectionUtils类代码示例

本文整理汇总了Java中org.apache.shiro.util.CollectionUtils的典型用法代码示例。如果您正苦于以下问题:Java CollectionUtils类的具体用法?Java CollectionUtils怎么用?Java CollectionUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CollectionUtils类属于org.apache.shiro.util包,在下文中一共展示了CollectionUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getActiveSessions

import org.apache.shiro.util.CollectionUtils; //导入依赖的package包/类
/**
 * 获取当前所有活跃用户
 */
@Override
public Collection<Session> getActiveSessions(){
    Jedis jedis = null;
    try {
        jedis = jedisPool.getResource();
        Set<String> keys = jedis.keys(prefix + "*");
        if(CollectionUtils.isEmpty(keys)){
            return null;
        }
        List<String> values = jedis.mget(keys.toArray(new String[keys.size()]));
        return SerializeUtils.deserializeFromStrings(values);
    } catch (Exception e){
        logger.warn("统计Session信息失败", e);
    } finally {
        jedis.close();
    }
    return null;
}
 
开发者ID:ZhuXS,项目名称:Spring-Shiro-Spark,代码行数:22,代码来源:ShiroSessionDao.java

示例2: setFilterChainDefinitions

import org.apache.shiro.util.CollectionUtils; //导入依赖的package包/类
/**
 * 从数据库动态读取权限
 */
@Override
public void setFilterChainDefinitions(String definitions) {

    MyShiroFilterFactoryBean.definitions = definitions;

    //数据库动态权限
    List<TbShiroFilter> list = systemService.getShiroFilter();
    for(TbShiroFilter tbShiroFilter : list){
        //字符串拼接权限
        definitions = definitions+tbShiroFilter.getName() + " = "+tbShiroFilter.getPerms()+"\n";
    }

    log.info(definitions);

    //从配置文件加载权限配置
    Ini ini = new Ini();
    ini.load(definitions);
    Ini.Section section = ini.getSection("urls");
    if (CollectionUtils.isEmpty(section)) {
        section = ini.getSection("");
    }

    this.setFilterChainDefinitionMap(section);
}
 
开发者ID:Exrick,项目名称:xmall,代码行数:28,代码来源:MyShiroFilterFactoryBean.java

示例3: getAllSessions

import org.apache.shiro.util.CollectionUtils; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
   public Collection<Session> getAllSessions() {
   	Collection<Session> sessions = new ArrayList<Session>(0);
	try {
		Object object = cacheManager.getCache(this.activeSessionsCacheName).getNativeCache();
		if(object instanceof Ehcache)
		{
			Ehcache ehcache = (Ehcache)object;
			List<Serializable> keys = ehcache.getKeysWithExpiryCheck();
			if (!CollectionUtils.isEmpty(keys)) {
				for (Serializable key : keys) {
					sessions.add(getSession(key));
				}
			}
		}
	} catch (Exception e) {
		logger.error("获取全部session异常", e);
	}
      
       return sessions;
   }
 
开发者ID:wjggwm,项目名称:webside,代码行数:23,代码来源:EhCacheShiroSessionRepository.java

示例4: getActiveSessions

import org.apache.shiro.util.CollectionUtils; //导入依赖的package包/类
public Collection<Session> getActiveSessions() {
        Collection<Session> values = super.getActiveSessions();
//		RedisClientSupport jedis = SpringBeanUtil.getRedisClientSupport();
//		if (jedis != null) {
//			String key = RedisKeyConfig.getShiroSessionCacheKey("*");
//			try {
//				Set<String> valueSet = jedis.keys(key);
//				if (valueSet!=null&&valueSet.size()>0) {
//					for (String v : valueSet) {
////					Session session = JSON.parseObject(v, Session.class);
//						Session session = SerializableUtils.deserialize(v,Session.class);
//						values.add(session);
//					}
//				}
//			} catch (CacheAccessException e) {
//			}
//		}
        if (CollectionUtils.isEmpty(values)) {
            return Collections.emptySet();
        } else {
            return Collections.unmodifiableCollection(values);
        }
    }
 
开发者ID:leiyong0326,项目名称:phone,代码行数:24,代码来源:ShiroSessionDAO.java

示例5: clear

import org.apache.shiro.util.CollectionUtils; //导入依赖的package包/类
@Override
public void clear() throws CacheException {
	logger.debug("clear redis all data!");
	try {
		synchronized (this) {
			Set<byte[]> keys = cache.keys(this.keyPrefix + "*");
			if (!CollectionUtils.isEmpty(keys)) {
				for (byte[] key : keys) {
					cache.del(key);
				}
			}
		}
	} catch (Throwable t) {
		throw new CacheException(t);
	}
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:17,代码来源:RedisCache.java

示例6: popIdentity

import org.apache.shiro.util.CollectionUtils; //导入依赖的package包/类
private PrincipalCollection popIdentity() {
    PrincipalCollection popped = null;

    List<PrincipalCollection> stack = getRunAsPrincipalsStack();
    if (!CollectionUtils.isEmpty(stack)) {
        popped = stack.remove(0);
        Session session;
        if (!CollectionUtils.isEmpty(stack)) {
            //persist the changed stack to the session
            session = getSession();
            session.setAttribute(RUN_AS_PRINCIPALS_SESSION_KEY, stack);
        } else {
            //stack is empty, remove it from the session:
            clearRunAsIdentities();
        }
    }

    return popped;
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:20,代码来源:DelegatingSubject.java

示例7: setRealmPrincipals

import org.apache.shiro.util.CollectionUtils; //导入依赖的package包/类
public Map<String,Object> setRealmPrincipals(String realmName, Map<String, Object> principals) {
    if (realmName == null) {
        throw new NullPointerException("realmName argument cannot be null.");
    }
    if (this.realmPrincipals == null) {
        if (!CollectionUtils.isEmpty(principals)) {
            this.realmPrincipals = new HashMap<String,Map<String,Object>>();
            return this.realmPrincipals.put(realmName, new HashMap<String,Object>(principals));
        } else {
            return null;
        }
    } else {
        Map<String,Object> existingPrincipals = this.realmPrincipals.remove(realmName);
        if (!CollectionUtils.isEmpty(principals)) {
            this.realmPrincipals.put(realmName, new HashMap<String,Object>(principals));
        }
        return existingPrincipals;
    }
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:20,代码来源:SimplePrincipalMap.java

示例8: getServletContextIniResource

import org.apache.shiro.util.CollectionUtils; //导入依赖的package包/类
/**
 * Returns the INI instance reflecting the specified servlet context resource path or {@code null} if no
 * resource was found.
 *
 * @param servletContextPath the servlet context resource path of the INI file to load
 * @return the INI instance reflecting the specified servlet context resource path or {@code null} if no
 *         resource was found.
 * @since 1.2
 */
protected Ini getServletContextIniResource(String servletContextPath) {
    String path = WebUtils.normalize(servletContextPath);
    if (getServletContext() != null) {
        InputStream is = getServletContext().getResourceAsStream(path);
        if (is != null) {
            Ini ini = new Ini();
            ini.load(is);
            if (CollectionUtils.isEmpty(ini)) {
                log.warn("ServletContext INI resource '" + servletContextPath + "' exists, but it did not contain " +
                        "any data.");
            }
            return ini;
        }
    }
    return null;
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:26,代码来源:IniShiroFilter.java

示例9: getDefaultIni

import org.apache.shiro.util.CollectionUtils; //导入依赖的package包/类
protected Ini getDefaultIni() {

        Ini ini = null;

        String[] configLocations = getDefaultConfigLocations();
        if (configLocations != null) {
            for (String location : configLocations) {
                ini = createIni(location, false);
                if (!CollectionUtils.isEmpty(ini)) {
                    log.debug("Discovered non-empty INI configuration at location '{}'.  Using for configuration.",
                            location);
                    break;
                }
            }
        }

        return ini;
    }
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:19,代码来源:IniWebEnvironment.java

示例10: createIni

import org.apache.shiro.util.CollectionUtils; //导入依赖的package包/类
/**
 * Creates an {@link Ini} instance reflecting the specified path, or {@code null} if the path does not exist and
 * is not required.
 * <p/>
 * If the path is required and does not exist or is empty, a {@link ConfigurationException} will be thrown.
 *
 * @param configLocation the resource path to load into an {@code Ini} instance.
 * @param required       if the path must exist and be converted to a non-empty {@link Ini} instance.
 * @return an {@link Ini} instance reflecting the specified path, or {@code null} if the path does not exist and
 *         is not required.
 * @throws ConfigurationException if the path is required but results in a null or empty Ini instance.
 */
protected Ini createIni(String configLocation, boolean required) throws ConfigurationException {

    Ini ini = null;

    if (configLocation != null) {
        ini = convertPathToIni(configLocation, required);
    }
    if (required && CollectionUtils.isEmpty(ini)) {
        String msg = "Required configuration location '" + configLocation + "' does not exist or did not " +
                "contain any INI configuration.";
        throw new ConfigurationException(msg);
    }

    return ini;
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:28,代码来源:IniWebEnvironment.java

示例11: createFilterChainResolver

import org.apache.shiro.util.CollectionUtils; //导入依赖的package包/类
protected FilterChainResolver createFilterChainResolver() {

        FilterChainResolver resolver = null;

        Ini ini = getIni();

        if (!CollectionUtils.isEmpty(ini)) {
            //only create a resolver if the 'filters' or 'urls' sections are defined:
            Ini.Section urls = ini.getSection(IniFilterChainResolverFactory.URLS);
            Ini.Section filters = ini.getSection(IniFilterChainResolverFactory.FILTERS);
            if (!CollectionUtils.isEmpty(urls) || !CollectionUtils.isEmpty(filters)) {
                //either the urls section or the filters section was defined.  Go ahead and create the resolver:
                IniFilterChainResolverFactory factory = new IniFilterChainResolverFactory(ini, this.objects);
                resolver = factory.getInstance();
            }
        }

        return resolver;
    }
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:20,代码来源:IniWebEnvironment.java

示例12: getFilters

import org.apache.shiro.util.CollectionUtils; //导入依赖的package包/类
protected Map<String, Filter> getFilters(Map<String, String> section, Map<String, ?> defaults) {

        Map<String, Filter> filters = extractFilters(defaults);

        if (!CollectionUtils.isEmpty(section)) {
            ReflectionBuilder builder = new ReflectionBuilder(defaults);
            Map<String, ?> built = builder.buildObjects(section);
            Map<String,Filter> sectionFilters = extractFilters(built);

            if (CollectionUtils.isEmpty(filters)) {
                filters = sectionFilters;
            } else {
                if (!CollectionUtils.isEmpty(sectionFilters)) {
                    filters.putAll(sectionFilters);
                }
            }
        }

        return filters;
    }
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:21,代码来源:IniFilterChainResolverFactory.java

示例13: createChains

import org.apache.shiro.util.CollectionUtils; //导入依赖的package包/类
protected void createChains(Map<String, String> urls, FilterChainManager manager) {
    if (CollectionUtils.isEmpty(urls)) {
        if (log.isDebugEnabled()) {
            log.debug("No urls to process.");
        }
        return;
    }

    if (log.isTraceEnabled()) {
        log.trace("Before url processing.");
    }

    for (Map.Entry<String, String> entry : urls.entrySet()) {
        String path = entry.getKey();
        String value = entry.getValue();
        manager.createChain(path, value);
    }
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:19,代码来源:IniFilterChainResolverFactory.java

示例14: getPermissions

import org.apache.shiro.util.CollectionUtils; //导入依赖的package包/类
protected Collection<Permission> getPermissions(AuthorizationInfo info) {
    Set<Permission> permissions = new HashSet<Permission>();

    if (info != null) {
        Collection<Permission> perms = info.getObjectPermissions();
        if (!CollectionUtils.isEmpty(perms)) {
            permissions.addAll(perms);
        }
        perms = resolvePermissions(info.getStringPermissions());
        if (!CollectionUtils.isEmpty(perms)) {
            permissions.addAll(perms);
        }

        perms = resolveRolePermissions(info.getRoles());
        if (!CollectionUtils.isEmpty(perms)) {
            permissions.addAll(perms);
        }
    }

    if (permissions.isEmpty()) {
        return Collections.emptySet();
    } else {
        return Collections.unmodifiableSet(permissions);
    }
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:26,代码来源:AuthorizingRealm.java

示例15: processDefinitions

import org.apache.shiro.util.CollectionUtils; //导入依赖的package包/类
private void processDefinitions(Ini ini) {
    if (CollectionUtils.isEmpty(ini)) {
        log.warn("{} defined, but the ini instance is null or empty.", getClass().getSimpleName());
        return;
    }

    Ini.Section rolesSection = ini.getSection(ROLES_SECTION_NAME);
    if (!CollectionUtils.isEmpty(rolesSection)) {
        log.debug("Discovered the [{}] section.  Processing...", ROLES_SECTION_NAME);
        processRoleDefinitions(rolesSection);
    }

    Ini.Section usersSection = ini.getSection(USERS_SECTION_NAME);
    if (!CollectionUtils.isEmpty(usersSection)) {
        log.debug("Discovered the [{}] section.  Processing...", USERS_SECTION_NAME);
        processUserDefinitions(usersSection);
    } else {
        log.info("{} defined, but there is no [{}] section defined.  This realm will not be populated with any " +
                "users and it is assumed that they will be populated programatically.  Users must be defined " +
                "for this Realm instance to be useful.", getClass().getSimpleName(), USERS_SECTION_NAME);
    }
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:23,代码来源:IniRealm.java


注:本文中的org.apache.shiro.util.CollectionUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。