Search in sources :

Example 1 with PollInfo

use of com.okta.idx.sdk.api.model.PollInfo in project okta-idx-java by okta.

the class AuthenticationTransaction method createProceedContext.

ProceedContext createProceedContext() {
    if (idxResponse == null || idxResponse.remediation() == null || idxResponse.remediation().remediationOptions() == null) {
        logger.error("ProceedContext is null");
        return null;
    }
    RemediationOption[] remediationOptions = idxResponse.remediation().remediationOptions();
    String href = remediationOptions[0].getHref();
    String refresh = remediationOptions[0].getRefresh();
    String skipHref = null;
    Optional<RemediationOption> skipOptional = getOptionalRemediationOption(RemediationType.SKIP);
    if (skipOptional.isPresent()) {
        skipHref = skipOptional.get().getHref();
    }
    boolean isIdentifyInOneStep = isRemediationRequireCredentials(RemediationType.IDENTIFY);
    String selectProfileEnrollHref = null;
    Optional<RemediationOption> selectEnrollProfileRemediationOption = getOptionalRemediationOption(RemediationType.SELECT_ENROLL_PROFILE);
    if (selectEnrollProfileRemediationOption.isPresent()) {
        selectProfileEnrollHref = selectEnrollProfileRemediationOption.get().getHref();
    }
    String resendHref = null;
    PollInfo pollInfo = null;
    if (idxResponse.getCurrentAuthenticatorEnrollment() != null && idxResponse.getCurrentAuthenticatorEnrollment().getValue() != null) {
        if (idxResponse.getCurrentAuthenticatorEnrollment().getValue().getResend() != null) {
            resendHref = idxResponse.getCurrentAuthenticatorEnrollment().getValue().getResend().getHref();
        }
        if (idxResponse.getCurrentAuthenticatorEnrollment().getValue().getPoll() != null) {
            RemediationOption pollRemediationOption = idxResponse.getCurrentAuthenticatorEnrollment().getValue().getPoll();
            pollInfo = new PollInfo(pollRemediationOption.getHref(), pollRemediationOption.getRefresh());
        }
    } else if (idxResponse.getCurrentAuthenticator() != null && idxResponse.getCurrentAuthenticator().getValue() != null) {
        if (idxResponse.getCurrentAuthenticator().getValue().getResend() != null) {
            resendHref = idxResponse.getCurrentAuthenticator().getValue().getResend().getHref();
        }
        if (idxResponse.getCurrentAuthenticator().getValue().getPoll() != null) {
            RemediationOption pollRemediationOption = idxResponse.getCurrentAuthenticator().getValue().getPoll();
            pollInfo = new PollInfo(pollRemediationOption.getHref(), pollRemediationOption.getRefresh());
        }
    }
    return new ProceedContext(clientContext, getStateHandle(), href, skipHref, isIdentifyInOneStep, selectProfileEnrollHref, resendHref, pollInfo, refresh);
}
Also used : RemediationOption(com.okta.idx.sdk.api.model.RemediationOption) PollInfo(com.okta.idx.sdk.api.model.PollInfo)

Aggregations

PollInfo (com.okta.idx.sdk.api.model.PollInfo)1 RemediationOption (com.okta.idx.sdk.api.model.RemediationOption)1