use of org.jasig.cas.client.authentication.DefaultAuthenticationRedirectStrategy in project cas by apereo.
the class AbstractSamlProfileHandlerController method issueAuthenticationRequestRedirect.
/**
* 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);
}
use of org.jasig.cas.client.authentication.DefaultAuthenticationRedirectStrategy in project cas by apereo.
the class WSFederationValidateRequestController method redirectToIdentityProvider.
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);
}
}
use of org.jasig.cas.client.authentication.DefaultAuthenticationRedirectStrategy in project cas by apereo.
the class WSFederationValidateRequestController method handleLogoutRequest.
private void handleLogoutRequest(final WSFederationRequest fedRequest, final HttpServletRequest request, final HttpServletResponse response) throws Exception {
String logoutUrl = casProperties.getServer().getLogoutUrl();
if (StringUtils.isNotBlank(fedRequest.getWreply())) {
final Service service = webApplicationServiceFactory.createService(fedRequest.getWreply());
final WSFederationRegisteredService registeredService = getWsFederationRegisteredService(service);
LOGGER.debug("Invoking logout operation for request [{}], redirecting next to [{}] matched against [{}]", fedRequest, fedRequest.getWreply(), registeredService);
final String logoutParam = casProperties.getLogout().getRedirectParameter();
logoutUrl = logoutUrl.concat("?").concat(logoutParam).concat("=").concat(service.getId());
}
final AuthenticationRedirectStrategy authenticationRedirectStrategy = new DefaultAuthenticationRedirectStrategy();
authenticationRedirectStrategy.redirect(request, response, logoutUrl);
}
Aggregations