public MapContext(Map<String, Object> map) { this(); if (!CollectionUtils.isEmpty(map)) { this.backingMap.putAll(map); } }
public Collection fromRealm(String realmName) { if (CollectionUtils.isEmpty(this.realmPrincipals)) { return Collections.emptySet(); } Map<String,Object> principals = this.realmPrincipals.get(realmName); if (CollectionUtils.isEmpty(principals)) { return Collections.emptySet(); } return Collections.unmodifiableCollection(principals.values()); }
public Set<Entry<String, Object>> entrySet() { return CollectionUtils.isEmpty(this.combinedPrincipals) ? Collections.<Entry<String,Object>>emptySet() : Collections.unmodifiableSet(this.combinedPrincipals.entrySet()); }
public Set<String> keySet() { return CollectionUtils.isEmpty(this.combinedPrincipals) ? Collections.<String>emptySet() : Collections.unmodifiableSet(this.combinedPrincipals.keySet()); }
public Collection<Object> values() { return CollectionUtils.isEmpty(this.combinedPrincipals) ? Collections.emptySet() : Collections.unmodifiableCollection(this.combinedPrincipals.values()); }
public Set<String> getRealmNames() { if (CollectionUtils.isEmpty(this.realmPrincipals)) { return Collections.emptySet(); } return Collections.unmodifiableSet(this.realmPrincipals.keySet()); }
public Collection<Session> getActiveSessions() { Collection<Session> values = sessions.values(); if (CollectionUtils.isEmpty(values)) { return Collections.emptySet(); } else { return Collections.unmodifiableCollection(values); } }
public <T> T oneByType(Class<T> type) { if (CollectionUtils.isEmpty(this.combinedPrincipals)) { return null; } for( Object value : this.combinedPrincipals.values()) { if (type.isInstance(value) ) { return type.cast(value); } } return null; }
public SimplePrincipalMap(Map<String, Map<String, Object>> backingMap) { if (!CollectionUtils.isEmpty(backingMap)) { this.realmPrincipals = backingMap; for (Map<String, Object> principals : this.realmPrincipals.values()) { if (!CollectionUtils.isEmpty(principals) ) { ensureCombinedPrincipals().putAll(principals); } } } }
public Set asSet() { if (CollectionUtils.isEmpty(this.combinedPrincipals)) { return Collections.emptySet(); } Set<Object> set = new HashSet<Object>(this.combinedPrincipals.size()); set.addAll(this.combinedPrincipals.values()); return set; }
public List asList() { if (CollectionUtils.isEmpty(this.combinedPrincipals)) { return Collections.emptyList(); } List<Object> list = new ArrayList<Object>(this.combinedPrincipals.size()); list.addAll(this.combinedPrincipals.values()); return list; }
protected void assertRealmsConfigured() throws IllegalStateException { Collection<Realm> realms = getRealms(); if (CollectionUtils.isEmpty(realms)) { String msg = "Configuration error: No realms have been configured! One or more realms must be " + "present to execute an authentication attempt."; throw new IllegalStateException(msg); } }
public void putAll(Map<? extends String, ?> map) { if (!CollectionUtils.isEmpty(map)) { ensureCombinedPrincipals().putAll(map); } }
private Collection<Permission> resolvePermissions(Collection<String> stringPerms) { Collection<Permission> perms = Collections.emptySet(); PermissionResolver resolver = getPermissionResolver(); if (resolver != null && !CollectionUtils.isEmpty(stringPerms)) { perms = new LinkedHashSet<Permission>(stringPerms.size()); for (String strPermission : stringPerms) { Permission permission = resolver.resolvePermission(strPermission); perms.add(permission); } } return perms; }
protected void registerFilters(Map<String, Filter> filters, FilterChainManager manager) { if (!CollectionUtils.isEmpty(filters)) { boolean init = getFilterConfig() != null; //only call filter.init if there is a FilterConfig available for (Map.Entry<String, Filter> entry : filters.entrySet()) { String name = entry.getKey(); Filter filter = entry.getValue(); manager.addFilter(name, filter, init); } } }
public Collection<Object> getAttributeKeys(SessionKey key) { Collection<Object> c = lookupRequiredSession(key).getAttributeKeys(); if (!CollectionUtils.isEmpty(c)) { return Collections.unmodifiableCollection(c); } return Collections.emptySet(); }
protected SecurityManager createInstance(Ini ini) { if (CollectionUtils.isEmpty(ini)) { throw new NullPointerException("Ini argument cannot be null or empty."); } SecurityManager securityManager = createSecurityManager(ini); if (securityManager == null) { String msg = SecurityManager.class + " instance cannot be null."; throw new ConfigurationException(msg); } return securityManager; }
private void addToRealms(Collection<Realm> realms, RealmFactory factory) { LifecycleUtils.init(factory); Collection<Realm> factoryRealms = factory.getRealms(); //SHIRO-238: check factoryRealms (was 'realms'): if (!CollectionUtils.isEmpty(factoryRealms)) { realms.addAll(factoryRealms); } }
/** * {@link ThreadContext#remove Remove}s all thread-state that was bound by this instance. If any previous * thread-bound resources existed prior to the {@link #bind bind} call, they are restored back to the * {@code ThreadContext} to ensure the thread state is exactly as it was before binding. */ public void restore() { ThreadContext.remove(); if (!CollectionUtils.isEmpty(this.originalResources)) { ThreadContext.setResources(this.originalResources); } }
private Ini.Section getConfigSection(Ini ini) { Ini.Section mainSection = ini.getSection(MAIN_SECTION_NAME); if (CollectionUtils.isEmpty(mainSection)) { //try the default: mainSection = ini.getSection(Ini.DEFAULT_SECTION_NAME); } return mainSection; }