edu.vt.middleware.crypt.x509
Class DNUtils

java.lang.Object
  extended by edu.vt.middleware.crypt.x509.DNUtils

public final class DNUtils
extends Object

Utility class with convenience methods for common operations performed on X.500 distinguished names.

Version:
$Revision: 2744 $
Author:
Middleware Services

Method Summary
static String getAttributeValue(X500Principal dn, AttributeType attribute)
          Gets the value of the first occurrence of the given attribute in the DN.
static String getAttributeValue(X500Principal dn, String attributeOid)
          Gets the value of the first occurrence of the given attribute in the DN.
static String[] getAttributeValues(X500Principal dn, AttributeType attribute)
          Gets the values of the given attribute contained in the DN.
static String[] getAttributeValues(X500Principal dn, String attributeOid)
          Gets the values of the given attribute contained in the DN.
static String getCN(X500Principal dn)
          Gets the CN attribute from the given X.500 distinguished name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getAttributeValues

public static String[] getAttributeValues(X500Principal dn,
                                          AttributeType attribute)
Gets the values of the given attribute contained in the DN.

NOTE: no escaping is done on special characters in the values, which could be different from what would appear in the string representation of the DN.

Parameters:
dn - X.500 distinguished name.
attribute - Attribute whose values will be retrieved.
Returns:
The attribute values for the given attribute in the order they appear would appear in the string representation of the DN or an empty array if the given attribute does not exist.

getAttributeValues

public static String[] getAttributeValues(X500Principal dn,
                                          String attributeOid)
Gets the values of the given attribute contained in the DN.

NOTE: no escaping is done on special characters in the values, which could be different from what would appear in the string representation of the DN.

Parameters:
dn - X.500 distinguished name.
attributeOid - OID of attribute whose values will be retrieved.
Returns:
The attribute values for the given attribute in the order they appear would appear in the string representation of the DN or an empty array if the given attribute does not exist.

getAttributeValue

public static String getAttributeValue(X500Principal dn,
                                       AttributeType attribute)
Gets the value of the first occurrence of the given attribute in the DN.

NOTE: no escaping is done on special characters in the values, which could be different from what would appear in the string representation of the DN.

Parameters:
dn - X.500 distinguished name.
attribute - Attribute whose value will be retrieved.
Returns:
Value of first occurrence of given attribute or null if the attribute does not exist. The first occurrence is determined by the ordering that would result from the string representation of the DN.

getAttributeValue

public static String getAttributeValue(X500Principal dn,
                                       String attributeOid)
Gets the value of the first occurrence of the given attribute in the DN.

NOTE: no escaping is done on special characters in the values, which could be different from what would appear in the string representation of the DN.

Parameters:
dn - X.500 distinguished name.
attributeOid - OID of attribute whose value will be retrieved.
Returns:
Value of first occurrence of given attribute or null if the attribute does not exist. The first occurrence is determined by the ordering that would result from the string representation of the DN.

getCN

public static String getCN(X500Principal dn)
Gets the CN attribute from the given X.500 distinguished name.

NOTE: no escaping is done on special characters in the CN, which could be different from what would appear in the string representation of the DN.

Parameters:
dn - DN from which to extract common name attribute.
Returns:
Common name or null if no CN exists. If the DN contains multiple CN attributes, only the first one is returned, where the ordering of attributes is the same as that of the string representation of the DN.


Copyright © 2003-2013 Virginia Tech. All Rights Reserved.