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

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

本文整理了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

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

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

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

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

  1. public String getName(final Principal principal) {
  2. final X500Principal x500Principal = X500PrincipalUtil.asX500Principal(principal, convert);
  3. if (x500Principal == null) {
  4. return null;
  5. }
  6. if (requiredOids != null && requiredOids.length != 0 && ! X500PrincipalUtil.containsAllAttributes(x500Principal, requiredOids)) {
  7. ElytronMessages.log.tracef("X500 principal [%s] was not decoded - does not contain required oids", x500Principal);
  8. return null;
  9. }
  10. final String[] values = X500PrincipalUtil.getAttributeValues(x500Principal, oid, reverse);
  11. if (values.length == 0) {
  12. ElytronMessages.log.tracef("X500 principal [%s] was not decoded - no values of attribute [%s]", x500Principal, oid);
  13. return null;
  14. } else {
  15. final String name = Arrays.stream(values).skip(startSegment).limit(maximumSegments).collect(Collectors.joining(joiner));
  16. if (ElytronMessages.log.isTraceEnabled()) {
  17. ElytronMessages.log.tracef("X500 principal [%s] decoded as name [%s] (attribute values: [%s])", x500Principal, name, String.join(", ", values));
  18. }
  19. return name;
  20. }
  21. }
  22. }

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

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

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

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

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

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

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

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

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

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

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

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

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

  1. public String getName(final Principal principal) {
  2. final X500Principal x500Principal = X500PrincipalUtil.asX500Principal(principal, convert);
  3. if (x500Principal == null) {
  4. return null;
  5. }
  6. if (requiredOids != null && requiredOids.length != 0 && ! X500PrincipalUtil.containsAllAttributes(x500Principal, requiredOids)) {
  7. ElytronMessages.log.tracef("X500 principal [%s] was not decoded - does not contain required oids", x500Principal);
  8. return null;
  9. }
  10. final String[] values = X500PrincipalUtil.getAttributeValues(x500Principal, oid, reverse);
  11. if (values.length == 0) {
  12. ElytronMessages.log.tracef("X500 principal [%s] was not decoded - no values of attribute [%s]", x500Principal, oid);
  13. return null;
  14. } else {
  15. final String name = Arrays.stream(values).skip(startSegment).limit(maximumSegments).collect(Collectors.joining(joiner));
  16. if (ElytronMessages.log.isTraceEnabled()) {
  17. ElytronMessages.log.tracef("X500 principal [%s] decoded as name [%s] (attribute values: [%s])", x500Principal, name, String.join(", ", values));
  18. }
  19. return name;
  20. }
  21. }
  22. }

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

  1. public String getName(final Principal principal) {
  2. final X500Principal x500Principal = X500PrincipalUtil.asX500Principal(principal, convert);
  3. if (x500Principal == null) {
  4. return null;
  5. }
  6. if (requiredOids != null && requiredOids.length != 0 && ! X500PrincipalUtil.containsAllAttributes(x500Principal, requiredOids)) {
  7. ElytronMessages.log.tracef("X500 principal [%s] was not decoded - does not contain required oids", x500Principal);
  8. return null;
  9. }
  10. final String[] values = X500PrincipalUtil.getAttributeValues(x500Principal, oid, reverse);
  11. if (values.length == 0) {
  12. ElytronMessages.log.tracef("X500 principal [%s] was not decoded - no values of attribute [%s]", x500Principal, oid);
  13. return null;
  14. } else {
  15. final String name = Arrays.stream(values).skip(startSegment).limit(maximumSegments).collect(Collectors.joining(joiner));
  16. if (ElytronMessages.log.isTraceEnabled()) {
  17. ElytronMessages.log.tracef("X500 principal [%s] decoded as name [%s] (attribute values: [%s])", x500Principal, name, String.join(", ", values));
  18. }
  19. return name;
  20. }
  21. }
  22. }

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

  1. public String getName(final Principal principal) {
  2. final X500Principal x500Principal = X500PrincipalUtil.asX500Principal(principal, convert);
  3. if (x500Principal == null) {
  4. return null;
  5. }
  6. if (requiredOids != null && requiredOids.length != 0 && ! X500PrincipalUtil.containsAllAttributes(x500Principal, requiredOids)) {
  7. ElytronMessages.log.tracef("X500 principal [%s] was not decoded - does not contain required oids", x500Principal);
  8. return null;
  9. }
  10. final String[] values = X500PrincipalUtil.getAttributeValues(x500Principal, oid, reverse);
  11. if (values.length == 0) {
  12. ElytronMessages.log.tracef("X500 principal [%s] was not decoded - no values of attribute [%s]", x500Principal, oid);
  13. return null;
  14. } else {
  15. final String name = Arrays.stream(values).skip(startSegment).limit(maximumSegments).collect(Collectors.joining(joiner));
  16. if (ElytronMessages.log.isTraceEnabled()) {
  17. ElytronMessages.log.tracef("X500 principal [%s] decoded as name [%s] (attribute values: [%s])", x500Principal, name, String.join(", ", values));
  18. }
  19. return name;
  20. }
  21. }
  22. }

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

  1. public String getName(final Principal principal) {
  2. final X500Principal x500Principal = X500PrincipalUtil.asX500Principal(principal, convert);
  3. if (x500Principal == null) {
  4. return null;
  5. }
  6. if (requiredOids != null && requiredOids.length != 0 && ! X500PrincipalUtil.containsAllAttributes(x500Principal, requiredOids)) {
  7. ElytronMessages.log.tracef("X500 principal [%s] was not decoded - does not contain required oids", x500Principal);
  8. return null;
  9. }
  10. final String[] values = X500PrincipalUtil.getAttributeValues(x500Principal, oid, reverse);
  11. if (values.length == 0) {
  12. ElytronMessages.log.tracef("X500 principal [%s] was not decoded - no values of attribute [%s]", x500Principal, oid);
  13. return null;
  14. } else {
  15. final String name = Arrays.stream(values).skip(startSegment).limit(maximumSegments).collect(Collectors.joining(joiner));
  16. if (ElytronMessages.log.isTraceEnabled()) {
  17. ElytronMessages.log.tracef("X500 principal [%s] decoded as name [%s] (attribute values: [%s])", x500Principal, name, String.join(", ", values));
  18. }
  19. return name;
  20. }
  21. }
  22. }

相关文章