Package io.meeds.web.security.service
Class OtpService
java.lang.Object
io.meeds.web.security.service.OtpService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanconsumeOtp(String userName, String otpMethod, String otpCode) Consumes a code already validated, for a flow that writes between its validation and the consumptionvoidsendOtpCode(String userName, String otpMethod) voidvalidateAndConsumeOtp(String userName, String otpMethod, String otpCode) Validates the code asvalidateOtp(String, String, String)does, then consumes it, so that the same code never validates a second time.voidvalidateOtp(String userName, String otpMethod, String otpCode)
-
Constructor Details
-
OtpService
public OtpService()
-
-
Method Details
-
sendOtpCode
-
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 asvalidateOtp(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 loginotpMethod- OTP method nameotpCode- code to validate- Throws:
IllegalAccessException- when the code is blank, wrong, expired, already consumed, or when the user exceeded the allowed attempts
-
consumeOtp
Consumes a code already validated, for a flow that writes between its validation and the consumption- Parameters:
userName- user loginotpMethod- OTP method nameotpCode- validated code- Returns:
- true when this call consumed the code, false when it was no longer there or the method is unknown
-