Class AccessManagementService
java.lang.Object
es.kukenan.smartfi.microservice.clients.service.AccessManagementService
Service fot management access for users.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intActual count of login error.private @NotBlank StringMax.private longTime difference to show in temporary blocked conditions.private ServicePropertiesService properties for retries and unlocking time.Map with properties for retires and time unlocking.private UserRepositoryDAO implementation to do queries about users. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckAccessManagement(User user) Method to check access management for blocked user and blocked temporally.private voidcheckAccessManagement(User user, HashMap<String, String> unlockingRetries) Method to check access management for blocked user and blocked temporally.private voidThis method thrown pre-temporally blocked message and temporally blocked message for users.private booleancheckUnlockingTime(User user, Map<String, String> unlockingRetries, int actualLoginErrorCount) Check if unlocking time is passed to free temporary locked of user.generateMapRetriesUnlockingTime(ServiceProperties serviceProperties) Generate a Map with retries and unlocking time for access management.Method for get additional info in response when user is temporary locked.getUserStatus(User user) Override method for get user status with user found in database.private UserStatusgetUserStatus(User user, Map<String, String> unlockingRetries, String blockedUserRetries, int actualLoginErrorCount) Get user status from User data for access management.(package private) voidupdateCountLoginDataUser(User user, int actualLoginErrorCount) Update Count login error and last login error date to check user blocks.
-
Field Details
-
diff
private long diffTime difference to show in temporary blocked conditions. -
actualLoginErrorCount
private int actualLoginErrorCountActual count of login error. -
blockedUserRetries
Max. number of retries. -
userRepository
DAO implementation to do queries about users. -
unlockingRetries
Map with properties for retires and time unlocking. -
serviceProperties
Service properties for retries and unlocking time.
-
-
Constructor Details
-
AccessManagementService
public AccessManagementService()
-
-
Method Details
-
checkAccessManagement
Method to check access management for blocked user and blocked temporally.- Parameters:
user- User data found in database.
-
checkAccessManagement
Method to check access management for blocked user and blocked temporally.- Parameters:
user- User data found in database. *unlockingRetries- Object hashmap with configuration about temporally blocked retries and unlocking time.
-
checkStatusUser
private void checkStatusUser(User user, Map<String, String> unlockingRetries, String blockedUserRetries) This method thrown pre-temporally blocked message and temporally blocked message for users.- Parameters:
user- Entity with user data.unlockingRetries- properties with temporally blocks and unlocking time.blockedUserRetries- max number of retries until block user.
-
updateCountLoginDataUser
Update Count login error and last login error date to check user blocks.- Parameters:
user- entity updated with user data.actualLoginErrorCount- actual counter of failed login retries.
-
generateMapRetriesUnlockingTime
Generate a Map with retries and unlocking time for access management.- Parameters:
serviceProperties- auto configurated properties bean for properties file complex strucuture for retries and unlocking time in access management.- Returns:
- Map with pairs of retires and unlocking time defines in complex structure at properties file.
-
getUserStatus
Override method for get user status with user found in database.- Parameters:
user- User found in database.- Returns:
- Access management user status.
-
getUserStatus
private UserStatus getUserStatus(User user, Map<String, String> unlockingRetries, String blockedUserRetries, int actualLoginErrorCount) Get user status from User data for access management.- Parameters:
user- user data found.unlockingRetries- Map with properties configured for retries and unlocking time in configuration file.blockedUserRetries- Configured number of retires to lock user.actualLoginErrorCount- Actual number of user errors login with user and password.- Returns:
- User status actual status of user in access management.
-
checkUnlockingTime
private boolean checkUnlockingTime(User user, Map<String, String> unlockingRetries, int actualLoginErrorCount) Check if unlocking time is passed to free temporary locked of user.- Parameters:
user- user data found in database.unlockingRetries- Map with properties configured for retries and unlocking time in configuration file.actualLoginErrorCount- Actual number of user errors login with user and password.- Returns:
- true if locked time is in progress, false if locked time is passed.
-
getAdditionalInfo
Method for get additional info in response when user is temporary locked.- Returns:
- HashMap with additional info for response.
-