org.wildfly.security.x500.util.X500PrincipalUtil.getAttributeValues()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(10.2k)|赞(0)|评价(0)|浏览(106)

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

X500PrincipalUtil.getAttributeValues介绍

[英]Get all the values of the attribute with the given OID in the given principal. This includes occurrences within multi-valued RDNs.
[中]获取给定主体中具有给定OID的属性的所有值。这包括多值RDN中的事件。

代码示例

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

/**
 * Get all the values of the attribute with the given OID in the given principal.  This includes occurrences within
 * multi-valued RDNs.
 *
 * @param principal the principal to examine
 * @param oid the OID whose values are to be returned
 * @return the list of values associated with the OID
 */
public static String[] getAttributeValues(X500Principal principal, String oid) {
  return getAttributeValues(principal, oid, false);
}

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

public static boolean matchGeneralName(GeneralName generalName, GeneralName actualGeneralName) {
  if ((generalName instanceof DNSName) && (actualGeneralName instanceof DirectoryName)) {
    // Check if the DNSName matches the DirectoryName's (most specific) Common Name field.
    // Although specifying a DNS name using the Common Name field has been deprecated, it is
    // still used in practice (e.g., see http://tools.ietf.org/html/rfc2818).
    String[] cnValues = X500PrincipalUtil.getAttributeValues(new X500Principal(((DirectoryName) actualGeneralName).getName()), X500.OID_AT_COMMON_NAME);
    String dnsName = ((DNSName) generalName).getName();
    return dnsName.equalsIgnoreCase(cnValues[0]);
  } else {
    return generalName.equals(actualGeneralName);
  }
}

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

public String getName(final Principal principal) {
    final X500Principal x500Principal = X500PrincipalUtil.asX500Principal(principal, convert);
    if (x500Principal == null) {
      return null;
    }
    if (requiredOids != null && requiredOids.length != 0 && ! X500PrincipalUtil.containsAllAttributes(x500Principal, requiredOids)) {
      ElytronMessages.log.tracef("X500 principal [%s] was not decoded - does not contain required oids", x500Principal);
      return null;
    }
    final String[] values = X500PrincipalUtil.getAttributeValues(x500Principal, oid, reverse);
    if (values.length == 0) {
      ElytronMessages.log.tracef("X500 principal [%s] was not decoded - no values of attribute [%s]", x500Principal, oid);
      return null;
    } else {
      final String name = Arrays.stream(values).skip(startSegment).limit(maximumSegments).collect(Collectors.joining(joiner));
      if (ElytronMessages.log.isTraceEnabled()) {
        ElytronMessages.log.tracef("X500 principal [%s] decoded as name [%s] (attribute values: [%s])", x500Principal, name, String.join(", ", values));
      }
      return name;
    }
  }
}

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

/**
 * Get all the values of the attribute with the given OID in the given principal.  This includes occurrences within
 * multi-valued RDNs.
 *
 * @param principal the principal to examine
 * @param oid the OID whose values are to be returned
 * @return the list of values associated with the OID
 */
public static String[] getAttributeValues(X500Principal principal, String oid) {
  return getAttributeValues(principal, oid, false);
}

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

/**
 * Get all the values of the attribute with the given OID in the given principal.  This includes occurrences within
 * multi-valued RDNs.
 *
 * @param principal the principal to examine
 * @param oid the OID whose values are to be returned
 * @return the list of values associated with the OID
 */
public static String[] getAttributeValues(X500Principal principal, String oid) {
  return getAttributeValues(principal, oid, false);
}

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

/**
 * Get all the values of the attribute with the given OID in the given principal.  This includes occurrences within
 * multi-valued RDNs.
 *
 * @param principal the principal to examine
 * @param oid the OID whose values are to be returned
 * @return the list of values associated with the OID
 */
public static String[] getAttributeValues(X500Principal principal, String oid) {
  return getAttributeValues(principal, oid, false);
}

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

public static boolean matchGeneralName(GeneralName generalName, GeneralName actualGeneralName) {
  if ((generalName instanceof DNSName) && (actualGeneralName instanceof DirectoryName)) {
    // Check if the DNSName matches the DirectoryName's (most specific) Common Name field.
    // Although specifying a DNS name using the Common Name field has been deprecated, it is
    // still used in practice (e.g., see http://tools.ietf.org/html/rfc2818).
    String[] cnValues = X500PrincipalUtil.getAttributeValues(new X500Principal(((DirectoryName) actualGeneralName).getName()), X500.OID_AT_COMMON_NAME);
    String dnsName = ((DNSName) generalName).getName();
    return dnsName.equalsIgnoreCase(cnValues[0]);
  } else {
    return generalName.equals(actualGeneralName);
  }
}

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

public static boolean matchGeneralName(GeneralName generalName, GeneralName actualGeneralName) {
  if ((generalName instanceof DNSName) && (actualGeneralName instanceof DirectoryName)) {
    // Check if the DNSName matches the DirectoryName's (most specific) Common Name field.
    // Although specifying a DNS name using the Common Name field has been deprecated, it is
    // still used in practice (e.g., see http://tools.ietf.org/html/rfc2818).
    String[] cnValues = X500PrincipalUtil.getAttributeValues(new X500Principal(((DirectoryName) actualGeneralName).getName()), X500.OID_AT_COMMON_NAME);
    String dnsName = ((DNSName) generalName).getName();
    return dnsName.equalsIgnoreCase(cnValues[0]);
  } else {
    return generalName.equals(actualGeneralName);
  }
}

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

public static boolean matchGeneralName(GeneralName generalName, GeneralName actualGeneralName) {
  if ((generalName instanceof DNSName) && (actualGeneralName instanceof DirectoryName)) {
    // Check if the DNSName matches the DirectoryName's (most specific) Common Name field.
    // Although specifying a DNS name using the Common Name field has been deprecated, it is
    // still used in practice (e.g., see http://tools.ietf.org/html/rfc2818).
    String[] cnValues = X500PrincipalUtil.getAttributeValues(new X500Principal(((DirectoryName) actualGeneralName).getName()), X500.OID_AT_COMMON_NAME);
    String dnsName = ((DNSName) generalName).getName();
    return dnsName.equalsIgnoreCase(cnValues[0]);
  } else {
    return generalName.equals(actualGeneralName);
  }
}

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

public String getName(final Principal principal) {
    final X500Principal x500Principal = X500PrincipalUtil.asX500Principal(principal, convert);
    if (x500Principal == null) {
      return null;
    }
    if (requiredOids != null && requiredOids.length != 0 && ! X500PrincipalUtil.containsAllAttributes(x500Principal, requiredOids)) {
      ElytronMessages.log.tracef("X500 principal [%s] was not decoded - does not contain required oids", x500Principal);
      return null;
    }
    final String[] values = X500PrincipalUtil.getAttributeValues(x500Principal, oid, reverse);
    if (values.length == 0) {
      ElytronMessages.log.tracef("X500 principal [%s] was not decoded - no values of attribute [%s]", x500Principal, oid);
      return null;
    } else {
      final String name = Arrays.stream(values).skip(startSegment).limit(maximumSegments).collect(Collectors.joining(joiner));
      if (ElytronMessages.log.isTraceEnabled()) {
        ElytronMessages.log.tracef("X500 principal [%s] decoded as name [%s] (attribute values: [%s])", x500Principal, name, String.join(", ", values));
      }
      return name;
    }
  }
}

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

public String getName(final Principal principal) {
    final X500Principal x500Principal = X500PrincipalUtil.asX500Principal(principal, convert);
    if (x500Principal == null) {
      return null;
    }
    if (requiredOids != null && requiredOids.length != 0 && ! X500PrincipalUtil.containsAllAttributes(x500Principal, requiredOids)) {
      ElytronMessages.log.tracef("X500 principal [%s] was not decoded - does not contain required oids", x500Principal);
      return null;
    }
    final String[] values = X500PrincipalUtil.getAttributeValues(x500Principal, oid, reverse);
    if (values.length == 0) {
      ElytronMessages.log.tracef("X500 principal [%s] was not decoded - no values of attribute [%s]", x500Principal, oid);
      return null;
    } else {
      final String name = Arrays.stream(values).skip(startSegment).limit(maximumSegments).collect(Collectors.joining(joiner));
      if (ElytronMessages.log.isTraceEnabled()) {
        ElytronMessages.log.tracef("X500 principal [%s] decoded as name [%s] (attribute values: [%s])", x500Principal, name, String.join(", ", values));
      }
      return name;
    }
  }
}

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

public String getName(final Principal principal) {
    final X500Principal x500Principal = X500PrincipalUtil.asX500Principal(principal, convert);
    if (x500Principal == null) {
      return null;
    }
    if (requiredOids != null && requiredOids.length != 0 && ! X500PrincipalUtil.containsAllAttributes(x500Principal, requiredOids)) {
      ElytronMessages.log.tracef("X500 principal [%s] was not decoded - does not contain required oids", x500Principal);
      return null;
    }
    final String[] values = X500PrincipalUtil.getAttributeValues(x500Principal, oid, reverse);
    if (values.length == 0) {
      ElytronMessages.log.tracef("X500 principal [%s] was not decoded - no values of attribute [%s]", x500Principal, oid);
      return null;
    } else {
      final String name = Arrays.stream(values).skip(startSegment).limit(maximumSegments).collect(Collectors.joining(joiner));
      if (ElytronMessages.log.isTraceEnabled()) {
        ElytronMessages.log.tracef("X500 principal [%s] decoded as name [%s] (attribute values: [%s])", x500Principal, name, String.join(", ", values));
      }
      return name;
    }
  }
}

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

public String getName(final Principal principal) {
    final X500Principal x500Principal = X500PrincipalUtil.asX500Principal(principal, convert);
    if (x500Principal == null) {
      return null;
    }
    if (requiredOids != null && requiredOids.length != 0 && ! X500PrincipalUtil.containsAllAttributes(x500Principal, requiredOids)) {
      ElytronMessages.log.tracef("X500 principal [%s] was not decoded - does not contain required oids", x500Principal);
      return null;
    }
    final String[] values = X500PrincipalUtil.getAttributeValues(x500Principal, oid, reverse);
    if (values.length == 0) {
      ElytronMessages.log.tracef("X500 principal [%s] was not decoded - no values of attribute [%s]", x500Principal, oid);
      return null;
    } else {
      final String name = Arrays.stream(values).skip(startSegment).limit(maximumSegments).collect(Collectors.joining(joiner));
      if (ElytronMessages.log.isTraceEnabled()) {
        ElytronMessages.log.tracef("X500 principal [%s] decoded as name [%s] (attribute values: [%s])", x500Principal, name, String.join(", ", values));
      }
      return name;
    }
  }
}

相关文章