Class X500PrincipalUtil

java.lang.Object
org.wildfly.security.x500.util.X500PrincipalUtil

public final class X500PrincipalUtil extends Object
A utility class for easily accessing details of an X500Principal.
Author:
David M. Lloyd
  • Method Details

    • getAttributeValues

      public static String[] getAttributeValues(X500Principal principal, String oid)
      Get all the values of the attribute with the given OID in the given principal. This includes occurrences within multi-valued RDNs.
      Parameters:
      principal - the principal to examine
      oid - the OID whose values are to be returned
      Returns:
      the list of values associated with the OID
    • getAttributeValues

      public static String[] getAttributeValues(X500Principal principal, String oid, boolean reverse)
      Get all the values of the attribute with the given OID in the given principal. This includes occurrences within multi-valued RDNs.
      Parameters:
      principal - the principal to examine
      oid - the OID whose values are to be returned
      reverse - true if the values in the returned list should be in reverse order
      Returns:
      the list of values associated with the OID
    • containsAllAttributes

      public static boolean containsAllAttributes(X500Principal principal, String... oids)
      Determine if the given principal contains all of the attributes specified by the given OIDs. This includes occurrences within multi-valued RDNs.
      Parameters:
      principal - the principal to examine
      oids - the OIDs of the attributes that must be present in the given principal (must not be null, cannot have null elements)
      Returns:
      true if the given principal contains all of the attributes specified by the given OIDs, false otherwise
    • asX500Principal

      public static X500Principal asX500Principal(Principal principal)
      Attempt to convert the given principal to an X.500 principal.
      Parameters:
      principal - the original principal
      Returns:
      the X.500 principal or null if the principal can not be converted.
    • asX500Principal

      public static X500Principal asX500Principal(Principal principal, boolean convert)
      Attempt to convert the given principal to an X.500 principal.
      Parameters:
      principal - the original principal
      convert - true if the principal should be converted to a X500Principal if not one already.
      Returns:
      the X.500 principal or null if the principal can not be converted.