本文整理汇总了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);
}
示例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);
}
}
示例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);
}
}
示例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;
}
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}