예제 #1
0
  public void editEventCreationPrivilege(boolean eventCreationPrivilege)
      throws PrivilegeInsufficientException, DoesNotExistException {

    User loggedInUser = logInManager.getLoggedInUser();
    if (PrivilegeManager.hasAdminPrivilege(loggedInUser)) {
      selectedUser.setEventCreationPrivilege(eventCreationPrivilege);
      usersTable.setLevel(selectedUser.getUserId(), eventCreationPrivilege == true ? 1 : 0);
    }
  }
예제 #2
0
  public void editPhoneNumber(PhoneNumber phoneNumber)
      throws PrivilegeInsufficientException, DoesNotExistException {

    User loggedInUser = logInManager.getLoggedInUser();
    if (PrivilegeManager.hasUserPrivilege(loggedInUser, selectedUser)) {
      selectedUser.setPhoneNumber(phoneNumber);
      usersTable.setPhone(selectedUser.getUserId(), phoneNumber.toString());
    }
  }
예제 #3
0
  public void editAddress(Address address)
      throws PrivilegeInsufficientException, DoesNotExistException {

    User loggedInUser = logInManager.getLoggedInUser();
    if (PrivilegeManager.hasUserPrivilege(loggedInUser, selectedUser)) {
      selectedUser.setAddress(address);
      usersTable.setAddress(selectedUser.getUserId(), address);
    }
  }
예제 #4
0
  public void editLastName(String lastName)
      throws PrivilegeInsufficientException, DoesNotExistException {

    User loggedInUser = logInManager.getLoggedInUser();
    if (PrivilegeManager.hasUserPrivilege(loggedInUser, selectedUser)) {
      selectedUser.setLastName(lastName);
      usersTable.setLastName(selectedUser.getUserId(), lastName);
    }
  }
예제 #5
0
  public void editPassword(String password, String passwordMatch)
      throws IllegalCharacterException, PasswordMismatchError, PrivilegeInsufficientException,
          DoesNotExistException, InvalidKeyException, UnsupportedEncodingException,
          IllegalBlockSizeException, BadPaddingException {

    User loggedInUser = logInManager.getLoggedInUser();
    if (PrivilegeManager.hasUserPrivilege(loggedInUser, selectedUser)) {
      selectedUser.setPassword(password, passwordMatch);
      usersTable.setPwd(selectedUser.getUserId(), password);
    }
  }
예제 #6
0
  public User createUser(User user) throws DuplicateEmailException {

    if (usersTable.checkEmail(user.getEmailAddress())) {
      throw new DuplicateEmailException("Email address already exists in the system");
    } else {
      User newUser = new User(usersTable.createUser(new InputUser(user)), user);
      userList.add(newUser);
      return newUser;
    }
  }
예제 #7
0
  private User rebuildUser(int userID) throws DoesNotExistException {

    User user =
        new User(
            userID,
            usersTable.getFirstName(userID),
            usersTable.getLastName(userID),
            usersTable.getEmail(userID),
            usersTable.getPwd(userID));

    user.setAdminPrivilege(usersTable.getLevel(userID) == 1 ? true : false);
    user.setEventCreationPrivilege(
        usersTable.getEventCreationPrivilege(userID) == 1 ? true : false);
    user.setPhoneNumber(new PhoneNumber(usersTable.getPhone(userID)));
    user.setAddress(
        new Address(
            usersTable.getStreet(userID),
            usersTable.getCity(userID),
            usersTable.getState(userID),
            usersTable.getZipcode(userID),
            usersTable.getCountry(userID)));

    return user;
  }
예제 #8
0
 public void deleteUser(User user) throws DoesNotExistException {
   userList.remove(selectedUser);
   usersTable.removeUser(selectedUser.getUserId());
 }
예제 #9
0
  ///////////////////// GETTERS ////////////////////////////
  public User getUser(int uid) throws DoesNotExistException {
    try {

      PreparedStatement idQueryStmt =
          dbConnection.prepareStatement("SELECT * FROM USERS WHERE UID=?");
      idQueryStmt.setInt(1, uid);
      ResultSet rs = idQueryStmt.executeQuery();

      User user = new User();
      Address address = new Address();

      while (rs.next()) {

        if (rs.getInt("LEVEL") == 1) {
          user.setAdminPrivilege(true);
        } else {
          user.setAdminPrivilege(false);
        }

        user.setFirstName(rs.getString("FNAME"));

        user.setLastName(rs.getString("LNAME"));

        try {
          user.setPassword(rs.getString("PWD"), rs.getString("PWD")); // fix this
        } catch (IllegalCharacterException ice) {
          debugLog.severe("password issues");
        } catch (PasswordMismatchError pme) {
          debugLog.severe("password issues");
        }

        user.setEmailAddress(rs.getString("EMAIL"));

        user.setPhoneNumber(null);

        address.setStreet(rs.getString("STREET"));

        address.setCity(rs.getString("CITY"));

        address.setState(rs.getString("STATE"));

        address.setZipCode(rs.getString("ZIPCODE"));

        address.setCountry(rs.getString("COUNTRY"));

        user.setAddress(address); // insert address into user.

        if (rs.getInt("EVENTLEVEL") == 1) {
          user.setEventCreationPrivilege(true);
        } else {
          user.setEventCreationPrivilege(false);
        }
      }

    } catch (SQLException sqle) {
      sqle.printStackTrace();
      System.exit(1);
    }

    throw new DoesNotExistException("User does not exist in USERS table");
  }