Class AuthenticationService
java.lang.Object
com.fiap.tech_challenge.parte1.ms_users.services.AuthenticationService
- All Implemented Interfaces:
org.springframework.security.core.userdetails.UserDetailsService
@Service
public class AuthenticationService
extends Object
implements org.springframework.security.core.userdetails.UserDetailsService
Service that implements Spring Security's UserDetailsService to load user-specific data.
Used during authentication to retrieve user details from the repository by username (login).
-
Constructor Summary
ConstructorsConstructorDescriptionAuthenticationService
(UserRepository userRepository) Constructs an AuthenticationService with the given UserRepository. -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.security.core.userdetails.UserDetails
loadUserByUsername
(String username) Locates the user based on the provided username (login).
-
Constructor Details
-
AuthenticationService
Constructs an AuthenticationService with the given UserRepository.- Parameters:
userRepository
- the user repository used to load user data
-
-
Method Details
-
loadUserByUsername
public org.springframework.security.core.userdetails.UserDetails loadUserByUsername(String username) throws org.springframework.security.core.userdetails.UsernameNotFoundException Locates the user based on the provided username (login). This method is used by Spring Security during the authentication process.- Specified by:
loadUserByUsername
in interfaceorg.springframework.security.core.userdetails.UserDetailsService
- Parameters:
username
- the username (login) identifying the user whose data is required.- Returns:
- a fully populated UserDetails object (used by Spring Security)
- Throws:
org.springframework.security.core.userdetails.UsernameNotFoundException
- if the user could not be found
-