Class SecurityService
java.lang.Object
com.jk.webstack.security.services.SecurityService
- All Implemented Interfaces:
 org.springframework.security.core.userdetails.UserDetailsService
public class SecurityService
extends Object
implements org.springframework.security.core.userdetails.UserDetailsService
This class provides user authentication and account management functionality
 for a web application.
 
 It implements the UserDetailsService interface for loading user
 details and managing user accounts.
- Version:
 - 1.0
 - Author:
 - Dr. Jalal H. Kiswani
 
- 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionvoidchangePassword(String userName, String currentPassword, String newPassword) This method change a user's password.This method create a user account with the provided details.protected UserfindAccountUsername(String username) This method find a user account by user name.protected voidinit()This method initializes the service, creating a default user and role if none exist.loadUserByUsername(String username) This method loads a user by their user name.protected voidprocessCurrentAccount(User account) This method process an existing user account.protected voidprocessNewAccount(User account) This method process the creation of a new user account.protected voidresetAccount(User account) This method reset a user's account by generating a new password.resetAccount(String username) This method reset a user's account by generating a new password. 
- 
Constructor Details
- 
SecurityService
public SecurityService()This method constructs a newSecurityService. 
 - 
 - 
Method Details
- 
init
protected void init()This method initializes the service, creating a default user and role if none exist. - 
loadUserByUsername
public User loadUserByUsername(String username) throws org.springframework.security.core.userdetails.UsernameNotFoundException This method loads a user by their user name.- Specified by:
 loadUserByUsernamein interfaceorg.springframework.security.core.userdetails.UserDetailsService- Parameters:
 username- Specifies the user name of the user to load.- Returns:
 - the User object representing the loaded user.
 - Throws:
 org.springframework.security.core.userdetails.UsernameNotFoundException- if the user is not found.
 - 
createAccount
public User createAccount(String username, String firstname, String lastname, String password, UserRole role) This method create a user account with the provided details.- Parameters:
 username- Specifies the user name for the new account.firstname- Specifies the first name for the new account.lastname- Specifies the last name for the new account.password- Specifies the password for the new account.role- Specifies the UserRole associated with the new account.- Returns:
 - the User object representing the created account.
 
 - 
processNewAccount
This method process the creation of a new user account.- Parameters:
 account- Specifies the new account.
 - 
processCurrentAccount
This method process an existing user account.- Parameters:
 account- Specifies the existing account.
 - 
resetAccount
This method reset a user's account by generating a new password.- Parameters:
 username- Specifies the user name of the account to reset.- Returns:
 - the User object representing the reset account.
 
 - 
resetAccount
This method reset a user's account by generating a new password.- Parameters:
 account- Specifies the account to reset.
 - 
findAccountUsername
This method find a user account by user name.- Parameters:
 username- Specifies the user name to search for.- Returns:
 - the User object representing the found account.
 
 - 
changePassword
This method change a user's password.- Parameters:
 userName- Specifies the user name of the user whose password is being changed.currentPassword- Specifies the user's current password.newPassword- Specifies the new password to set.
 
 -