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


Java CommonUtils.constructRedirectUrl方法代码示例

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


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

示例1: issueAuthenticationRequestRedirect

import org.jasig.cas.client.util.CommonUtils; //导入方法依赖的package包/类
/**
 * Redirect request for authentication.
 *
 * @param pair     the pair
 * @param request  the request
 * @param response the response
 * @throws Exception the exception
 */
protected void issueAuthenticationRequestRedirect(final Pair<? extends SignableSAMLObject, MessageContext> pair,
                                                  final HttpServletRequest request,
                                                  final HttpServletResponse response) throws Exception {
    final AuthnRequest authnRequest = AuthnRequest.class.cast(pair.getLeft());
    final String serviceUrl = constructServiceUrl(request, response, pair);
    LOGGER.debug("Created service url [{}]", serviceUrl);

    final String initialUrl = CommonUtils.constructRedirectUrl(this.loginUrl,
            CasProtocolConstants.PARAMETER_SERVICE, serviceUrl, authnRequest.isForceAuthn(),
            authnRequest.isPassive());

    final String urlToRedirectTo = buildRedirectUrlByRequestedAuthnContext(initialUrl, authnRequest, request);

    LOGGER.debug("Redirecting SAML authN request to [{}]", urlToRedirectTo);
    final AuthenticationRedirectStrategy authenticationRedirectStrategy = new DefaultAuthenticationRedirectStrategy();
    authenticationRedirectStrategy.redirect(request, response, urlToRedirectTo);

}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:27,代码来源:AbstractSamlProfileHandlerController.java

示例2: redirectToIdentityProvider

import org.jasig.cas.client.util.CommonUtils; //导入方法依赖的package包/类
private void redirectToIdentityProvider(final WSFederationRequest fedRequest, final HttpServletResponse response,
                                        final HttpServletRequest request, final WSFederationRegisteredService service) {
    try {
        final String serviceUrl = constructServiceUrl(request, response, fedRequest);
        LOGGER.debug("Created service url [{}] mapped to [{}]", serviceUrl, service);
        final boolean renew = shouldRenewAuthentication(fedRequest, request);
        final String initialUrl = CommonUtils.constructRedirectUrl(casProperties.getServer().getLoginUrl(),
                CasProtocolConstants.PARAMETER_SERVICE, serviceUrl, renew, false);
        LOGGER.debug("Redirecting authN request to [{}]", initialUrl);
        final AuthenticationRedirectStrategy authenticationRedirectStrategy = new DefaultAuthenticationRedirectStrategy();
        authenticationRedirectStrategy.redirect(request, response, initialUrl);
    } catch (final Exception e) {
        throw Throwables.propagate(e);
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:16,代码来源:WSFederationValidateRequestController.java

示例3: build

import org.jasig.cas.client.util.CommonUtils; //导入方法依赖的package包/类
@Override
public RedirectAction build(final CasClient casClient, final WebContext context) {
    try {
        final CasConfiguration casConfiguration = casClient.getConfiguration();
        final String redirectionUrl = CommonUtils.constructRedirectUrl(casConfiguration.getLoginUrl(),
                CasProtocolConstants.PARAMETER_SERVICE,
                casClient.computeFinalCallbackUrl(context),
                casConfiguration.isRenew(), casConfiguration.isGateway());
        LOGGER.debug("Final redirect url is [{}]", redirectionUrl);
        return RedirectAction.redirect(redirectionUrl);
    } catch (final Exception e) {
        throw new IllegalArgumentException(e);
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:15,代码来源:OAuth20DefaultCasClientRedirectActionBuilder.java

示例4: retrieveCredentials

import org.jasig.cas.client.util.CommonUtils; //导入方法依赖的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

示例5: getRedirectUrl

import org.jasig.cas.client.util.CommonUtils; //导入方法依赖的package包/类
protected String getRedirectUrl(final String urlEncodedService, final HttpServletRequest request) {
	ServiceProperties sp = wrappedCasAuthEntryPoint.getServiceProperties();
	String url = CommonUtils.constructRedirectUrl(wrappedCasAuthEntryPoint.getLoginUrl(), sp.getServiceParameter(),
			urlEncodedService, sp.isSendRenew(), false);

	if (request.getRequestURI().endsWith("/logoutcas")) {
		url = url + "&so=yes";
	}

	String account = parseAccount(getSavedRequestRedirectUrl(request));
	if (StringUtils.isEmpty(account)) {
		return url;
	}
	return url + "&account=" + account;
}
 
开发者ID:SmarterApp,项目名称:TechnologyReadinessTool,代码行数:16,代码来源:CasAuthenticationEntryPoint.java

示例6: logout

import org.jasig.cas.client.util.CommonUtils; //导入方法依赖的package包/类
@RequestMapping("/logout")
public void logout(HttpServletRequest request,HttpServletResponse response) throws IOException{
	 HttpSession session = request.getSession(false);
        if (session != null) {
            session.invalidate();
        }
	String loginUrl = (String)RainbowProperties.getProperties(CAS_LOGOUT);
	String serviceUrl = (String)RainbowProperties.getProperties(CLIENT_SERVICE) + "/login";
	if(serviceUrl == null || serviceUrl.length() == 0){
		serviceUrl = "http://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/login";
	}
	ServiceProperties sp = (ServiceProperties)SpringApplicationContext.getBean("serviceProperties");
	String redirectUrl = CommonUtils.constructRedirectUrl(loginUrl, sp.getServiceParameter(), serviceUrl, false, false);
	response.sendRedirect(redirectUrl);
}
 
开发者ID:youngor,项目名称:openclouddb,代码行数:16,代码来源:LogoutAction.java

示例7: constructRedirectUrl

import org.jasig.cas.client.util.CommonUtils; //导入方法依赖的package包/类
/**
 * Uses the CAS CommonUtils to build the CAS Redirect URL.
 */
private String constructRedirectUrl(String serviceUrl, boolean renew, boolean gateway) {
    return CommonUtils.constructRedirectUrl(casLoginUrl, "service", serviceUrl, renew, gateway);
}
 
开发者ID:Unicon,项目名称:shib-cas-authn3,代码行数:7,代码来源:ShibcasAuthServlet.java

示例8: doFilter

import org.jasig.cas.client.util.CommonUtils; //导入方法依赖的package包/类
public final void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse, final FilterChain filterChain) throws IOException, ServletException {
    final HttpServletRequest request = (HttpServletRequest) servletRequest;
    final HttpServletResponse response = (HttpServletResponse) servletResponse;
    
    if (isRequestUrlExcluded(request)) {
        log.debug("Request is ignored.");
        filterChain.doFilter(request, response);
        return;
    }
    
    final HttpSession session = request.getSession(false);
    final Assertion assertion = session != null ? (Assertion) session.getAttribute(CONST_CAS_ASSERTION) : null;

    if (assertion != null && loggedOutOfSakai()) {
        log.debug("found a CAS assertion and we are logged out of Sakai. Invalidating the session so we don't get logged back on by an old assertion.");
        session.invalidate();
    }  else if (assertion != null) {
        filterChain.doFilter(request, response);
        return;
    }

    final String serviceUrl = constructServiceUrl(request, response);
    final String ticket = retrieveTicketFromRequest(request);
    final boolean wasGatewayed = this.gateway && this.gatewayStorage.hasGatewayedAlready(request, serviceUrl);

    if (CommonUtils.isNotBlank(ticket) || wasGatewayed) {
        filterChain.doFilter(request, response);
        return;
    }

    final String modifiedServiceUrl;

    log.debug("no ticket and no assertion found");
    if (this.gateway) {
        log.debug("setting gateway attribute in session");
        modifiedServiceUrl = this.gatewayStorage.storeGatewayInformation(request, serviceUrl);
    } else {
        modifiedServiceUrl = serviceUrl;
    }

    if (log.isDebugEnabled()) {
    	log.debug("Constructed service url: {}", modifiedServiceUrl);
    }

    final String urlToRedirectTo = CommonUtils.constructRedirectUrl(this.casServerLoginUrl, getProtocol().getServiceParameterName(), modifiedServiceUrl, this.renew, this.gateway);

    if (log.isDebugEnabled()) {
    	log.debug("redirecting to \"{}\"", urlToRedirectTo);
    }
    this.authenticationRedirectStrategy.redirect(request, response, urlToRedirectTo);
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:52,代码来源:SakaiCasAuthenticationFilter.java

示例9: doFilter

import org.jasig.cas.client.util.CommonUtils; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 *
 * @param servletRequest .
 * @param servletResponse .
 * @param filterChain .
 * @throws IOException in case of error.
 * @throws ServletException in case of error.
 */
public final void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse,
        final FilterChain filterChain) throws IOException, ServletException {
    final HttpServletRequest request = (HttpServletRequest) servletRequest;
    final HttpServletResponse response = (HttpServletResponse) servletResponse;
    final HttpSession session = request.getSession(false);
    final Assertion assertion = session != null ? (Assertion) session.getAttribute(CONST_CAS_ASSERTION)
            : null;

    if (assertion != null) {
        filterChain.doFilter(request, response);
        return;
    }

    final String serviceUrl = constructServiceUrl(request, response);
    final String ticket = retrieveTicketFromRequest(request);
    final boolean wasGatewayed = this.gateway
            && this.gatewayStorage.hasGatewayedAlready(request, serviceUrl);

    if (CommonUtils.isNotBlank(ticket) || wasGatewayed || isExcludedUrl(request)) {
        filterChain.doFilter(request, response);
        return;
    }

    final String modifiedServiceUrl;

    LOG.debug("no ticket and no assertion found");
    if (this.gateway) {
        LOG.debug("setting gateway attribute in session");
        modifiedServiceUrl = this.gatewayStorage.storeGatewayInformation(request, serviceUrl);
    } else {
        modifiedServiceUrl = serviceUrl;
    }

    LOG.debug("Constructed service url: " + modifiedServiceUrl);

    final String urlToRedirectTo = CommonUtils.constructRedirectUrl(this.casServerLoginUrl,
            getServiceParameterName(), modifiedServiceUrl, this.renew, this.gateway);

    LOG.debug("redirecting to \"" + urlToRedirectTo + "\"");

    response.sendRedirect(urlToRedirectTo);
}
 
开发者ID:NCIP,项目名称:caarray,代码行数:52,代码来源:CasAuthenticationFilter.java


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