/**
   * Return <code>true</code> if the specified Principal has the specified security role, within the
   * context of this Realm; otherwise return <code>false</code>. This method can be overridden by
   * Realm implementations, but the default is adequate when an instance of <code>GenericPrincipal
   * </code> is used to represent authenticated Principals from this Realm.
   *
   * @param principal Principal for whom the role is to be checked
   * @param role Security role to be checked
   */
  public boolean hasRole(Principal principal, String role) {

    if ((principal == null) || (role == null) || !(principal instanceof GenericPrincipal))
      return (false);
    GenericPrincipal gp = (GenericPrincipal) principal;
    if (!(gp.getRealm() == this)) return (false);
    boolean result = gp.hasRole(role);
    if (debug >= 2) {
      String name = principal.getName();
      if (result) log(sm.getString("realmBase.hasRoleSuccess", name, role));
      else log(sm.getString("realmBase.hasRoleFailure", name, role));
    }
    return (result);
  }