Example usage for org.apache.shiro.util CollectionUtils isEmpty

List of usage examples for org.apache.shiro.util CollectionUtils isEmpty

Introduction

In this page you can find the example usage for org.apache.shiro.util CollectionUtils isEmpty.

Prototype

@Deprecated
public static boolean isEmpty(PrincipalCollection principals) 

Source Link

Document

Returns true if the specified PrincipalCollection is null or PrincipalCollection#isEmpty empty , false otherwise.

Usage

From source file:cn.com.xl.core.shiro.redis.RedisCache.java

License:Apache License

@Override
@SuppressWarnings("unchecked")
public Set<K> keys() {
    IJedis jedis = initJedis();/*from  w  ww  . j a va 2  s.  c  o m*/
    try {
        Set<Object> keySet = jedis.hkeys(getName());
        if (!CollectionUtils.isEmpty(keySet)) {
            Set<K> keys = new LinkedHashSet<K>();
            for (Object key : keySet) {
                keys.add((K) key);
            }
            return keys;
        } else {
            return Collections.emptySet();
        }
    } catch (Throwable t) {
        throw new CacheException(t);
    }
}

From source file:cn.com.xl.core.shiro.redis.RedisCache.java

License:Apache License

@Override
public Collection<V> values() {
    try {//w  w  w  .j  a v a 2s .  com
        Set<K> keys = keys();
        if (!CollectionUtils.isEmpty(keys)) {
            List<V> values = new ArrayList<V>(keys.size());
            for (K key : keys) {
                V value = get(key);
                if (value != null) {
                    values.add(value);
                }
            }
            return Collections.unmodifiableList(values);
        } else {
            return Collections.emptyList();
        }
    } catch (Throwable t) {
        throw new CacheException(t);
    }
}

From source file:cn.guoyukun.spring.jpa.entity.search.SearchRequest.java

License:Apache License

@Override
public Searchable addSearchFilters(Collection<? extends SearchFilter> searchFilters) {
    if (CollectionUtils.isEmpty(searchFilters)) {
        return this;
    }/* w w  w .j a v a2 s  .  co  m*/
    for (SearchFilter searchFilter : searchFilters) {
        addSearchFilter(searchFilter);
    }
    return this;
}

From source file:cn.usually.common.shiro.authc.pam.AnySuccessfulStrategy.java

License:Apache License

/**
 * Returns the specified {@code aggregate} instance if is non null and valid
 * (that is, has principals and they are not empty) immediately, or, if it
 * is null or not valid, the {@code info} argument is returned instead.
 * <p/>//from  w w w . ja  v a 2s.  co m
 * This logic ensures that the first valid info encountered is the one
 * retained and all subsequent ones are ignored, since this strategy
 * mandates that only the info from the first successfully authenticated
 * realm be used.
 */
protected AuthenticationInfo merge(AuthenticationInfo info, AuthenticationInfo aggregate) {
    if (aggregate != null && !CollectionUtils.isEmpty(aggregate.getPrincipals())) {
        return aggregate;
    }
    return info != null ? info : aggregate;
}

From source file:com.caricah.iotracah.bootstrap.security.realm.impl.IOTIniBasedRealm.java

License:Apache License

@Override
protected void onInit() {
    super.onInit();

    Ini ini = getIni();/*from  w  w  w .  j  ava  2  s . c  o m*/

    if (CollectionUtils.isEmpty(ini)) {
        String msg = "Ini instance and/or resourcePath resulted in null or empty Ini configuration.  Cannot "
                + "load account data.";
        throw new IllegalStateException(msg);
    }

    processDefinitions(ini);
}

From source file:com.caricah.iotracah.bootstrap.security.realm.impl.IOTIniBasedRealm.java

License:Apache License

private void processDefinitions(Ini ini) {
    if (CollectionUtils.isEmpty(ini)) {
        log.warn("{} defined, but the ini instance is null or empty.", getClass().getSimpleName());
        return;//from w w  w .ja  v a 2  s  .com
    }

    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);
    }
}

From source file:com.caricah.iotracah.bootstrap.security.realm.state.IOTSubject.java

License:Apache License

protected boolean hasPrincipals() {
    return !CollectionUtils.isEmpty(getPrincipals());
}

From source file:com.caricah.iotracah.bootstrap.security.realm.state.IOTSubject.java

License:Apache License

private Object getPrimaryPrincipal(PrincipalCollection principals) {
    if (!CollectionUtils.isEmpty(principals)) {
        return principals.getPrimaryPrincipal();
    }/*from  www.  jav  a2 s .  c o  m*/
    return null;
}

From source file:com.centfor.frame.shiro.FrameShiroFilterFactoryBean.java

License:Apache License

/**
 * A convenience method that sets the {@link #setFilterChainDefinitionMap(java.util.Map) filterChainDefinitionMap}
 * property by accepting a {@link java.util.Properties Properties}-compatible string (multi-line key/value pairs).
 * Each key/value pair must conform to the format defined by the
 * {@link FilterChainManager#createChain(String,String)} JavaDoc - each property key is an ant URL
 * path expression and the value is the comma-delimited chain definition.
 *
 * @param definitions a {@link java.util.Properties Properties}-compatible string (multi-line key/value pairs)
 *                    where each key/value pair represents a single urlPathExpression-commaDelimitedChainDefinition.
 *//*  w w  w  . jav a2 s .co  m*/
public void setFilterChainDefinitions(String definitions) {
    Ini ini = new Ini();
    ini.load(definitions);
    //did they explicitly state a 'urls' section?  Not necessary, but just in case:
    Ini.Section section = ini.getSection(IniFilterChainResolverFactory.URLS);
    if (CollectionUtils.isEmpty(section)) {
        //no urls section.  Since this _is_ a urls chain definition property, just assume the
        //default section contains only the definitions:
        section = ini.getSection(Ini.DEFAULT_SECTION_NAME);
    }
    setFilterChainDefinitionMap(section);
}

From source file:com.centfor.frame.shiro.FrameShiroFilterFactoryBean.java

License:Apache License

protected FilterChainManager createFilterChainManager() {

    DefaultFilterChainManager manager = new DefaultFilterChainManager();
    Map<String, Filter> defaultFilters = manager.getFilters();
    //apply global settings if necessary:
    for (Filter filter : defaultFilters.values()) {
        applyGlobalPropertiesIfNecessary(filter);
    }/*from w w  w . ja v a2 s . c om*/

    //Apply the acquired and/or configured filters:
    Map<String, Filter> filters = getFilters();
    if (!CollectionUtils.isEmpty(filters)) {
        for (Map.Entry<String, Filter> entry : filters.entrySet()) {
            String name = entry.getKey();
            Filter filter = entry.getValue();
            applyGlobalPropertiesIfNecessary(filter);
            if (filter instanceof Nameable) {
                ((Nameable) filter).setName(name);
            }
            //'init' argument is false, since Spring-configured filters should be initialized
            //in Spring (i.e. 'init-method=blah') or implement InitializingBean:
            manager.addFilter(name, filter, false);
        }
    }

    //build up the chains:
    Map<String, String> chains = getFilterChainDefinitionMap();
    if (!CollectionUtils.isEmpty(chains)) {
        for (Map.Entry<String, String> entry : chains.entrySet()) {
            String url = entry.getKey();
            String chainDefinition = entry.getValue();
            manager.createChain(url, chainDefinition);
        }
    }

    return manager;
}