Class AbstractLoginService<T extends es.kukenan.smartfi.microservice.clients.dto.LoginDto>
java.lang.Object
es.kukenan.smartfi.microservice.clients.service.login.strategy.AbstractLoginService<T>
- Type Parameters:
T- Type of login dto.
- All Implemented Interfaces:
LoginServiceStrategy<T>
- Direct Known Subclasses:
LoginBasicService,LoginBiometricService,LoginRememberService
public abstract class AbstractLoginService<T extends es.kukenan.smartfi.microservice.clients.dto.LoginDto>
extends Object
implements LoginServiceStrategy<T>
Absttract class for login strategy pattern.
-
Field Summary
FieldsModifier and TypeFieldDescriptionService properties for retries and unlocking time.private AmqpControllerGenerate MQ to update other microservices.private InternalProductsApiClientCore api client.private es.kukenan.smartfi.common.service.jwt.JwtServiceJwt service.private KafkaControllerKafka Controller.protected ServiceUtilitiesService Utilities for users services.private UserDeviceRepositoryRepository for users devices..protected UserRepositoryUser repository use for database queries.private UserUpdatedEventMapperEvent update user state.protected static final ZoneIdUniversal Time CoordinatedZoneIdvalue. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract booleancheckCredentials(T loginDto, User user) Check the given user credentials (found with the given login details).protected es.kukenan.smartfi.microservice.clients.dto.LoginResponseDtocheckSca(User user, es.kukenan.smartfi.microservice.clients.dto.LoginDto loginDto, es.kukenan.smartfi.microservice.clients.dto.LoginResponseDto loginResponseDto) Check user SCA access date.private voidcheckUserState(User user) Check the given user state.protected abstract es.kukenan.smartfi.microservice.clients.dto.LoginResponseDtocreateLoginResponse(T loginDto, User user) Create specific response for ok login.protected abstract UserfindUserInDb(T loginDto) Find the user in the database with the given login details.protected UserhandleTemporaryLocks(User user, boolean credentialsOk) Handle user temporary locks.protected ZonedDateTimeGet last login date from the given user entity.es.kukenan.smartfi.microservice.clients.dto.LoginResponseDtoLogin process.protected voidUpdate to zero count access errors.
-
Field Details
-
ZONE_UTC
Universal Time CoordinatedZoneIdvalue. -
userRepository
User repository use for database queries. -
userDeviceRepository
Repository for users devices.. -
serviceUtilities
Service Utilities for users services. -
accessManagementService
Service properties for retries and unlocking time. -
userUpdatedEventMapper
Event update user state. -
amqpController
Generate MQ to update other microservices. -
kafkaController
Kafka Controller. -
internalProductsApiClient
Core api client. -
jwtService
@Autowired private es.kukenan.smartfi.common.service.jwt.JwtService jwtServiceJwt service.
-
-
Constructor Details
-
AbstractLoginService
public AbstractLoginService()
-
-
Method Details
-
createLoginResponse
protected abstract es.kukenan.smartfi.microservice.clients.dto.LoginResponseDto createLoginResponse(T loginDto, User user) Create specific response for ok login.- Parameters:
loginDto- Type of login dto.user- user data found.- Returns:
- login response.
-
checkSca
protected es.kukenan.smartfi.microservice.clients.dto.LoginResponseDto checkSca(User user, es.kukenan.smartfi.microservice.clients.dto.LoginDto loginDto, es.kukenan.smartfi.microservice.clients.dto.LoginResponseDto loginResponseDto) Check user SCA access date.- Parameters:
user- User dta found.loginDto- DTO of login with reuqets data.loginResponseDto- Generated response from login endpoint.- Returns:
- LoginResponseDto response with checked last sca access date.
-
updateErrorAccessCounterToZero
Update to zero count access errors.- Parameters:
user- data user found.
-
findUserInDb
Find the user in the database with the given login details.- Parameters:
loginDto- login details.- Returns:
- The user in database. Must not be null, if the user is not found the proper exception must be thrown.
-
checkCredentials
Check the given user credentials (found with the given login details).- Parameters:
loginDto- login details received to find the user.user- the user found.- Returns:
- the user if the credentials presented were correct. In other case, then proper exception must be thrown.
-
handleTemporaryLocks
Handle user temporary locks.- Parameters:
user- the user found.credentialsOk- flag set to true if the user credentials were correct.- Returns:
- the user if there are no temporary locks.
-
checkUserState
Check the given user state. If the user is not in a state that allows her/him to log in, an exception will be thrown.IMPORTANT: note that there is no differentiation between valid or invalid credentials. This is made on purpose, for usability matters we want the user to know he is blocked even in the case his/her credentials are not valid.
- Parameters:
user- the user.
-
login
public es.kukenan.smartfi.microservice.clients.dto.LoginResponseDto login(T loginDto, UserLog userLog) Login process.- Specified by:
loginin interfaceLoginServiceStrategy<T extends es.kukenan.smartfi.microservice.clients.dto.LoginDto>- Parameters:
loginDto- login request process data.userLog- Bean for auditory log.- Returns:
- LoginResponse.
-
lastLogin
Get last login date from the given user entity.- Parameters:
user- user entity.- Returns:
- the last login date, if any.
-