use of org.apereo.cas.otp.repository.credentials.OneTimeTokenAccount in project cas by apereo.
the class OneTimeTokenAccountCheckRegistrationAction method doExecute.
@Override
protected Event doExecute(final RequestContext requestContext) throws Exception {
final RequestContext context = RequestContextHolder.getRequestContext();
final String uid = WebUtils.getAuthentication(context).getPrincipal().getId();
final String secretKey = repository.getSecret(uid);
if (StringUtils.isBlank(secretKey)) {
final OneTimeTokenAccount keyAccount = this.repository.create(uid);
final String keyUri = "otpauth://totp/" + this.label + ':' + uid + "?secret=" + keyAccount.getSecretKey() + "&issuer=" + this.issuer;
requestContext.getFlowScope().put("key", keyAccount);
requestContext.getFlowScope().put("keyUri", keyUri);
LOGGER.debug("Registration key URI is [{}]", keyUri);
return new EventFactorySupport().event(this, "register");
}
return success();
}
use of org.apereo.cas.otp.repository.credentials.OneTimeTokenAccount in project cas by apereo.
the class OneTimeTokenAccountSaveRegistrationAction method doExecute.
@Override
protected Event doExecute(final RequestContext requestContext) throws Exception {
final OneTimeTokenAccount account = requestContext.getFlowScope().get("key", OneTimeTokenAccount.class);
final String uid = WebUtils.getAuthentication(requestContext).getPrincipal().getId();
repository.save(uid, account.getSecretKey(), account.getValidationCode(), account.getScratchCodes());
return success();
}
Aggregations