Package com.skava.util
Class UserAuthUtil
java.lang.Object
com.skava.util.UserAuthUtil
This is a utility class for user which contains util methods used in this service.
- Author:
- Infosys Equinox
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
deleteLoginAttemptCountCustomPropertyFromDB
(UsersEntity user, UserCommonServices userCommonServices, String name) This method is used to delete the given custom properties from DB.static void
deleteMultipleCustomPropertiesFromDB
(UsersEntity user, UserCommonServices userCommonServices, List<String> names) This method is used to delete the given custom properties from DB.static String
This method is used to get notification param for a user notification request.static String
getParamValueFromUserIdAndTime
(long userId) This method is used to get activation or reset param for an user.static String
getParamValueFromUserIdAndTime
(long userId, String otp) static String
This method is used to generate OTP code.static String
loadEnableUserMergeValueFromDB
(Collection collection, UserCommonServices userCommonServices, CollectionCommonServices collectionCommonServices) This method is used to load collection property value from DBstatic int
loadFailMaxLimitFromCollectionProperties
(Collection collection, UserCommonServices userCommonServices, CollectionCommonServices collectionCommonServices) This method used to load collection property of resend limit for MFAstatic String
loadMFAValueFromDB
(Collection collection, UserCommonServices userCommonServices, CollectionCommonServices collectionCommonServices, String name) This method is used to load collection property value from DBstatic int
loadResendMaxLimitFromCollectionProperties
(Collection collection, UserCommonServices userCommonServices, CollectionCommonServices collectionCommonServices) This method used to load collection property of resend limit for MFAstatic int
loadType
(String requestType, UserCommonServices userCommonServices, String locale) This method is used to set integer type based on the given string type.static UserAuthResponse
setAuthResponseAndGenerateLoginToken
(UsersEntity userEntity, UserCommonServices userCommonServices) This method is used to generate login token and set user id in user model object.static UserAuthResponse
setAuthResponseAndLoginToken
(UsersEntity userEntity, String loginToken, int availableRetries, int maxFailLimit, boolean resetParam) This method is used to set login token and availableRetries in auth response and set user id in user model object.static void
triggerLockedStatusEmail
(UserAuthRequest request, CollectionCommonServices collectionCommonServices, com.skava.core.event.EventClientComponent clientComponent, Optional<UsersEntity> user) triggerLockedStatusEmail - This method is used to trigger email notification for locked status.static void
updateEmailNotifyProp
(UserAuthRequest request, UserCommonServices userCommonServices, Optional<UsersEntity> user) updateEmailNotifyProp - This method is used to update email notify property.
-
Method Details
-
getNotificationParamName
This method is used to get notification param for a user notification request. It contains auth notification param appended with operation. Operation means 2FA etc.- Parameters:
request
- HoldsUserNotificationRequest
object is used to get notification param for an user.- Returns:
- The notification param.
-
getParamValueFromUserIdAndTime
This method is used to get activation or reset param for an user. It contains random generated OTP code appended with user id appended with timestamp.- Parameters:
userId
- Indicates the user identifier for which user the notification param is used generated.- Returns:
- The activation/reset param
-
getParamValueFromUserIdAndTime
-
getRandomOTPCode
This method is used to generate OTP code.- Returns:
- The random OTP code
-
loadType
public static int loadType(String requestType, UserCommonServices userCommonServices, String locale) This method is used to set integer type based on the given string type.- Parameters:
requestType
- Indicates the user's type.userCommonServices
- HoldsUserCommonServices
object for response message.locale
- Indicates the locale message.- Returns:
- The valid type.
-
loadEnableUserMergeValueFromDB
public static String loadEnableUserMergeValueFromDB(Collection collection, UserCommonServices userCommonServices, CollectionCommonServices collectionCommonServices) This method is used to load collection property value from DB- Parameters:
collection
- HoldsCollection
object to get collection property value.userCommonServices
- HoldsUserCommonServices
object to get property value from DB.collectionCommonServices
- HoldsCollectionCommonServices
object to get property value.- Returns:
- The valid String value.
-
loadMFAValueFromDB
public static String loadMFAValueFromDB(Collection collection, UserCommonServices userCommonServices, CollectionCommonServices collectionCommonServices, String name) This method is used to load collection property value from DB- Parameters:
collection
- HoldsCollection
object to get collection property value.userCommonServices
- HoldsUserCommonServices
object to get property value from DB.collectionCommonServices
- HoldsCollectionCommonServices
object to get property value.name
- Indicates the name of the property which is used for loading the value from DB.- Returns:
- The valid String value.
-
deleteLoginAttemptCountCustomPropertyFromDB
public static void deleteLoginAttemptCountCustomPropertyFromDB(UsersEntity user, UserCommonServices userCommonServices, String name) This method is used to delete the given custom properties from DB.- Parameters:
user
- HoldsUsersEntity
object to delete the custom property from DB.userCommonServices
- HoldsUserCommonServices
object to delete custom property.name
- Indicates the name of the property which is used for deleting the given property.
-
deleteMultipleCustomPropertiesFromDB
public static void deleteMultipleCustomPropertiesFromDB(UsersEntity user, UserCommonServices userCommonServices, List<String> names) This method is used to delete the given custom properties from DB.- Parameters:
user
- HoldsUsersEntity
object used to delete the custom property from DB.userCommonServices
- HoldsUserCommonServices
object used to delete custom property.names
- Indicates the list of name of the property which is used for deleting the given property.
-
setAuthResponseAndGenerateLoginToken
public static UserAuthResponse setAuthResponseAndGenerateLoginToken(UsersEntity userEntity, UserCommonServices userCommonServices) This method is used to generate login token and set user id in user model object.- Parameters:
userEntity
- HoldsUsersEntity
object used to get user id and set id in user model.userCommonServices
- HoldsUserCommonServices
object to generate login token and used for encrypting login token.- Returns:
- The Holds
UserAuthResponse
object which contains user object and login tokens.
-
setAuthResponseAndLoginToken
public static UserAuthResponse setAuthResponseAndLoginToken(UsersEntity userEntity, String loginToken, int availableRetries, int maxFailLimit, boolean resetParam) This method is used to set login token and availableRetries in auth response and set user id in user model object.- Parameters:
userEntity
- HoldsUsersEntity
object used to get user id and set id in user model.loginToken
- Indicates the login token.availableRetries
- Indicates the available retry count of an user.maxFailLimit
- Indicates the maximum fail limit of the user.- Returns:
- The
UserAuthResponse
object which contains user object and login tokens.
-
loadResendMaxLimitFromCollectionProperties
public static int loadResendMaxLimitFromCollectionProperties(Collection collection, UserCommonServices userCommonServices, CollectionCommonServices collectionCommonServices) This method used to load collection property of resend limit for MFA- Parameters:
collection
- HoldsCollection
object used to load resent limit property for that particular collection id.userCommonServices
- HoldsUserCommonServices
object for getting collection attributes.collectionCommonServices
- HoldsCollectionCommonServices
object for getting collection attributes.- Returns:
- The valid resends limit integer value.
-
loadFailMaxLimitFromCollectionProperties
public static int loadFailMaxLimitFromCollectionProperties(Collection collection, UserCommonServices userCommonServices, CollectionCommonServices collectionCommonServices) This method used to load collection property of resend limit for MFA- Parameters:
collection
- HoldsCollection
object used to load resent limit property for that particular collection id.userCommonServices
- HoldsUserCommonServices
object for getting collection attributes.collectionCommonServices
- HoldsCollectionCommonServices
object for getting collection attributes.- Returns:
- The valid resends limit integer value.
-
triggerLockedStatusEmail
public static void triggerLockedStatusEmail(UserAuthRequest request, CollectionCommonServices collectionCommonServices, com.skava.core.event.EventClientComponent clientComponent, Optional<UsersEntity> user) triggerLockedStatusEmail - This method is used to trigger email notification for locked status.- Parameters:
request
- HoldsUserAuthRequest
object used to get collection id and auth token.collectionCommonServices
- HoldsCollectionCommonServices
object used to get property value from DB.clientComponent
- HoldsEventClientComponent
object used to send email notification.user
- HoldsUsersEntity
object used to get user object.
-
updateEmailNotifyProp
public static void updateEmailNotifyProp(UserAuthRequest request, UserCommonServices userCommonServices, Optional<UsersEntity> user) updateEmailNotifyProp - This method is used to update email notify property.- Parameters:
request
- HoldsUserAuthRequest
object used to update email notify property.userCommonServices
- HoldsUserCommonServices
object used to update email notify property.user
- HoldsUsersEntity
object used to update email notify property.
-