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


Java CollectionUtils.isEmpty方法代码示例

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


在下文中一共展示了CollectionUtils.isEmpty方法的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: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: doGetAuthorizationInfo

import org.apache.shiro.util.CollectionUtils; //导入方法依赖的package包/类
/**
 * 授权
 */
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
	String username = (String) principals.getPrimaryPrincipal();
	CmsUser user = cmsUserMng.findByUsername(username);
	CmsSite site=CmsThreadVariable.getSite();
	SimpleAuthorizationInfo auth = new SimpleAuthorizationInfo();
	if (user != null) {
		Set<String>viewPermissionSet=new HashSet<String>();
		Set<String> perms = user.getPerms(site.getId(),viewPermissionSet);
		if (!CollectionUtils.isEmpty(perms)) {
			// 权限加入AuthorizationInfo认证对象
			auth.setStringPermissions(perms);
		}
	}
	return auth;
}
 
开发者ID:huanzhou,项目名称:jeecms6,代码行数:19,代码来源:CmsAuthorizingRealm.java

示例11: 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:caricah,项目名称:iotracah,代码行数:23,代码来源:IOTIniBasedRealm.java

示例12: createSecurityManager

import org.apache.shiro.util.CollectionUtils; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked"})
private SecurityManager createSecurityManager(Ini ini, Ini.Section mainSection) {

    Map<String, ?> defaults = createDefaults(ini, mainSection);
    Map<String, ?> objects = buildInstances(mainSection, defaults);

    SecurityManager securityManager = getSecurityManagerBean();

    boolean autoApplyRealms = isAutoApplyRealms(securityManager);

    if (autoApplyRealms) {
        //realms and realm factory might have been created - pull them out first so we can
        //initialize the securityManager:
        Collection<Realm> realms = getRealms(objects);
        //set them on the SecurityManager
        if (!CollectionUtils.isEmpty(realms)) {
            applyRealmsToSecurityManager(realms, securityManager);
        }
    }

    return securityManager;
}
 
开发者ID:icode,项目名称:ameba-shiro,代码行数:23,代码来源:IniSecurityManagerFactory.java

示例13: getPermissions

import org.apache.shiro.util.CollectionUtils; //导入方法依赖的package包/类
private 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:StarterInc,项目名称:Ignite,代码行数:26,代码来源:RoleSecurityJdbcRealm.java

示例14: resolveRolePermissions

import org.apache.shiro.util.CollectionUtils; //导入方法依赖的package包/类
private Collection<Permission> resolveRolePermissions(
		Collection<String> roleNames) {
	Collection<Permission> perms = Collections.emptySet();
	RolePermissionResolver resolver = getRolePermissionResolver();
	if (resolver != null && !CollectionUtils.isEmpty(roleNames)) {
		perms = new LinkedHashSet<Permission>(roleNames.size());
		for (String roleName : roleNames) {
			Collection<Permission> resolved = resolver
					.resolvePermissionsInRole(roleName);
			if (!CollectionUtils.isEmpty(resolved)) {
				perms.addAll(resolved);
			}
		}
	}
	return perms;
}
 
开发者ID:StarterInc,项目名称:Ignite,代码行数:17,代码来源:RoleSecurityJdbcRealm.java

示例15: createWebSecurityManager

import org.apache.shiro.util.CollectionUtils; //导入方法依赖的package包/类
@Override
protected WebSecurityManager createWebSecurityManager() {
    Ini ini = getIni();
    
    if (CollectionUtils.isEmpty(ini)) {
        ini = null;
    }
    
    BeanManager beanManager = BeanManagerProvider.getBeanManager();
    IniSecurityManagerFactory factory = new CdiWebIniSecurityManagerFactory(beanManager);
    factory.setIni(ini);

    WebSecurityManager wsm = (WebSecurityManager)factory.getInstance();
    Map<String, ?> beans = factory.getBeans();
    if (!CollectionUtils.isEmpty(beans)) {
        this.objects.putAll(beans);
    }

    return wsm;
}
 
开发者ID:ops4j,项目名称:org.ops4j.pax.shiro,代码行数:21,代码来源:CdiIniWebEnvironment.java


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