Package org.cyclos.services.access
Interface TotpService
-
- All Superinterfaces:
Service
- All Known Subinterfaces:
TotpServiceLocal
public interface TotpService extends Service
Service for managing a user's TOTP secret. The activation flow can only be performed by the logged user itself, and is as follows:- Call
getData(BasicUserVO)to get the current status. - Call
requestActivationCode(SendOtpParams)with the desired send medium. - Call
verifyActivationCode(String)with the code received by email / SMS. The status is changed toTotpSecretStatus.PENDING. An URL with the QR-code content is retured. - The user scans the QR-code with the authenticator APP, and generates a code.
- Call
activate(String)with the code. The status is set toTotpSecretStatus.ACTIVE.
-
-
Field Summary
Fields Modifier and Type Field Description static intTOTP_LENGTHTOTP lengthstatic StringTOTP_VALUE_PREFIXPrefix used when confirming an action with a totp.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidactivate(@NotNull String totp)Finishes the activation of an authenticator app, using a code generated by the app.TotpSecretDatagetData(BasicUserVO user)Returns data for the current TOTP secret of the given user.voidremove(@NotNull RemoveTotpSecretParams params)Removes the TOTP secret of a user.OtpResultrequestActivationCode(@NotNull SendOtpParams params)Requests an activation code of a TOTP device.StringverifyActivationCode(@NotNull String otp)Verify the activation of the the TOTP device, changing its status toTotpSecretStatus.PENDING.
-
-
-
Field Detail
-
TOTP_LENGTH
static final int TOTP_LENGTH
TOTP length- See Also:
- Constant Field Values
-
TOTP_VALUE_PREFIX
static final String TOTP_VALUE_PREFIX
Prefix used when confirming an action with a totp. Unprefixed values are considered regular passwords.- See Also:
- Constant Field Values
-
-
Method Detail
-
activate
void activate(@NotNull @NotNull String totp) throws FrameworkException, InvalidTotpExceptionFinishes the activation of an authenticator app, using a code generated by the app. The TOTP status must currently beTotpSecretStatus.PENDING, and will be set toTotpSecretStatus.ACTIVE.- Throws:
InvalidTotpException- The given TOTP value is invalid according to the generated user secretFrameworkException
-
getData
TotpSecretData getData(BasicUserVO user) throws FrameworkException
Returns data for the current TOTP secret of the given user. If the logged user can activate a TOTP, the data for requesting a verification code, which starts the activation process, is returned.- Throws:
FrameworkException
-
remove
void remove(@NotNull @NotNull RemoveTotpSecretParams params) throws FrameworkExceptionRemoves the TOTP secret of a user. When it is the current user a confirmation credential is used.- Throws:
FrameworkException
-
requestActivationCode
OtpResult requestActivationCode(@NotNull @NotNull SendOtpParams params) throws FrameworkException
Requests an activation code of a TOTP device.- Throws:
FrameworkException
-
verifyActivationCode
String verifyActivationCode(@NotNull @NotNull String otp) throws FrameworkException
Verify the activation of the the TOTP device, changing its status toTotpSecretStatus.PENDING. Returns the URL which should be displayed as QR-code for being scanned or copied / pasted in the app.- Throws:
FrameworkException
-
-