/**
  * Returns <CODE>true</CODE> if the the provided strings represent the same DN and <CODE>false
  * </CODE> otherwise.
  *
  * @param dn1 the first dn to compare.
  * @param dn2 the second dn to compare.
  * @return <CODE>true</CODE> if the the provided strings represent the same DN and <CODE>false
  *     </CODE> otherwise.
  */
 private static boolean areDnsEqual(String dn1, String dn2) {
   boolean areDnsEqual = false;
   try {
     LdapName name1 = new LdapName(dn1);
     LdapName name2 = new LdapName(dn2);
     areDnsEqual = name1.equals(name2);
   } catch (Exception ex) {
     /* ignore */
   }
   return areDnsEqual;
 }
Esempio n. 2
0
  /**
   * Compares this principal to the specified object.
   *
   * @param object The object to compare this principal against.
   * @return true if they are equal; false otherwise.
   */
  public boolean equals(Object object) {
    if (this == object) {
      return true;
    }
    if (object instanceof LdapPrincipal) {
      try {

        return name.equals(getLdapName(((LdapPrincipal) object).getName()));

      } catch (InvalidNameException e) {
        return false;
      }
    }
    return false;
  }