Search in sources :

Example 1 with WithContentAction

use of org.pac4j.core.exception.http.WithContentAction in project cas by apereo.

the class BaseDelegatedAuthenticationController method getResultingView.

/**
 * Gets resulting view.
 *
 * @param client     the client
 * @param webContext the web context
 * @param ticket     the ticket
 * @return the resulting view
 * @throws Exception the exception
 */
protected View getResultingView(final IndirectClient client, final WebContext webContext, final TransientSessionTicket ticket) throws Exception {
    client.init();
    val actionResult = getRedirectionAction(client, webContext, ticket);
    if (actionResult.isPresent()) {
        val action = actionResult.get();
        LOGGER.debug("Determined final redirect action for client [{}] as [{}]", client, action);
        if (action instanceof WithLocationAction) {
            val foundAction = WithLocationAction.class.cast(action);
            val builder = new URIBuilder(foundAction.getLocation());
            val url = builder.toString();
            LOGGER.debug("Redirecting client [{}] to [{}] based on identifier [{}]", client.getName(), url, ticket.getId());
            return new RedirectView(url);
        }
        if (action instanceof WithContentAction) {
            val seeOtherAction = WithContentAction.class.cast(action);
            return new DynamicHtmlView(seeOtherAction.getContent());
        }
    }
    LOGGER.warn("Unable to determine redirect action for client [{}]", client);
    return null;
}
Also used : lombok.val(lombok.val) WithContentAction(org.pac4j.core.exception.http.WithContentAction) RedirectView(org.springframework.web.servlet.view.RedirectView) WithLocationAction(org.pac4j.core.exception.http.WithLocationAction) DynamicHtmlView(org.apereo.cas.web.view.DynamicHtmlView) URIBuilder(org.apache.http.client.utils.URIBuilder)

Aggregations

lombok.val (lombok.val)1 URIBuilder (org.apache.http.client.utils.URIBuilder)1 DynamicHtmlView (org.apereo.cas.web.view.DynamicHtmlView)1 WithContentAction (org.pac4j.core.exception.http.WithContentAction)1 WithLocationAction (org.pac4j.core.exception.http.WithLocationAction)1 RedirectView (org.springframework.web.servlet.view.RedirectView)1