/** * Replace the mapping for the given key with the values copied from the given collection. * * @param key the key * @param values the new values * @return a list containing the previously mapped values */ default List<String> copyAndReplace(String key, Collection<String> values) { final List<String> old = copyAndRemove(key); addAll(key, values); return old; }
/** * Add all the values from the given map to this attributes collection. * * @param map the map to copy from * @return {@code true} if elements were added, {@code false} otherwise */ default boolean addAll(Map<String, ? extends Collection<String>> map) { Assert.checkNotNullParam("map", map); boolean changed = false; for (Map.Entry<String, ? extends Collection<String>> entry : map.entrySet()) { final Collection<String> value = entry.getValue(); if (value != null && ! value.isEmpty()) { final String key = entry.getKey(); changed = addAll(key, value) || changed; } } return changed; }
@Override public AuthorizationIdentity getAuthorizationIdentity() throws RealmUnavailableException { if (this.authenticatedSubject == null){ throw SecurityLogger.ROOT_LOGGER.unableToCreateAuthorizationIdentity(); } Attributes attributes = null; /* process the JAAS subject, extracting attributes from groups that might have been set in the subject by the JAAS login modules (e.g. caller principal, roles) */ final Set<Principal> principals = authenticatedSubject.getPrincipals(); if (principals != null) { for (Principal principal : principals) { if (principal instanceof Group) { final Set<String> values = this.processGroup((Group) principal); if (attributes == null) { attributes = new MapAttributes(); } attributes.addAll(principal.getName(), values); } } } if (attributes == null) attributes = Attributes.EMPTY; return AuthorizationIdentity.basicIdentity(attributes); }
/** * Replace the mapping for the given key with the values copied from the given collection. * * @param key the key * @param values the new values * @return a list containing the previously mapped values */ default List<String> copyAndReplace(String key, Collection<String> values) { final List<String> old = copyAndRemove(key); addAll(key, values); return old; }
/** * Replace the mapping for the given key with the values copied from the given collection. * * @param key the key * @param values the new values * @return a list containing the previously mapped values */ default List<String> copyAndReplace(String key, Collection<String> values) { final List<String> old = copyAndRemove(key); addAll(key, values); return old; }
/** * Replace the mapping for the given key with the values copied from the given collection. * * @param key the key * @param values the new values * @return a list containing the previously mapped values */ default List<String> copyAndReplace(String key, Collection<String> values) { final List<String> old = copyAndRemove(key); addAll(key, values); return old; }
/** * Add all the values from the given map to this attributes collection. * * @param map the map to copy from * @return {@code true} if elements were added, {@code false} otherwise */ default boolean addAll(Map<String, ? extends Collection<String>> map) { Assert.checkNotNullParam("map", map); boolean changed = false; for (Map.Entry<String, ? extends Collection<String>> entry : map.entrySet()) { final Collection<String> value = entry.getValue(); if (value != null && ! value.isEmpty()) { final String key = entry.getKey(); changed = addAll(key, value) || changed; } } return changed; }
/** * Add all the values from the given map to this attributes collection. * * @param map the map to copy from * @return {@code true} if elements were added, {@code false} otherwise */ default boolean addAll(Map<String, ? extends Collection<String>> map) { Assert.checkNotNullParam("map", map); boolean changed = false; for (Map.Entry<String, ? extends Collection<String>> entry : map.entrySet()) { final Collection<String> value = entry.getValue(); if (value != null && ! value.isEmpty()) { final String key = entry.getKey(); changed = addAll(key, value) || changed; } } return changed; }
/** * Add all the values from the given map to this attributes collection. * * @param map the map to copy from * @return {@code true} if elements were added, {@code false} otherwise */ default boolean addAll(Map<String, ? extends Collection<String>> map) { Assert.checkNotNullParam("map", map); boolean changed = false; for (Map.Entry<String, ? extends Collection<String>> entry : map.entrySet()) { final Collection<String> value = entry.getValue(); if (value != null && ! value.isEmpty()) { final String key = entry.getKey(); changed = addAll(key, value) || changed; } } return changed; }
@Override public AuthorizationIdentity getAuthorizationIdentity() throws RealmUnavailableException { if (this.authenticatedSubject == null){ throw SecurityLogger.ROOT_LOGGER.unableToCreateAuthorizationIdentity(); } Attributes attributes = null; /* process the JAAS subject, extracting attributes from groups that might have been set in the subject by the JAAS login modules (e.g. caller principal, roles) */ final Set<Principal> principals = authenticatedSubject.getPrincipals(); if (principals != null) { for (Principal principal : principals) { if (principal instanceof Group) { final Set<String> values = this.processGroup((Group) principal); if (attributes == null) { attributes = new MapAttributes(); } attributes.addAll(principal.getName(), values); } } } if (attributes == null) attributes = Attributes.EMPTY; return AuthorizationIdentity.basicIdentity(attributes); }