org.edg.security.authorization
Class DNConvert

java.lang.Object
  |
  +--org.edg.security.authorization.DNConvert

public class DNConvert
extends java.lang.Object

This class is made to convert RFC2253-style Distinguished Name to the older X.500 style frequently used in Globus, or vice versa. It also has method to remove "/CN=proxy" or "/CN=limited proxy" or "/CN=12345..." suffixes from a DN, where 12345... are digits only.

Whitespace is removed in the process, in accordance with RFC2253. Thus, the following code

DNConvert c = new DNConvert("CN=proxy, CN = Olle, O= KTH, C=SE");
System.out.println("["+c.removeProxy(DNConvert.RFC2253)+"]);
System.out.println("["+c.removeProxy(DNConvert.X500)+"]");

yields the following result:

[CN=Olle,O=KTH,C=SE]
[/C=SE/O=KTH/CN=Olle]

Version:
$Id: DNConvert.java,v 1.10 2003/09/17 08:05:59 gianluca Exp $
Author:
Ville Nenonen Ville.Nenonen@hut.fi, Olle Mulmo (rewrite)

Field Summary
static int RFC2253
          The style denoting RFC2253 format of the DN
static int X500
          The style denoting the old X.500 format of the DN
 
Constructor Summary
DNConvert(java.lang.String dn)
           
DNConvert(java.lang.String dn, boolean formatEmailAttr)
           
 
Method Summary
 java.lang.String reformat(int style)
          Converts the DN from one style to another.
 java.lang.String removeProxySuffix()
          Removes the proxy extension of the DN.
 java.lang.String removeProxySuffix(int style)
          Removes the proxy extension of the DN.
static void setDefaultEmailAttrFormatting(boolean enabled)
          Redefines the default behavior whether to reformat the email address portion of a DN or not.
 void setFormatEmailAttr(boolean enabled)
          Defines whether to reformat an email attribute in the DN or not
 java.lang.String toString()
           
 java.lang.String trim()
          Removes any whitespace between type-value and RDN delimiters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RFC2253

public static final int RFC2253
The style denoting RFC2253 format of the DN

See Also:
Constant Field Values

X500

public static final int X500
The style denoting the old X.500 format of the DN

See Also:
Constant Field Values
Constructor Detail

DNConvert

public DNConvert(java.lang.String dn)
Parameters:
dn - The Distuingished Name, in either X.500 or RFC2253 format.

DNConvert

public DNConvert(java.lang.String dn,
                 boolean formatEmailAttr)
Parameters:
dn - The Distuingished Name, in either X.500 or RFC2253 format.
formatEmailAttr - If set, will reformat the email attribute
Method Detail

setDefaultEmailAttrFormatting

public static void setDefaultEmailAttrFormatting(boolean enabled)
Redefines the default behavior whether to reformat the email address portion of a DN or not.

Parameters:
enabled -
See Also:
DNConvert(String, boolean), setFormatEmailAttr(boolean)

removeProxySuffix

public java.lang.String removeProxySuffix(int style)
Removes the proxy extension of the DN.

Parameters:
style - The style to reformat to (one of X500 or RFC2253)
Returns:
DN in preferred format without any 'CN=proxy' RDN
See Also:
reformat(int)

setFormatEmailAttr

public void setFormatEmailAttr(boolean enabled)
Defines whether to reformat an email attribute in the DN or not

Parameters:
enabled -

removeProxySuffix

public java.lang.String removeProxySuffix()
Removes the proxy extension of the DN.

Returns:
DN in the current format without any 'CN=proxy' RDN.

trim

public java.lang.String trim()
Removes any whitespace between type-value and RDN delimiters.

Example:" CN=John Doe , O =Org" returns "CN=John Doe,O=Org"

Returns:
String the trimmed DN

reformat

public java.lang.String reformat(int style)
Converts the DN from one style to another.

Parameters:
style - The style to reformat to (one of X500 or RFC2253)
Returns:
The DN in the preferred format.
See Also:
X500, RFC2253

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object