Package org.wildfly.security.x500.util
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 anX500Principal
.- Author:
- David M. Lloyd
-
-
Field Summary
Fields Modifier and Type Field Description private static MethodHandle
AS_X500_PRINCIPAL_HANDLE
private static String[]
NO_STRINGS
private static Class<?>
X500_NAME_CLASS
-
Constructor Summary
Constructors Modifier Constructor Description private
X500PrincipalUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static X500Principal
asX500Principal(Principal principal)
Attempt to convert the given principal to an X.500 principal.static X500Principal
asX500Principal(Principal principal, boolean convert)
Attempt to convert the given principal to an X.500 principal.static boolean
containsAllAttributes(X500Principal principal, String... oids)
Determine if the given principal contains all of the attributes specified by the given OIDs.static String[]
getAttributeValues(X500Principal principal, String oid)
Get all the values of the attribute with the given OID in the given principal.static String[]
getAttributeValues(X500Principal principal, String oid, boolean reverse)
Get all the values of the attribute with the given OID in the given principal.
-
-
-
Field Detail
-
NO_STRINGS
private static final String[] NO_STRINGS
-
X500_NAME_CLASS
private static final Class<?> X500_NAME_CLASS
-
AS_X500_PRINCIPAL_HANDLE
private static final MethodHandle AS_X500_PRINCIPAL_HANDLE
-
-
Method Detail
-
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 examineoid
- 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 examineoid
- the OID whose values are to be returnedreverse
-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 examineoids
- the OIDs of the attributes that must be present in the given principal (must not benull
, cannot havenull
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 principalconvert
-true
if the principal should be converted to aX500Principal
if not one already.- Returns:
- the X.500 principal or
null
if the principal can not be converted.
-
-