Class AuthenticationService
java.lang.Object
callofproject.dev.authentication.service.AuthenticationService
@Service("callofproject.dev.authentication.service.authentication")
@Lazy
public class AuthenticationService
extends Object
Service class for authentication-related operations.
It implements the IAuthenticationService interface.
-
Constructor Summary
ConstructorsConstructorDescriptionAuthenticationService(UserManagementService userManagementService, org.springframework.security.authentication.AuthenticationProvider authenticationProvider, org.springframework.security.crypto.password.PasswordEncoder passwordEncoder, KafkaProducer kafkaProducer, callofproject.dev.repository.authentication.dal.UserServiceHelper serviceHelper, callofproject.dev.repository.authentication.repository.rdbms.IUserRepository userRepository, ExecutorService executorService) Constructor for the AuthenticationService class. -
Method Summary
Modifier and TypeMethodDescriptionauthenticate(AuthenticationRequest request) Login operation for users.Optional<callofproject.dev.repository.authentication.entity.User>findUserByUsername(String username) Find user by username.booleanrefreshToken(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Refresh token.register(RegisterRequest request) Register user with given RegisterRequest parameter.Iterable<callofproject.dev.repository.authentication.entity.User>registerAll(List<RegisterRequest> requests) Register all users with given RegisterRequest list parameter.registerUserCallback(RegisterRequest request) Register user with given RegisterRequest parameter.voidSend authentication email.booleanvalidateToken(String token) Validate given token.callofproject.dev.data.common.clas.ResponseMessage<Object>verifyUserAndRegister(String token) Verify user and register.
-
Constructor Details
-
AuthenticationService
public AuthenticationService(@Qualifier("callofproject.dev.authentication.service.usermanagement") UserManagementService userManagementService, org.springframework.security.authentication.AuthenticationProvider authenticationProvider, org.springframework.security.crypto.password.PasswordEncoder passwordEncoder, KafkaProducer kafkaProducer, callofproject.dev.repository.authentication.dal.UserServiceHelper serviceHelper, callofproject.dev.repository.authentication.repository.rdbms.IUserRepository userRepository, ExecutorService executorService) Constructor for the AuthenticationService class. It is used to inject dependencies into the service.- Parameters:
userManagementService- The UserManagementService object to be injected.authenticationProvider- The AuthenticationProvider object to be injected.passwordEncoder- The PasswordEncoder object to be injected.kafkaProducer- The KafkaProducer object to be injected.serviceHelper- The UserServiceHelper object to be injected.userRepository- The IUserRepository object to be injected.executorService- The ExecutorService object to be injected.
-
-
Method Details
-
register
Register user with given RegisterRequest parameter.- Parameters:
request- represent the request.- Returns:
- AuthenticationResponse.
-
authenticate
Login operation for users.- Parameters:
request- represent the AuthenticationRequest- Returns:
- the AuthenticationResponse
-
validateToken
Validate given token.- Parameters:
token- represent the jwt.- Returns:
- boolean value.
-
registerUserCallback
Register user with given RegisterRequest parameter.- Parameters:
request- represent the request.- Returns:
- AuthenticationResponse.
-
sendAuthenticationEmail
Send authentication email.- Parameters:
dto- represent the UserSignUpRequestDTO.
-
verifyUserAndRegister
public callofproject.dev.data.common.clas.ResponseMessage<Object> verifyUserAndRegister(String token) Verify user and register.- Parameters:
token- represent the token.- Returns:
- ResponseMessage
-
registerAll
public Iterable<callofproject.dev.repository.authentication.entity.User> registerAll(List<RegisterRequest> requests) Register all users with given RegisterRequest list parameter.- Parameters:
requests- represent the RegisterRequest list.- Returns:
- Users.
-
refreshToken
public boolean refreshToken(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws IOException Refresh token.- Parameters:
request- represent the request.response- represent the response.- Returns:
- boolean value.
- Throws:
IOException- if an I/O error occurs.
-
findUserByUsername
public Optional<callofproject.dev.repository.authentication.entity.User> findUserByUsername(String username) Find user by username.- Parameters:
username- represent the username.- Returns:
- User.
-