Esempio n. 1
0
  /** Validate Username field data is acceptable */
  public void validateUsername(FacesContext context, UIComponent component, Object value)
      throws ValidatorException {
    int minUsernameLength = Application.getClientConfig(context).getMinUsernameLength();

    String name = ((String) value).trim();
    if (name.length() < minUsernameLength || name.length() > 256) {
      String err =
          MessageFormat.format(
              Application.getMessage(context, LoginBean.MSG_USERNAME_LENGTH),
              new Object[] {minUsernameLength, 256});
      throw new ValidatorException(new FacesMessage(err));
    }
    if (name.indexOf('"') != -1 || name.indexOf('\\') != -1) {
      String err =
          MessageFormat.format(
              Application.getMessage(context, LoginBean.MSG_USER_ERR), new Object[] {"\", \\"});
      throw new ValidatorException(new FacesMessage(err));
    }

    try {
      name = PersonServiceImpl.updateUsernameForTenancy(name, getTenantService());
    } catch (TenantDomainMismatchException e) {
      String err =
          MessageFormat.format(
              Application.getMessage(FacesContext.getCurrentInstance(), ERROR_DOMAIN_MISMATCH),
              e.getTenantA(),
              e.getTenantB());
      throw new ValidatorException(new FacesMessage(err));
    }
  }
Esempio n. 2
0
 public boolean checkTenantUserName() {
   try {
     this.userName = PersonServiceImpl.updateUsernameForTenancy(this.userName, getTenantService());
     return true;
   } catch (TenantDomainMismatchException e) {
     Utils.addErrorMessage(
         MessageFormat.format(
             Application.getMessage(FacesContext.getCurrentInstance(), ERROR_DOMAIN_MISMATCH),
             e.getTenantA(),
             e.getTenantB()));
     return false;
   }
 }