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

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

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

Attributes.get介绍

[英]Get the collection of values for the given key. The result may implement SetEntry if the values are distinct (for example, a role or group set).
[中]获取给定键的值集合。如果值不同(例如,角色集或组集),则结果可能实现SetEntry。

代码示例

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

/**
 * Get the first value mapped to the given key.
 *
 * @param key the key
 * @return the value
 * @throws IndexOutOfBoundsException if there are no values for the given key
 */
default String getFirst(String key) {
  return get(key, 0);
}

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

@Override
public String get(String key, int idx) {
  return Attributes.this.get(key, idx);
}

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

public String get(final int index) {
  return attributes.get(key, index);
}

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

/**
 * Get the last value mapped to the given key.
 *
 * @param key the key
 * @return the value
 * @throws IndexOutOfBoundsException if there are no values for the given key
 */
default String getLast(String key) {
  return get(key, size(key) - 1);
}

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

/**
 * Get the index of the first occurrence of the given value at the given key, if any.
 *
 * @param key the key
 * @param value the value
 * @return the index, or -1 if the value was not found at the given key
 */
default int indexOf(String key, String value) {
  final int size = size(key);
  for (int i = 0; i < size; i ++) {
    if (get(key, i).equals(value)) {
      return i;
    }
  }
  return -1;
}

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

/**
 * Get the index of the last occurrence of the given value at the given key, if any.
 *
 * @param key the key
 * @param value the value
 * @return the index, or -1 if the value was not found at the given key
 */
default int lastIndexOf(String key, String value) {
  final int size = size(key);
  for (int i = size - 1; i >= 0; i --) {
    if (get(key, i).equals(value)) {
      return i;
    }
  }
  return -1;
}

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

/**
 * Remove the mapping for the given key at the given position if it matches the given existing value.  All later
 * entries for that key are shifted up to fill in the gap left by the removed element.
 *
 * @param key the key
 * @param idx the index
 * @param value the expected previous mapping value
 * @return {@code true} if the value matched and was removed, {@code false} otherwise
 * @throws IndexOutOfBoundsException if {@code idx} is less than 0 or greater than or equal to {@code size(key)}
 */
default boolean remove(String key, int idx, String value) {
  if (get(key, idx).equals(value)) {
    remove(key, idx);
    return true;
  } else {
    return false;
  }
}

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

/**
 * Remove all values for the given key from this collection, copying the values into a list which is returned.
 *
 * @param key the key
 * @return the values as a list (not {@code null})
 */
default List<String> copyAndRemove(String key) {
  final Entry values = get(key);
  List<String> copy = values.isEmpty() ? Collections.emptyList() : new ArrayList<>(values);
  remove(key);
  return copy;
}

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

/**
   * Create a simple role decoder which returns the values of the given attribute.
   *
   * @param attribute the attribute
   * @return the roles
   */
  static RoleDecoder simple(String attribute) {
    return identity -> {
      final Attributes.Entry entry = identity.getAttributes().get(attribute);
      return entry.isEmpty() ? Roles.NONE : entry instanceof Attributes.SetEntry ? Roles.fromSet((Attributes.SetEntry) entry) : Roles.fromSet(new HashSet<>(entry));
    };
  }
}

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

/**
 * Conditionally set a specific value of a given key to a new value, if the existing value matches the {@code expect}
 * parameter.
 *
 * @param key the key
 * @param idx the index
 * @param expect the expected value
 * @param update the value to set
 * @return {@code true} if the actual value matched the expected value and was updated, {@code false} otherwise
 * @throws IndexOutOfBoundsException if {@code idx} is less than 0 or greater than or equal to {@code size(key)}
 */
default boolean set(String key, int idx, String expect, String update) {
  Assert.checkNotNullParam("update", update);
  if (expect == null || idx < 0 || idx >= size(key) || ! get(key, idx).equals(expect)) {
    return false;
  }
  set(key, idx, update);
  return true;
}

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

renameTo = attributes.get(mapping.getName(), 0);
} else {
  throw log.ldapRealmRequiresExactlyOneRdnAttribute(mapping.getName(), name);
} else {
  BasicAttribute attribute = new BasicAttribute(mapping.getLdapName());
  attributes.get(mapping.getName()).forEach(attribute::add);
  modItems.add(new ModificationItem(DirContext.REPLACE_ATTRIBUTE, attribute));

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

/**
 * Get the first value mapped to the given key.
 *
 * @param key the key
 * @return the value
 * @throws IndexOutOfBoundsException if there are no values for the given key
 */
default String getFirst(String key) {
  return get(key, 0);
}

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

/**
 * Get the first value mapped to the given key.
 *
 * @param key the key
 * @return the value
 * @throws IndexOutOfBoundsException if there are no values for the given key
 */
default String getFirst(String key) {
  return get(key, 0);
}

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

@Override
public String get(String key, int idx) {
  return Attributes.this.get(key, idx);
}

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

/**
 * Get the first value mapped to the given key.
 *
 * @param key the key
 * @return the value
 * @throws IndexOutOfBoundsException if there are no values for the given key
 */
default String getFirst(String key) {
  return get(key, 0);
}

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

/**
 * Get the last value mapped to the given key.
 *
 * @param key the key
 * @return the value
 * @throws IndexOutOfBoundsException if there are no values for the given key
 */
default String getLast(String key) {
  return get(key, size(key) - 1);
}

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

/**
 * Get the last value mapped to the given key.
 *
 * @param key the key
 * @return the value
 * @throws IndexOutOfBoundsException if there are no values for the given key
 */
default String getLast(String key) {
  return get(key, size(key) - 1);
}

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

/**
 * Get the last value mapped to the given key.
 *
 * @param key the key
 * @return the value
 * @throws IndexOutOfBoundsException if there are no values for the given key
 */
default String getLast(String key) {
  return get(key, size(key) - 1);
}

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

/**
 * Remove all values for the given key from this collection, copying the values into a list which is returned.
 *
 * @param key the key
 * @return the values as a list (not {@code null})
 */
default List<String> copyAndRemove(String key) {
  final Entry values = get(key);
  List<String> copy = values.isEmpty() ? Collections.emptyList() : new ArrayList<>(values);
  remove(key);
  return copy;
}

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

/**
 * Remove all values for the given key from this collection, copying the values into a list which is returned.
 *
 * @param key the key
 * @return the values as a list (not {@code null})
 */
default List<String> copyAndRemove(String key) {
  final Entry values = get(key);
  List<String> copy = values.isEmpty() ? Collections.emptyList() : new ArrayList<>(values);
  remove(key);
  return copy;
}

相关文章