/** * Constructs the Url for Redirection to the CAS server. Default implementation relies * on the CAS client to do the bulk of the work. * * @param serviceUrl the service url that should be included. * @return the redirect url. CANNOT be NULL. */ protected String createRedirectUrl(final String serviceUrl) { return CommonUtils.constructRedirectUrl(this.loginUrl, this.serviceProperties.getServiceParameter(), serviceUrl, this.serviceProperties.isSendRenew(), false); }
private void redirectToCas( final HttpServletRequest request, final HttpServletResponse response) throws ServerAuthException { try { final String redirectUrl = CommonUtils.constructRedirectUrl( casServerLoginUrl, protocol.getServiceParameterName(), serviceUrl(request, response), renew, false); logger.debug("Redirecting to {}", redirectUrl); response.sendRedirect(redirectUrl); } catch (IOException e) { logger.debug("Redirect to CAS failed with error", e); throw new ServerAuthException("Redirect to CAS failed", e); } } }
/** * Constructs the Url for Redirection to the CAS server. Default implementation relies * on the CAS client to do the bulk of the work. * * @param serviceUrl the service url that should be included. * @return the redirect url. CANNOT be NULL. */ protected String createRedirectUrl(final String serviceUrl) { return CommonUtils.constructRedirectUrl(this.loginUrl, this.serviceProperties.getServiceParameter(), serviceUrl, this.serviceProperties.isSendRenew(), false); }
/** * Constructs the Url for Redirection to the CAS server. Default implementation relies * on the CAS client to do the bulk of the work. * * @param serviceUrl the service url that should be included. * @return the redirect url. CANNOT be NULL. */ protected String createRedirectUrl(final String serviceUrl) { return CommonUtils.constructRedirectUrl(this.loginUrl, this.serviceProperties.getServiceParameter(), serviceUrl, this.serviceProperties.isSendRenew(), false); }
public void testRedirectUrlWithParam() { final String loginUrl = "http://localhost:8080/login?myName=foo"; final String fullyConstructedUrl = CommonUtils.constructRedirectUrl(loginUrl, "foo", "foo", false, false); int count = 0; final char[] chars = fullyConstructedUrl.toCharArray(); for (int i = 0; i < chars.length; i++) { if (chars[i] == '?') { count++; } } assertEquals(1, count); }
public final boolean redirectToCAS(final ServletRequest servletRequest, final ServletResponse servletResponse) 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) { return false; } final String serviceUrl = constructServiceUrl(request, response); final String ticket = CommonUtils.safeGetParameter(request,getArtifactParameterName()); if (CommonUtils.isNotBlank(ticket)) { return false; } final String modifiedServiceUrl; log.debug("no ticket and no assertion found"); modifiedServiceUrl = serviceUrl; if (log.isDebugEnabled()) { log.debug("Constructed service url: " + modifiedServiceUrl); } final String urlToRedirectTo = CommonUtils.constructRedirectUrl(getCasLogin(), getServiceParameterName(), modifiedServiceUrl, false, false); if (log.isDebugEnabled()) { log.debug("redirecting to \"" + urlToRedirectTo + "\""); } response.sendRedirect(urlToRedirectTo); return true; }
final String urlToRedirectTo = CommonUtils.constructRedirectUrl(this.casServerLoginUrl, getServiceParameterName(), modifiedServiceUrl, this.renew, this.gateway);
final String urlToRedirectTo = CommonUtils.constructRedirectUrl(this.casServerLoginUrl, getProtocol().getServiceParameterName(), modifiedServiceUrl, this.renew, this.gateway);
this.serviceParameterName, this.artifactParameterName, true); if (CommonUtils.isBlank(token)) { final String redirectUrl = CommonUtils.constructRedirectUrl(this.casServerLoginUrl, this.serviceParameterName, service, false, false); logger.debug("Redirecting to {}", redirectUrl);
this.serviceParameterName, this.artifactParameterName, true); if (CommonUtils.isBlank(token)) { final String redirectUrl = CommonUtils.constructRedirectUrl(this.casServerLoginUrl, this.serviceParameterName, service, false, false); logger.debug("Redirecting to {}", redirectUrl);
/** * 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 { val authnRequest = (AuthnRequest) pair.getLeft(); val serviceUrl = constructServiceUrl(request, response, pair); LOGGER.debug("Created service url [{}]", DigestUtils.abbreviate(serviceUrl)); val initialUrl = CommonUtils.constructRedirectUrl(casProperties.getServer().getLoginUrl(), CasProtocolConstants.PARAMETER_SERVICE, serviceUrl, authnRequest.isForceAuthn(), authnRequest.isPassive()); val urlToRedirectTo = buildRedirectUrlByRequestedAuthnContext(initialUrl, authnRequest, request); LOGGER.debug("Redirecting SAML authN request to [{}]", urlToRedirectTo); val authenticationRedirectStrategy = new DefaultAuthenticationRedirectStrategy(); authenticationRedirectStrategy.redirect(request, response, urlToRedirectTo); }