use of com.yubico.u2f.data.messages.RegisterRequestData in project cas by apereo.
the class U2FAccountSaveRegistrationAction method doExecute.
@Override
protected Event doExecute(final RequestContext requestContext) throws Exception {
final Principal p = WebUtils.getAuthentication(requestContext).getPrincipal();
final String response = requestContext.getRequestParameters().get("tokenResponse");
final RegisterResponse registerResponse = RegisterResponse.fromJson(response);
final String regReqJson = u2FDeviceRepository.getDeviceRegistrationRequest(registerResponse.getRequestId(), p.getId());
final RegisterRequestData registerRequestData = RegisterRequestData.fromJson(regReqJson);
final DeviceRegistration registration = u2f.finishRegistration(registerRequestData, registerResponse);
u2FDeviceRepository.registerDevice(p.getId(), registration);
return success();
}
use of com.yubico.u2f.data.messages.RegisterRequestData in project cas by apereo.
the class U2FStartRegistrationAction method doExecute.
@Override
protected Event doExecute(final RequestContext requestContext) throws Exception {
final Principal p = WebUtils.getAuthentication(requestContext).getPrincipal();
final RegisterRequestData registerRequestData = u2f.startRegistration(this.serverAddress, u2FDeviceRepository.getRegisteredDevices(p.getId()));
u2FDeviceRepository.requestDeviceRegistration(registerRequestData.getRequestId(), p.getId(), registerRequestData.toJson());
if (!registerRequestData.getRegisterRequests().isEmpty()) {
final RegisterRequest req = registerRequestData.getRegisterRequests().iterator().next();
requestContext.getFlowScope().put("u2fReg", new U2FRegistration(req.getChallenge(), req.getAppId()));
return success();
}
return error();
}
Aggregations