use of org.wso2.carbon.identity.application.authentication.framework.util.FrameworkConstants.REQUEST_PARAM_SP in project carbon-identity-framework by wso2.
the class FrameworkUtils method sendToRetryPage.
/**
* Send user to retry page during an authentication flow failure.
*
* @param request Http servlet request.
* @param response Http servlet response.
* @param context Authentication Context.
* @param status Failure status.
* @param statusMsg Failure status message.
* @throws IOException
*/
public static void sendToRetryPage(HttpServletRequest request, HttpServletResponse response, AuthenticationContext context, String status, String statusMsg) throws IOException {
try {
URIBuilder uriBuilder = new URIBuilder(ConfigurationFacade.getInstance().getAuthenticationEndpointRetryURL());
if (status != null && statusMsg != null) {
uriBuilder.addParameter("status", status);
uriBuilder.addParameter("statusMsg", statusMsg);
}
request.setAttribute(FrameworkConstants.RequestParams.FLOW_STATUS, AuthenticatorFlowStatus.INCOMPLETE);
if (context != null) {
if (IdentityTenantUtil.isTenantedSessionsEnabled()) {
uriBuilder.addParameter(USER_TENANT_DOMAIN_HINT, context.getUserTenantDomain());
}
uriBuilder.addParameter(REQUEST_PARAM_SP, context.getServiceProviderName());
if (!IdentityTenantUtil.isTenantQualifiedUrlsEnabled()) {
uriBuilder.addParameter(TENANT_DOMAIN, context.getTenantDomain());
}
response.sendRedirect(uriBuilder.build().toString());
} else {
response.sendRedirect(getRedirectURL(uriBuilder.build().toString(), request));
}
} catch (URISyntaxException e) {
log.error("Error building redirect url for failure", e);
FrameworkUtils.sendToRetryPage(request, response);
} finally {
List<String> cookiesToInvalidateConfig = IdentityUtil.getCookiesToInvalidateConfigurationHolder();
if (ArrayUtils.isNotEmpty(request.getCookies())) {
Arrays.stream(request.getCookies()).filter(cookie -> cookiesToInvalidateConfig.stream().anyMatch(cookieToInvalidate -> cookie.getName().contains(cookieToInvalidate))).forEach(cookie -> removeCookie(request, response, cookie.getName()));
}
}
}
Aggregations