private boolean isUserValid(AuthenticationDescriptor model, char[] password) {

        boolean valid = false;

        try {
            char[] hpwd = hashPassword(password);
            
            if (model != null) {
                
                char[] passwd = model.getPassword().toCharArray();
                
                if (HEX.equalsIgnoreCase(getProperty(PARAM_ENCODING))) {
                    valid = true;
                    //Do a case-insensitive equals
                    if (hpwd.length == passwd.length) {
                        for (int i = 0; i < hpwd.length; i++) {
                            if (!(Character.toLowerCase(passwd[i]) == Character.toLowerCase(hpwd[i]))) {
                                valid = false;
                                break;
                            }
                        }
                    } else {
                        valid = false;
                    }
                } else {
                    valid = Arrays.equals(passwd, hpwd);
                }
            }
        } catch (Exception ex) {
            _logger.log(Level.SEVERE, "restrealm.invaliduser", model.getName());
            if (_logger.isLoggable(Level.FINE)) {
                _logger.log(Level.FINE, "Cannot validate user", ex);
            }
        } 
        return valid;
    }