Class Employee
java.lang.Object
csce331.group13.project2.models.Employee
Represents an employee in the system with authentication and role information.
Uses BCrypt for secure password hashing.
- Author:
- Varish Kongara, Austin Glander
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancheckPassword(String plainPassword) Verifies a plain text password against the stored hash.getEmail()Gets the employee's email address.Gets the employee's unique identifier.getName()Gets the employee's name.Gets the employee's password hash.static StringhashPassword(String plainPassword) Hashes a plain text password using BCrypt.booleanisActive()Checks if the employee is currently active.booleanChecks if the employee has manager privileges.voidsetActive(boolean active) Sets the employee's active status.voidSets the employee's email address.voidsetManager(boolean manager) Sets the employee's manager status.voidSets the employee's name.voidsetPassword(String password) Sets the employee's password by hashing the plain text password.voidsetPasswordHash(String passwordHash) Sets the employee's password hash directly.toString()
-
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
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
-
checkPassword
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
-
getName
-
setName
-
getEmail
-
setEmail
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
Gets the employee's password hash.- Returns:
- The BCrypt password hash.
-
setPasswordHash
Sets the employee's password hash directly.- Parameters:
passwordHash- The BCrypt password hash.
-
setPassword
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
-