use of com.okta.authn.sdk.resource.Factor in project cerberus by Nike-Inc.
the class InitialLoginStateHandler method handleMfaResponse.
/**
* Handles MFA states by determining valid user MFA factors.
*
* @param mfaResponse - Authentication response from the Completable Future
*/
private void handleMfaResponse(AuthenticationResponse mfaResponse) {
final String userId = mfaResponse.getUser().getId();
final String userLogin = mfaResponse.getUser().getLogin();
final AuthData authData = AuthData.builder().userId(userId).username(userLogin).build();
final AuthResponse authResponse = AuthResponse.builder().data(authData).build();
authData.setStateToken(mfaResponse.getStateToken());
authResponse.setStatus(AuthStatus.MFA_REQUIRED);
final List<Factor> factors = new ArrayList<>(mfaResponse.getFactors());
factors.removeIf(this::isPush);
validateUserFactors(factors);
factors.forEach(factor -> authData.getDevices().add(AuthMfaDevice.builder().id(factor.getId()).name(getDeviceName(factor)).requiresTrigger(isTriggerRequired(factor)).isPush(isPush(factor)).build()));
authenticationResponseFuture.complete(authResponse);
}
Aggregations