Exemplo n.º 1
0
  public String modify() {
    // actually, uses just for account access reset
    DAO dao = new DAO();
    UserManagement userTmp = new UserManagement();
    UserManagement userToModify = new UserManagement();
    userTmp.setUserCode(userToModify.getUserCode());
    UserManagement userFromDB = new UserManagement();
    userFromDB =
        (UserManagement)
            dao.load(
                UserManagement.class,
                UserParamSearchBB.userManagementAPasser.getUserCode(),
                userTmp);
    if (userFromDB.getNbreSessionConnected() != 0) {

      BuildMessage.addMessage(
          null, "User activity detected: ", "  he can't be updated", FacesMessage.SEVERITY_ERROR);

      return null;
    }

    if (!(userName.length() > 0)) {

      BuildMessage.addMessage(
          null, "User validation: ", " User name is required", FacesMessage.SEVERITY_ERROR);
      return null;
    }

    if (ipAddress != null && ipAddress.trim() == "" && ipAddressMang.equals("Y")) {

      BuildMessage.addMessage(
          null, "IP management: ", " User IP address is required", FacesMessage.SEVERITY_ERROR);
      return null;
    }

    if (!(dateEndPass != null) && expirationMang.equals('Y')) {

      BuildMessage.addMessage(
          null,
          "Password management: ",
          " Expiry date for password is required",
          FacesMessage.SEVERITY_ERROR);
      return null;
    }

    buildUserWithoutPassword(userFromDB);

    dao.saveOrUpdate(userFromDB);
    // dao.delete(userFromDB.getUserHabilitationParams());
    returnMessageBeforeTrx(
        "userManagement",
        userFromDB.getUserCode(),
        userFromDB.getUserName(),
        dao.isSuccessOperation(),
        'U');
    dao.getSession().flush();
    UserParamSearchBB.actionDone = false;
    return null;
  }
Exemplo n.º 2
0
  public void validateSecondPassword(FacesContext context, UIComponent toValidate, Object value) {
    String RetapePassword = (String) value;

    if (!RetapePassword.equals(newPassword)) {
      validate = false;
      BuildMessage.addMessage(
          null,
          "Password validation: ",
          "Please, check password confirmation is diferent from password",
          FacesMessage.SEVERITY_ERROR);
    }
  }
  public void validate(FacesContext context, UIComponent component, Object value)
      throws ValidatorException {
    String MessageBundle = "Validator_int";
    String MessageBundle2 = "Port_length";
    Object params[] = null;
    List test = new ArrayList();
    test.add(value);
    params = test.toArray();

    // String text = "^[0-9]*[1-9]+$|^[1-9]+[0-9]*$";

    Pattern mask = Pattern.compile(text);
    Matcher matcher = mask.matcher(value.toString());

    if (!matcher.find()) {

      throw new ValidatorException(
          new FacesMessage(
              BuildMessage.getMessageResourceString(
                  context.getApplication().getMessageBundle(),
                  MessageBundle,
                  params,
                  context.getViewRoot().getLocale())));

    } else {

      if (value.toString().length() < 4) {

        throw new ValidatorException(
            new FacesMessage(
                BuildMessage.getMessageResourceString(
                    context.getApplication().getMessageBundle(),
                    MessageBundle2,
                    params,
                    context.getViewRoot().getLocale())));
      }
    }
  }
Exemplo n.º 4
0
  public String delete() {
    // actually, uses just for account access reset
    DAO dao = new DAO();
    UserManagement userTmp = new UserManagement();
    UserManagement userToModify = new UserManagement();
    userTmp.setUserCode(userToModify.getUserCode());
    UserManagement userFromDB = new UserManagement();
    userFromDB =
        (UserManagement)
            dao.load(
                UserManagement.class,
                UserParamSearchBB.userManagementAPasser.getUserCode(),
                userTmp);
    if (userFromDB.getNbreSessionConnected() != 0) {

      BuildMessage.addMessage(
          null, "User activity detected: ", "  he can't be deleted", FacesMessage.SEVERITY_ERROR);
      UserParamBB.pollEnabled = true;
      UserParamSearchBB.actionDone = true;

      return null;

    } else {
      dao.delete(userFromDB);
      returnMessageBeforeTrx(
          "userManagement",
          userFromDB.getUserCode(),
          userFromDB.getUserName(),
          dao.isSuccessOperation(),
          'D');

      UserParamBB.pollEnabled = true;
      UserParamSearchBB.actionDone = true;
    }

    return null;
  }
Exemplo n.º 5
0
  public String valider() {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    FacesMessage facesMessage = new FacesMessage();
    String message = null;
    DAO dao = new DAO();
    UserManagement userManagement = new UserManagement();
    construct(userManagement);

    if (userPassword != null && userPassword.trim() != "") {

      if (!(userName.length() > 0)) {

        BuildMessage.addMessage(
            null, "User validation: ", "Sorry, user name is required", FacesMessage.SEVERITY_ERROR);
        return null;
      }
      if (userPassword.length() < 8) {

        BuildMessage.addMessage(
            null,
            "Password validation: ",
            "Sorry, user password is invalid",
            FacesMessage.SEVERITY_ERROR);
        return null;
      }
      if (ipAddress != null && ipAddress.trim() == "" && ipAddressMang.equals("Y")) {

        BuildMessage.addMessage(
            null,
            "IP management: ",
            "Sorry, User IP address is required",
            FacesMessage.SEVERITY_ERROR);
        return null;
      }

      if (!(dateEndPass != null) && expirationMang.equals('Y')) {

        BuildMessage.addMessage(
            null,
            "Password management: ",
            "Sorry, Expiry date for password is required",
            FacesMessage.SEVERITY_ERROR);
        return null;
      }

      if (validate) {

        if (checkExistRecord(UserManagement.class, userManagement.getUserCode())) {
          returnMessageIfExistRecord(
              "UserManagement ", userManagement.getUserCode(), userManagement.getUserName());
        } else {
          dao.save(userManagement);
          facesContext.getMessages();
          returnMessageBeforeTrx(
              "User ",
              userManagement.getUserCode(),
              userManagement.getUserName(),
              dao.isSuccessOperation(),
              'I');
          attributeConnecteRole(userManagement);
          if (userManagement.getUserType().equals("S")) {
            attributeSupervisorRole1(userManagement);
            attributeSupervisorRole2(userManagement);
          }
        }

        dao.getSession().flush();
        UserParamSearchBB.actionDone = true;
      }

    } else {

      BuildMessage.addMessage(
          null,
          "Password validation: ",
          "Sorry, user password is invalid",
          FacesMessage.SEVERITY_ERROR);
      return null;
    }
    return null;
  }