Package com.skava.util
Class UserLoginMFAUtil
java.lang.Object
com.skava.util.UserLoginMFAUtil
This is a Utility class for User model which contains validator and util methods used in this service.
- Author:
- Infosys Equinox
-
Method Summary
Modifier and TypeMethodDescriptionconvertRecentOTPToList
(PropertiesEntity recentOTPPropertyFromDB) This method is used to convert recent OTP string value to list.static String
generateLoginTokenAndOTPForLoginMFAAndCheckRecentOTPs
(UserCommonServices userCommonServices, UserAuthRequest request, Collection collection, UsersEntity userEntity, com.skava.core.event.EventClientComponent eventClientComponent, CollectionCommonServices collectionCommonServices) This method is used to generate login OTP and login Token which is used for MFA login.static String
generateQRCode
(String secretCode, String userMail, String qrGeneratorURL, String issuer) This method is used to generate QR codestatic String
getLoginRandomOTPCode
(List<String> recentOTPList) This method is used to generate random OTP and checks whether the generated OTP is present in recent OTPs.static int
loadRecentOTPFromCollectionProperties
(Collection collection, CollectionCommonServices collectionCommonServices, UserCommonServices userCommonServices) This method is used to load Recent OTP value count from database for the given collection.static void
saveMFAAuth
(String secretCode, UserCommonServices userCommonServices, long userId, String loginToken) This method is used to savev MFA authenticator.static LoginMFAPayload
setLoginMFAPayloadValueFromUserEntity
(UsersEntity userEntity, String loginOTP, String loginToken) This method is used to set login MFA payload details from user entity.static void
updateMFAAuth
(MfaAuthStatus status, MFAAuthEntity mfaAuthEntity, UserCommonServices userCommonServices, long userId) This method is used to update MFA authenticator.static void
updateMFALoginAuth
(MfaLoginTokenStatus status, MFAAuthEntity mfaAuthEntity, UserCommonServices userCommonServices, long userId) This method is used to update MFA authenticator.updateRecentOtpList
(String loginOTP, List<String> recentOTPList, int limit) This method is used to check new OTP with old OTP list.static boolean
verifyTotp
(String secretCode, String passCode) This method is used to verify OTP
-
Method Details
-
generateLoginTokenAndOTPForLoginMFAAndCheckRecentOTPs
public static String generateLoginTokenAndOTPForLoginMFAAndCheckRecentOTPs(UserCommonServices userCommonServices, UserAuthRequest request, Collection collection, UsersEntity userEntity, com.skava.core.event.EventClientComponent eventClientComponent, CollectionCommonServices collectionCommonServices) This method is used to generate login OTP and login Token which is used for MFA login.- Parameters:
userCommonServices
- HoldsUserCommonServices
object to save loginOTP in DB.request
- HoldsUserAuthRequest
object to get store id and locale from request.collection
- HoldsCollection
object to get collection id and business id for triggering event.userEntity
- HoldsUsersEntity
object to set loginMFAPayload details.eventClientComponent
- HoldsEventClientComponent
object used to convert and send the message.collectionCommonServices
- HoldsCollectionCommonServices
object for loading properties.- Returns:
- The valid login token.
-
updateRecentOtpList
public static List<String> updateRecentOtpList(String loginOTP, List<String> recentOTPList, int limit) This method is used to check new OTP with old OTP list. -
loadRecentOTPFromCollectionProperties
public static int loadRecentOTPFromCollectionProperties(Collection collection, CollectionCommonServices collectionCommonServices, UserCommonServices userCommonServices) This method is used to load Recent OTP value count from database for the given collection.- Parameters:
collection
- HoldsCollection
object is used for loading the last mfa recent otp check limit.collectionCommonServices
- HoldsCollectionCommonServices
object for loading last mfa recent otp check limit.userCommonServices
- HoldsUserCommonServices
object for loading last mfa recent otp check limit.- Returns:
- The valid last recent OTP limit.
-
convertRecentOTPToList
This method is used to convert recent OTP string value to list.- Parameters:
recentOTPPropertyFromDB
- HoldsPropertiesEntity
object which contains recent OTP values.- Returns:
- The list of recent OTPs.
-
getLoginRandomOTPCode
This method is used to generate random OTP and checks whether the generated OTP is present in recent OTPs. -
setLoginMFAPayloadValueFromUserEntity
public static LoginMFAPayload setLoginMFAPayloadValueFromUserEntity(UsersEntity userEntity, String loginOTP, String loginToken) This method is used to set login MFA payload details from user entity.- Parameters:
userEntity
- HoldsUsersEntity
object used to set values in login MFA payload.loginOTP
- Indicates the login MFA OTPloginToken
- Indicates the login MFA token- Returns:
- The
LoginMFAPayload
object used to set login MFA payload values.
-
saveMFAAuth
public static void saveMFAAuth(String secretCode, UserCommonServices userCommonServices, long userId, String loginToken) This method is used to savev MFA authenticator.- Parameters:
secretCode
-userCommonServices
-userId
-
-
updateMFAAuth
public static void updateMFAAuth(MfaAuthStatus status, MFAAuthEntity mfaAuthEntity, UserCommonServices userCommonServices, long userId) This method is used to update MFA authenticator.- Parameters:
status
-mfaAuthEntity
-userCommonServices
-userId
-
-
updateMFALoginAuth
public static void updateMFALoginAuth(MfaLoginTokenStatus status, MFAAuthEntity mfaAuthEntity, UserCommonServices userCommonServices, long userId) This method is used to update MFA authenticator.- Parameters:
status
-mfaAuthEntity
-userCommonServices
-userId
-
-
generateQRCode
public static String generateQRCode(String secretCode, String userMail, String qrGeneratorURL, String issuer) This method is used to generate QR code- Parameters:
secretCode
-userMail
-qrGeneratorURL
-issuer
-- Returns:
-
verifyTotp
This method is used to verify OTP- Parameters:
secretCode
-passCode
-- Returns:
-