Class UserLoginMFAUtil

java.lang.Object
com.skava.util.UserLoginMFAUtil

public final class UserLoginMFAUtil extends Object
This is a Utility class for User model which contains validator and util methods used in this service.
Author:
Infosys Equinox
  • 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 - Holds UserCommonServices object to save loginOTP in DB.
      request - Holds UserAuthRequest object to get store id and locale from request.
      collection - Holds Collection object to get collection id and business id for triggering event.
      userEntity - Holds UsersEntity object to set loginMFAPayload details.
      eventClientComponent - Holds EventClientComponent object used to convert and send the message.
      collectionCommonServices - Holds CollectionCommonServices 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.
      Parameters:
      loginOTP - Indicates the login OTP which is used for checking the old otps.
      recentOTPList - Holds List of String which contains old otps list used for checking the old OTP.
      limit - Indicates the limit for storing the old passwords.
      Returns:
      The List of OTPs
    • 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 - Holds Collection object is used for loading the last mfa recent otp check limit.
      collectionCommonServices - Holds CollectionCommonServices object for loading last mfa recent otp check limit.
      userCommonServices - Holds UserCommonServices object for loading last mfa recent otp check limit.
      Returns:
      The valid last recent OTP limit.
    • convertRecentOTPToList

      public static List<String> convertRecentOTPToList(PropertiesEntity recentOTPPropertyFromDB)
      This method is used to convert recent OTP string value to list.
      Parameters:
      recentOTPPropertyFromDB - Holds PropertiesEntity object which contains recent OTP values.
      Returns:
      The list of recent OTPs.
    • getLoginRandomOTPCode

      public static String getLoginRandomOTPCode(List<String> recentOTPList)
      This method is used to generate random OTP and checks whether the generated OTP is present in recent OTPs.
      Parameters:
      recentOTPList - Holds List of String which contains recent OTPs.
      Returns:
      The valid random otp.
    • 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 - Holds UsersEntity object used to set values in login MFA payload.
      loginOTP - Indicates the login MFA OTP
      loginToken - 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

      public static boolean verifyTotp(String secretCode, String passCode)
      This method is used to verify OTP
      Parameters:
      secretCode -
      passCode -
      Returns: