当前位置: 首页>>代码示例>>Java>>正文


Java HttpAction.redirect方法代码示例

本文整理汇总了Java中org.pac4j.core.exception.HttpAction.redirect方法的典型用法代码示例。如果您正苦于以下问题:Java HttpAction.redirect方法的具体用法?Java HttpAction.redirect怎么用?Java HttpAction.redirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.pac4j.core.exception.HttpAction的用法示例。


在下文中一共展示了HttpAction.redirect方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: computeRedirectionToServerIfNecessary

import org.pac4j.core.exception.HttpAction; //导入方法依赖的package包/类
private void computeRedirectionToServerIfNecessary(final WebContext context) throws HttpAction {
    final String relayStateValue = context.getRequestParameter(CasConfiguration.RELAY_STATE_PARAMETER);
    // if we have a state value -> redirect to the CAS server to continue the logout process
    if (CommonUtils.isNotBlank(relayStateValue)) {
        final StringBuilder buffer = new StringBuilder();
        buffer.append(configuration.getPrefixUrl());
        if (!configuration.getPrefixUrl().endsWith("/")) {
            buffer.append("/");
        }
        buffer.append("logout?_eventId=next&");
        buffer.append(CasConfiguration.RELAY_STATE_PARAMETER);
        buffer.append("=");
        buffer.append(CommonUtils.urlEncode(relayStateValue));
        final String redirectUrl = buffer.toString();
        logger.debug("Redirection url to the CAS server: {}", redirectUrl);
        throw HttpAction.redirect("Force redirect to CAS server for front channel logout", context, redirectUrl);
    }
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:19,代码来源:TicketAndLogoutRequestExtractor.java

示例2: perform

import org.pac4j.core.exception.HttpAction; //导入方法依赖的package包/类
/**
 * Perform a {@link RedirectAction} on the web context.
 *
 * @param context the web context
 * @return the performed {@link HttpAction}
 */
public HttpAction perform(final WebContext context) {
    if (type == RedirectType.REDIRECT) {
        return HttpAction.redirect("redirection via 302", context, location);
    } else {
        return HttpAction.ok("redirection via 200", context, content);
    }
}
 
开发者ID:millross,项目名称:pac4j-async,代码行数:14,代码来源:RedirectAction.java

示例3: handleError

import org.pac4j.core.exception.HttpAction; //导入方法依赖的package包/类
@Override
protected boolean handleError(final C context) throws HttpAction {
    if (this.redirectionUrl != null) {
        throw HttpAction.redirect(getErrorMessage(), context, this.redirectionUrl);
    } else {
        return false;
    }
}
 
开发者ID:millross,项目名称:pac4j-async,代码行数:9,代码来源:AbstractCheckAuthenticationAuthorizer.java

示例4: redirectToOriginallyRequestedUrl

import org.pac4j.core.exception.HttpAction; //导入方法依赖的package包/类
protected HttpAction redirectToOriginallyRequestedUrl(final C context, final String defaultUrl) {
    final String requestedUrl = (String) context.getSessionAttribute(Pac4jConstants.REQUESTED_URL);
    String redirectUrl = defaultUrl;
    if (isNotBlank(requestedUrl)) {
        context.setSessionAttribute(Pac4jConstants.REQUESTED_URL, null);
        redirectUrl = requestedUrl;
    }
    logger.debug("redirectUrl: {}", redirectUrl);
    return HttpAction.redirect("redirect", context, redirectUrl);
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:11,代码来源:DefaultCallbackLogic.java

示例5: perform

import org.pac4j.core.exception.HttpAction; //导入方法依赖的package包/类
@Override
public R perform(final C context, final Config config, final HttpActionAdapter<R, C> httpActionAdapter,
                   final String defaultUrl, final String inputLogoutUrlPattern) {

    logger.debug("=== APP LOGOUT ===");

    // default value
    final String logoutUrlPattern;
    if (inputLogoutUrlPattern == null) {
        logoutUrlPattern = Pac4jConstants.DEFAULT_LOGOUT_URL_PATTERN_VALUE;
    } else {
        logoutUrlPattern = inputLogoutUrlPattern;
    }

    // checks
    assertNotNull("context", context);
    assertNotNull("config", config);
    assertNotNull("httpActionAdapter", httpActionAdapter);
    assertNotBlank(Pac4jConstants.LOGOUT_URL_PATTERN, logoutUrlPattern);

    // logic
    final ProfileManager manager = getProfileManager(context);
    manager.logout();
    postLogout(context);

    final String url = context.getRequestParameter(Pac4jConstants.URL);
    String redirectUrl = defaultUrl;
    if (url != null && Pattern.matches(logoutUrlPattern, url)) {
        redirectUrl = url;
    }
    logger.debug("redirectUrl: {}", redirectUrl);
    final HttpAction action;
    if (redirectUrl != null) {
        action = HttpAction.redirect("redirect", context, redirectUrl);
    } else {
        action = HttpAction.ok("ok", context);
    }

    return httpActionAdapter.adapt(action.getCode(), context);
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:41,代码来源:DefaultApplicationLogoutLogic.java

示例6: handleError

import org.pac4j.core.exception.HttpAction; //导入方法依赖的package包/类
@Override
protected boolean handleError(final WebContext context) throws HttpAction {
    if (this.redirectionUrl != null) {
        throw HttpAction.redirect(getErrorMessage(), context, this.redirectionUrl);
    } else {
        return false;
    }
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:9,代码来源:AbstractCheckAuthenticationAuthorizer.java

示例7: redirect

import org.pac4j.core.exception.HttpAction; //导入方法依赖的package包/类
@Override
public final HttpAction redirect(final WebContext context) throws HttpAction {
    final RedirectAction action = getRedirectAction(context);
    if (action.getType() == RedirectType.REDIRECT) {
        return HttpAction.redirect("redirection via 302", context, action.getLocation());
    } else {
        return HttpAction.ok("redirection via 200", context, action.getContent());
    }
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:10,代码来源:IndirectClient.java

示例8: handleInvalidCredentials

import org.pac4j.core.exception.HttpAction; //导入方法依赖的package包/类
private HttpAction handleInvalidCredentials(final WebContext context, final String username, String message, String errorMessage, int errorCode) throws HttpAction {
    // it's an AJAX request -> unauthorized (instead of a redirection)
    if (getAjaxRequestResolver().isAjax(context)) {
        logger.info("AJAX request detected -> returning " + errorCode);
        return HttpAction.status("AJAX request -> " + errorCode, errorCode, context);
    } else {
        String redirectionUrl = CommonHelper.addParameter(this.loginUrl, this.usernameParameter, username);
        redirectionUrl = CommonHelper.addParameter(redirectionUrl, ERROR_PARAMETER, errorMessage);
        logger.debug("redirectionUrl: {}", redirectionUrl);
        logger.debug(message);
        return HttpAction.redirect(message, context, redirectionUrl);
    }
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:14,代码来源:FormClient.java

示例9: retrieveCredentials

import org.pac4j.core.exception.HttpAction; //导入方法依赖的package包/类
@Override
protected TokenCredentials retrieveCredentials(final WebContext context) throws HttpAction {
    init(context);
    try {
        String currentUrl = context.getFullRequestURL();
        String loginUrl = configuration.getLoginUrl();
        final CallbackUrlResolver callbackUrlResolver = configuration.getCallbackUrlResolver();
        if (callbackUrlResolver != null) {
            currentUrl = callbackUrlResolver.compute(currentUrl, context);
            loginUrl = callbackUrlResolver.compute(loginUrl, context);
        }

        final TokenCredentials credentials = getCredentialsExtractor().extract(context);
        if (credentials == null) {
            // redirect to the login page
            final String redirectionUrl = CommonUtils.constructRedirectUrl(loginUrl, CasConfiguration.SERVICE_PARAMETER,
                    currentUrl, configuration.isRenew(), false);
            logger.debug("redirectionUrl: {}", redirectionUrl);
            throw HttpAction.redirect("no ticket -> force redirect to login page", context, redirectionUrl);
        }

        // clean url from ticket parameter
        currentUrl = CommonHelper.substringBefore(currentUrl, "?" + CasConfiguration.TICKET_PARAMETER + "=");
        currentUrl = CommonHelper.substringBefore(currentUrl, "&" + CasConfiguration.TICKET_PARAMETER + "=");
        final CasAuthenticator casAuthenticator = new CasAuthenticator(configuration, currentUrl);
        casAuthenticator.init(context);
        casAuthenticator.validate(credentials, context);

        return credentials;
    } catch (CredentialsException e) {
        logger.error("Failed to retrieve or validate CAS credentials", e);
        return null;
    }
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:35,代码来源:DirectCasClient.java

示例10: forbidden

import org.pac4j.core.exception.HttpAction; //导入方法依赖的package包/类
@Override
protected HttpAction forbidden(final WebContext context, final List currentClients, final List list, final String authorizers) {
    return HttpAction.redirect("Authorization failed", context, "authorizationFailure");
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:5,代码来源:CasManagementSecurityInterceptor.java


注:本文中的org.pac4j.core.exception.HttpAction.redirect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。