* Performs validation on the User class by passing the User object from the form submission to
   * the {@link UserService#validate(User,Map,boolean,String,String)} method. In order to accomodate
   * the username and email variations on the {@link DefaultUser} class, this checks the
   * configuration to see if the {@link UserConfiguration#isUsernameSameAsEmail()} method returns
   * true and if it does, it assumes that the form only has a field for the username and copies that
   * value from the username property to the email property.
  public void validate() {
    // It is okay to create the user as a side-effect because it will be empty
    if (user == null) {
      user = new DefaultUser();

    if (userConfiguration.isUsernameSameAsEmail()) {

    ErrorList errors =
        userService.validate(user, associations, user.getId() != null, password, passwordConfirm);
    if (!errors.isEmpty()) {
      for (net.java.error.Error error : errors) {
        PropertyError pe = (PropertyError) error;
        messageStore.addFieldError(MessageScope.REQUEST, pe.getProperty(), pe.getMessage());
  * @return The Map of settings for the forms. These settings are boolean flags and are fetched
  *     from the {@link UserConfiguration#getDomainFlags()} method. Defaults to true.
 public Map<String, Boolean> getSettings() {
   return userConfiguration.getDomainFlags();