Class Employee

java.lang.Object
csce331.group13.project2.models.Employee

public class Employee extends Object
Represents an employee in the system with authentication and role information. Uses BCrypt for secure password hashing.
Author:
Varish Kongara, Austin Glander
  • Constructor Details

    • Employee

      public Employee(UUID employeeId, String name, String email, boolean manager, String passwordHash, boolean isActive)
      Constructs an Employee with all fields specified.
      Parameters:
      employeeId - The unique identifier for the employee.
      name - The employee's name.
      email - The employee's email address.
      manager - Whether the employee has manager privileges.
      passwordHash - The BCrypt-hashed password.
      isActive - Whether the employee is currently active.
    • Employee

      public Employee(String name, String email, boolean manager, String passwordHash, boolean isActive)
      Constructs an Employee with a newly generated UUID.
      Parameters:
      name - The employee's name.
      email - The employee's email address.
      manager - Whether the employee has manager privileges.
      passwordHash - The BCrypt-hashed password.
      isActive - Whether the employee is currently active.
  • Method Details

    • hashPassword

      public static String hashPassword(String plainPassword)
      Hashes a plain text password using BCrypt.
      Parameters:
      plainPassword - The plain text password to hash.
      Returns:
      The BCrypt-hashed password.
    • checkPassword

      public boolean checkPassword(String plainPassword)
      Verifies a plain text password against the stored hash.
      Parameters:
      plainPassword - The plain text password to verify.
      Returns:
      true if the password matches; false otherwise.
    • getEmployeeId

      public UUID getEmployeeId()
      Gets the employee's unique identifier.
      Returns:
      The employee ID.
    • getName

      public String getName()
      Gets the employee's name.
      Returns:
      The employee name.
    • setName

      public void setName(String name)
      Sets the employee's name.
      Parameters:
      name - The new name.
    • getEmail

      public String getEmail()
      Gets the employee's email address.
      Returns:
      The email address.
    • setEmail

      public void setEmail(String email)
      Sets the employee's email address.
      Parameters:
      email - The new email address.
    • isManager

      public boolean isManager()
      Checks if the employee has manager privileges.
      Returns:
      true if the employee is a manager; false otherwise.
    • setManager

      public void setManager(boolean manager)
      Sets the employee's manager status.
      Parameters:
      manager - The new manager status.
    • getPasswordHash

      public String getPasswordHash()
      Gets the employee's password hash.
      Returns:
      The BCrypt password hash.
    • setPasswordHash

      public void setPasswordHash(String passwordHash)
      Sets the employee's password hash directly.
      Parameters:
      passwordHash - The BCrypt password hash.
    • setPassword

      public void setPassword(String password)
      Sets the employee's password by hashing the plain text password.
      Parameters:
      password - The plain text password.
    • isActive

      public boolean isActive()
      Checks if the employee is currently active.
      Returns:
      true if the employee is active; false otherwise.
    • setActive

      public void setActive(boolean active)
      Sets the employee's active status.
      Parameters:
      active - The new active status.
    • toString

      public String toString()
      Overrides:
      toString in class Object