use of com.okta.idx.sdk.api.response.TokenResponse in project okta-idx-java by okta.
the class HomeController method displayLoginPage.
/**
* Display the login page.
*
* @param session the http session
* @return the login view
*/
@GetMapping(value = "/login")
public ModelAndView displayLoginPage(final HttpSession session) {
TokenResponse tokenResponse = (TokenResponse) session.getAttribute("tokenResponse");
// render token response if a successful one is already present in session
if (tokenResponse != null) {
return homeHelper.proceedToHome(tokenResponse, session);
}
AuthenticationResponse authenticationResponse = begin(session);
if (authenticationResponse.getErrors().size() > 0) {
ModelAndView modelAndView = new ModelAndView("error");
modelAndView.addObject("errors", authenticationResponse.getErrors());
return modelAndView;
}
ModelAndView modelAndView = new ModelAndView("login");
if (!CollectionUtils.isEmpty(authenticationResponse.getIdps())) {
modelAndView.addObject("idps", authenticationResponse.getIdps());
}
return modelAndView;
}
use of com.okta.idx.sdk.api.response.TokenResponse in project okta-idx-java by okta.
the class AuthenticationTransaction method asAuthenticationResponse.
AuthenticationResponse asAuthenticationResponse(AuthenticationStatus defaultStatus) throws ProcessingException {
AuthenticationResponse authenticationResponse = new AuthenticationResponse();
authenticationResponse.setProceedContext(createProceedContext());
copyErrorMessages(idxResponse, authenticationResponse);
fillOutIdps(authenticationResponse);
fillOutAuthenticators(authenticationResponse);
if (idxResponse == null) {
return authenticationResponse;
}
if (idxResponse.isLoginSuccessful()) {
// login successful
logger.info("Login Successful!");
TokenResponse tokenResponse = idxResponse.getSuccessWithInteractionCode().exchangeCode(client, clientContext);
authenticationResponse.setAuthenticationStatus(AuthenticationStatus.SUCCESS);
authenticationResponse.setTokenResponse(tokenResponse);
return authenticationResponse;
}
if (idxResponse.getCurrentAuthenticator() != null) {
authenticationResponse.getWebAuthnParams().setCurrentAuthenticator(idxResponse.getCurrentAuthenticator());
}
if (idxResponse.getCurrentAuthenticatorEnrollment() != null) {
authenticationResponse.setCurrentAuthenticatorEnrollment(idxResponse.getCurrentAuthenticatorEnrollment());
}
if (idxResponse.getAuthenticatorEnrollments() != null) {
authenticationResponse.setAuthenticatorEnrollments(idxResponse.getAuthenticatorEnrollments());
}
String firstRemediation = "";
if (idxResponse.remediation() != null && idxResponse.remediation().remediationOptions().length > 0) {
firstRemediation = idxResponse.remediation().remediationOptions()[0].getName();
}
switch(firstRemediation) {
case RemediationType.REENROLL_AUTHENTICATOR:
authenticationResponse.setAuthenticationStatus(AuthenticationStatus.PASSWORD_EXPIRED);
break;
case RemediationType.AUTHENTICATOR_VERIFICATION_DATA:
authenticationResponse.setAuthenticationStatus(AuthenticationStatus.AWAITING_AUTHENTICATOR_VERIFICATION_DATA);
break;
case RemediationType.AUTHENTICATOR_ENROLLMENT_DATA:
authenticationResponse.setAuthenticationStatus(AuthenticationStatus.AWAITING_AUTHENTICATOR_ENROLLMENT_DATA);
break;
case RemediationType.CHALLENGE_AUTHENTICATOR:
authenticationResponse.setAuthenticationStatus(AuthenticationStatus.AWAITING_AUTHENTICATOR_VERIFICATION);
break;
case RemediationType.SELECT_AUTHENTICATOR_AUTHENTICATE:
authenticationResponse.setAuthenticationStatus(AuthenticationStatus.AWAITING_AUTHENTICATOR_SELECTION);
break;
case RemediationType.SELECT_AUTHENTICATOR_ENROLL:
authenticationResponse.setAuthenticationStatus(AuthenticationStatus.AWAITING_AUTHENTICATOR_ENROLLMENT_SELECTION);
break;
case RemediationType.ENROLL_PROFILE:
authenticationResponse.setAuthenticationStatus(AuthenticationStatus.AWAITING_PROFILE_ENROLLMENT);
break;
case RemediationType.ENROLL_AUTHENTICATOR:
authenticationResponse.setAuthenticationStatus(AuthenticationStatus.AWAITING_AUTHENTICATOR_ENROLLMENT);
break;
case RemediationType.ENROLL_POLL:
authenticationResponse.setAuthenticationStatus(AuthenticationStatus.AWAITING_POLL_ENROLLMENT);
break;
case RemediationType.ENROLLMENT_CHANNEL_DATA:
authenticationResponse.setAuthenticationStatus(AuthenticationStatus.AWAITING_CHANNEL_DATA_ENROLLMENT);
break;
case RemediationType.CHALLENGE_POLL:
authenticationResponse.setAuthenticationStatus(AuthenticationStatus.AWAITING_CHALLENGE_POLL);
break;
default:
authenticationResponse.setAuthenticationStatus(defaultStatus);
break;
}
Optional.ofNullable(idxResponse.getCurrentAuthenticator()).map(CurrentAuthenticatorEnrollment::getValue).map(CurrentAuthenticatorEnrollmentValue::getContextualData).ifPresent(authenticationResponse::setContextualData);
return authenticationResponse;
}
Aggregations