/** * Returns true if the string conforms to distinguished name syntax. * @param dn String to evaluate fo distinguished name syntax. * @return true if the dn is valid. */ public static boolean isValid(String dn){ try { new DN(dn); } catch (IllegalArgumentException iae){ return false; } return true; }
/** * Returns the Parent of this DN * @return Parent DN */ public DN getParent(){ DN parent = new DN(); parent.rdnList = (ArrayList)this.rdnList.clone(); if (parent.rdnList.size() >= 1) parent.rdnList.remove(0); //remove first object return parent; }
/** * Compares the two strings per the distinguishedNameMatch equality matching * (using case-ignore matching). IllegalArgumentException is thrown if one * or both DNs are invalid. UnsupportedOpersationException is thrown if the * API implementation is not able to detemine if the DNs match or not. * * @param dn1 String form of the first DN to compare. *<br><br> * @param dn2 String form of the second DN to compare. * * @return Returns true if the two strings correspond to the same DN; false * if the DNs are different. */ public static boolean equals (String dn1, String dn2) { DN dnA = new DN(dn1); DN dnB = new DN(dn2); return dnA.equals(dnB); }
/** * Returns the DN normalized by removal of non-significant space characters * as per RFC 2253, section4. * * @return a normalized string */ public static String normalize(String dn){ DN testDN = new DN(dn); return testDN.toString(); }
/** * Creates an RDN object from the DN component specified in the string RDN * * @param rdn the DN component */ public RDN(String rdn){ rawValue = rdn; DN dn = new DN(rdn); Vector rdns = dn.getRDNs(); //there should only be one rdn if (rdns.size() != 1) throw new IllegalArgumentException("Invalid RDN: see API " + "documentation"); RDN thisRDN = (RDN)(rdns.elementAt(0)); this.types = thisRDN.types; this.values = thisRDN.values; this.rawValue = thisRDN.rawValue; return; }
/** * Returns the individual components of a distinguished name (DN). * * @param dn The distinguished name, for example, "cn=Babs * Jensen,ou=Accounting,o=Acme,c=US" *<br><br> * @param noTypes If true, returns only the values of the * components and not the names. For example, "Babs * Jensen", "Accounting", "Acme", "US" instead of * "cn=Babs Jensen", "ou=Accounting", "o=Acme", and * "c=US". * * @return An array of strings representing the individual components * of a DN, or null if the DN is not valid. */ public static String[] explodeDN(String dn, boolean noTypes) { DN dnToExplode = new DN(dn); return dnToExplode.explodeDN(noTypes); }
DN dn = new DN(dnString); DN containerDN = dn.getParent(); Vector<RDN> containerRDNs = containerDN.getRDNs();
DN dn = new DN(base);
DN dn = new DN(entry.getDN());
DN dnVal = new DN(dn);