/** * 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; }
/** * 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 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); }
if (isAlpha(currChar)) throw new IllegalArgumentException(dnString); currChar = dnString.charAt(currIndex); if (isDigit(currChar)) else if (isDigit(currChar)) if (isAlpha(currChar) || isDigit(currChar) || (currChar == '-')) tokenBuf[tokenIndex++] = currChar; else if (!isDigit(currChar)) throw new IllegalArgumentException(dnString); firstDigitZero = (currChar == '0') ? true: false; (isDigit(currChar) && firstDigitZero) || while (isDigit(currChar) && (currIndex < lastIndex)){ tokenBuf[tokenIndex++] = currChar; currChar = dnString.charAt(++currIndex); throw new IllegalArgumentException(dnString); currChar = dnString.charAt(++currIndex); if (isHexDigit(currChar)) if (isHexDigit(nextChar)) char tmpc = hexToChar(currChar, nextChar);
DN dn = new DN(base); Identifier id = new Identifier(); try { id.setType(this.getIdentifierType(((RDN)dn.getRDNs().get(0)).getType())); } catch (IllegalArgumentException e1) { throw new LDAPException("Could not determine type",53, e1.toString(), e1); throw new LDAPException("Could not determine type",53, e1.toString(), e1); id.setId(dn.explodeDN(true)[0]);
/** * 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; }