org.wildfly.security.x500.util.X500PrincipalUtil类的使用及代码示例

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

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

X500PrincipalUtil介绍

[英]A utility class for easily accessing details of an X500Principal.
[中]用于轻松访问X500主体详细信息的实用程序类。

代码示例

代码示例来源: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: wildfly/wildfly

/**
 * Attempt to convert the given principal to an X.500 principal.
 *
 * @param principal the original principal
 * @return the X.500 principal or {@code null} if the principal can not be converted.
 */
public static X500Principal asX500Principal(Principal principal) {
  return asX500Principal(principal, false);
}

代码示例来源: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

return new KeyStoreRealmIdentity(name);
} else {
  final X500Principal x500Principal = X500PrincipalUtil.asX500Principal(principal);
  if (x500Principal == null) {
    log.tracef("KeyStoreRealm: conversion of principal [%s] to X500Principal failed", principal);
        if (keyStore.isCertificateEntry(alias)) {
          final Certificate certificate = keyStore.getCertificate(alias);
          if (certificate instanceof X509Certificate && x500Principal.equals(X500PrincipalUtil.asX500Principal(((X509Certificate) certificate).getSubjectX500Principal()))) {
            log.tracef("KeyStoreRealm: certificate found by X500Principal in alias [%s]", alias);
            return new KeyStoreRealmIdentity(alias);

代码示例来源: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: 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: wildfly/wildfly

throw ElytronMessages.log.emptyChainNotTrusted();
Principal principal = X500PrincipalUtil.asX500Principal(chain[0].getSubjectX500Principal());
if (principal == null) {
  throw ElytronMessages.log.notTrusted(null);

代码示例来源: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-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.wildfly.security/wildfly-elytron

/**
 * Attempt to convert the given principal to an X.500 principal.
 *
 * @param principal the original principal
 * @return the X.500 principal or {@code null} if the principal can not be converted.
 */
public static X500Principal asX500Principal(Principal principal) {
  return asX500Principal(principal, false);
}

代码示例来源: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-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;
    }
  }
}

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

/**
 * Attempt to convert the given principal to an X.500 principal.
 *
 * @param principal the original principal
 * @return the X.500 principal or {@code null} if the principal can not be converted.
 */
public static X500Principal asX500Principal(Principal principal) {
  return asX500Principal(principal, 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.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

/**
 * Attempt to convert the given principal to an X.500 principal.
 *
 * @param principal the original principal
 * @return the X.500 principal or {@code null} if the principal can not be converted.
 */
public static X500Principal asX500Principal(Principal principal) {
  return asX500Principal(principal, false);
}

代码示例来源: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.wildfly.security/wildfly-elytron

return new KeyStoreRealmIdentity(name);
} else {
  final X500Principal x500Principal = X500PrincipalUtil.asX500Principal(principal);
  if (x500Principal == null) {
    log.tracef("KeyStoreRealm: conversion of principal [%s] to X500Principal failed", principal);
        if (keyStore.isCertificateEntry(alias)) {
          final Certificate certificate = keyStore.getCertificate(alias);
          if (certificate instanceof X509Certificate && x500Principal.equals(X500PrincipalUtil.asX500Principal(((X509Certificate) certificate).getSubjectX500Principal()))) {
            log.tracef("KeyStoreRealm: certificate found by X500Principal in alias [%s]", alias);
            return new KeyStoreRealmIdentity(alias);

代码示例来源: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.jboss.eap/wildfly-client-all

return new KeyStoreRealmIdentity(name);
} else {
  final X500Principal x500Principal = X500PrincipalUtil.asX500Principal(principal);
  if (x500Principal == null) {
    log.tracef("KeyStoreRealm: conversion of principal [%s] to X500Principal failed", principal);
        if (keyStore.isCertificateEntry(alias)) {
          final Certificate certificate = keyStore.getCertificate(alias);
          if (certificate instanceof X509Certificate && x500Principal.equals(X500PrincipalUtil.asX500Principal(((X509Certificate) certificate).getSubjectX500Principal()))) {
            log.tracef("KeyStoreRealm: certificate found by X500Principal in alias [%s]", alias);
            return new KeyStoreRealmIdentity(alias);

相关文章