Search in sources :

Example 1 with RegisterRequestData

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();
}
Also used : RegisterResponse(com.yubico.u2f.data.messages.RegisterResponse) DeviceRegistration(com.yubico.u2f.data.DeviceRegistration) RegisterRequestData(com.yubico.u2f.data.messages.RegisterRequestData) Principal(org.apereo.cas.authentication.principal.Principal)

Example 2 with RegisterRequestData

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();
}
Also used : RegisterRequest(com.yubico.u2f.data.messages.RegisterRequest) RegisterRequestData(com.yubico.u2f.data.messages.RegisterRequestData) U2FRegistration(org.apereo.cas.adaptors.u2f.U2FRegistration) Principal(org.apereo.cas.authentication.principal.Principal)

Aggregations

RegisterRequestData (com.yubico.u2f.data.messages.RegisterRequestData)2 Principal (org.apereo.cas.authentication.principal.Principal)2 DeviceRegistration (com.yubico.u2f.data.DeviceRegistration)1 RegisterRequest (com.yubico.u2f.data.messages.RegisterRequest)1 RegisterResponse (com.yubico.u2f.data.messages.RegisterResponse)1 U2FRegistration (org.apereo.cas.adaptors.u2f.U2FRegistration)1