Class OtpService

java.lang.Object
io.meeds.web.security.service.OtpService

@Service public class OtpService extends Object
  • Constructor Details

    • OtpService

      public OtpService()
  • Method Details

    • sendOtpCode

      public void sendOtpCode(String userName, String otpMethod)
    • validateOtp

      public void validateOtp(String userName, String otpMethod, String otpCode) throws IllegalAccessException
      Throws:
      IllegalAccessException
    • validateAndConsumeOtp

      public void validateAndConsumeOtp(String userName, String otpMethod, String otpCode) throws IllegalAccessException
      Validates the code as validateOtp(String, String, String) does, then consumes it, so that the same code never validates a second time. Two concurrent validations of one code see one winner: the loser is refused like a wrong code, without counting as a failed attempt.
      Parameters:
      userName - user login
      otpMethod - OTP method name
      otpCode - code to validate
      Throws:
      IllegalAccessException - when the code is blank, wrong, expired, already consumed, or when the user exceeded the allowed attempts
    • consumeOtp

      public boolean consumeOtp(String userName, String otpMethod, String otpCode)
      Consumes a code already validated, for a flow that writes between its validation and the consumption
      Parameters:
      userName - user login
      otpMethod - OTP method name
      otpCode - validated code
      Returns:
      true when this call consumed the code, false when it was no longer there or the method is unknown