Hashtable dntable = new Hashtable(); String o = null; DERObjectIdentifier oid=null; Collection coll = new ArrayList();
Vector oldordering = new Vector(); Vector oldvalues = new Vector();
    public static X509Name stringToBcX509Name(String dn) {        cat.debug(">stringToBcX509Name: " + dn);        // Strip bad chars        String stipeddn = StringTools.strip(dn);        String trimmeddn = stipeddn.trim();        StringTokenizer st = new StringTokenizer(trimmeddn, ",=");        Hashtable dntable = new Hashtable();        String o = null;        DERObjectIdentifier oid=null;        Collection coll = new ArrayList();        while (st.hasMoreTokens()) {            o = st.nextToken();            if (o.trim().equalsIgnoreCase("C")) {                oid = X509Name.C;                coll.add(X509Name.C);            }            else if (o.trim().equalsIgnoreCase("DC")) {                oid = X509Name.DC;                coll.add(X509Name.DC);            }            else if (o.trim().equalsIgnoreCase("ST")) {                oid = X509Name.ST;                coll.add(X509Name.ST);            }            else if (o.trim().equalsIgnoreCase("L")) {                oid = X509Name.L;                coll.add(X509Name.L);            }            else if (o.trim().equalsIgnoreCase("O")) {                oid = X509Name.O;                coll.add(X509Name.O);            }            else if (o.trim().equalsIgnoreCase("OU")) {                oid = X509Name.OU;                coll.add(X509Name.OU);            }            else if (o.trim().equalsIgnoreCase("SN")) {                oid = X509Name.SN;                coll.add(X509Name.SN);            }            else if (o.trim().equalsIgnoreCase("CN")) {                oid = X509Name.CN;                coll.add(X509Name.CN);            }            else if (o.trim().equalsIgnoreCase("EmailAddress")) {                oid = X509Name.EmailAddress;                coll.add(X509Name.EmailAddress);            }            else                oid=null; // Just drop unknown entries in the DN            if (oid != null)                dntable.put(oid, st.nextToken());        }        Vector order = new Vector();        order.add(X509Name.EmailAddress);        order.add(X509Name.CN);        order.add(X509Name.SN);        order.add(X509Name.OU);        order.add(X509Name.O);        order.add(X509Name.L);        order.add(X509Name.ST);        order.add(X509Name.DC);        order.add(X509Name.C);        order.retainAll(coll);        cat.debug(order.toString());        cat.debug(dntable.toString());        cat.debug("<stringToBcX509Name");        return new X509Name(order, dntable);    }