org.wildfly.security.authz.Attributes.addAll()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(5.9k)|赞(0)|评价(0)|浏览(110)

本文整理了Java中org.wildfly.security.authz.Attributes.addAll()方法的一些代码示例,展示了Attributes.addAll()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Attributes.addAll()方法的具体详情如下:
包路径:org.wildfly.security.authz.Attributes
类名称:Attributes
方法名:addAll

Attributes.addAll介绍

[英]Add all the values from the given collection to the value collection for the given key.
[中]将给定集合中的所有值添加到给定键的值集合中。

代码示例

代码示例来源:origin: wildfly/wildfly

/**
 * 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;
}

代码示例来源:origin: wildfly/wildfly

/**
 * 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;
}

代码示例来源:origin: wildfly/wildfly

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

代码示例来源:origin: org.jboss.eap/wildfly-client-all

/**
 * 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;
}

代码示例来源:origin: org.wildfly.security/wildfly-elytron-auth-server

/**
 * 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;
}

代码示例来源:origin: org.wildfly.security/wildfly-elytron

/**
 * 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;
}

代码示例来源:origin: org.wildfly.security/wildfly-elytron-auth-server

/**
 * 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;
}

代码示例来源:origin: org.wildfly.security/wildfly-elytron

/**
 * 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;
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

/**
 * 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;
}

代码示例来源:origin: org.jboss.eap/wildfly-security

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

相关文章