Search in sources :

Example 1 with Factor

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);
}
Also used : AuthData(com.nike.cerberus.auth.connector.AuthData) Factor(com.okta.authn.sdk.resource.Factor) ArrayList(java.util.ArrayList) AuthResponse(com.nike.cerberus.auth.connector.AuthResponse)

Aggregations

AuthData (com.nike.cerberus.auth.connector.AuthData)1 AuthResponse (com.nike.cerberus.auth.connector.AuthResponse)1 Factor (com.okta.authn.sdk.resource.Factor)1 ArrayList (java.util.ArrayList)1