Skip to content
This repository has been archived by the owner on Nov 3, 2017. It is now read-only.

Commit

Permalink
Fixing the handling of returning the respond to CAS SAML 1.1 clients (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jtgasper3 authored and SavvasMisaghMoayyed committed Jun 10, 2016
1 parent 69b4e7f commit a4ab7be
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
import org.jasig.cas.authentication.principal.GoogleAccountsService;
import org.jasig.cas.authentication.principal.Response;
import org.jasig.cas.authentication.principal.Response.ResponseType;
import org.jasig.cas.authentication.principal.SamlService;
import org.jasig.cas.authentication.principal.SimpleWebApplicationServiceImpl;
import org.jasig.cas.util.HttpClient;
import org.jasig.cas.web.support.GoogleAccountsArgumentExtractor;
import org.jasig.cas.web.support.SamlArgumentExtractor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;
Expand Down Expand Up @@ -148,6 +150,7 @@ public DefaultMultiFactorAuthenticationSupportingWebApplicationService(

@Override
public Response getResponse(final String ticketId) {

final Map<String, String> parameters = new HashMap<String, String>();

final RequestContext requestContext = RequestContextHolder.getRequestContext();
Expand All @@ -162,10 +165,14 @@ public Response getResponse(final String ticketId) {
final String samlRequest = req.getParameter("SAMLRequest");
LOGGER.debug("xmlRequest = " + samlRequest);

final String samlTarget = req.getParameter("TARGET");
LOGGER.debug("samlTarget = " + samlTarget);

if (StringUtils.hasText(ticketId)) {
parameters.put(CONST_PARAM_TICKET, ticketId);
}
if (StringUtils.hasText(samlRequest)) {
LOGGER.debug("working through GoogleAccounts response");
try {
final GoogleAccountsArgumentExtractor googleAccountsArgumentExtractor =
getBean("googleAccountsArgumentExtractor",
Expand All @@ -178,12 +185,33 @@ public Response getResponse(final String ticketId) {
if (StringUtils.hasText(samlResponse)) {
parameters.put("SAMLResponse", samlResponse);
parameters.put("RelayState", relayState);

LOGGER.debug("sendingGoogleAccounts response");
return Response.getPostResponse(getOriginalUrl(), parameters);
}
} catch (final Exception e) {
LOGGER.error(e.getMessage());
}
}
if (StringUtils.hasText(samlTarget)) {
try {
LOGGER.debug("working through Saml (1.1) response");
final SamlArgumentExtractor samlArgumentExtractor =
getBean("samlArgumentExtractor",
SamlArgumentExtractor.class);
final SamlService samlService =
(SamlService) samlArgumentExtractor.extractService(req);
samlService.setPrincipal(getPrincipal());

parameters.put("SAMLart", ticketId);
parameters.put("TARGET", getOriginalUrl());

LOGGER.debug("sending Saml (1.1) response");
return Response.getRedirectResponse(getOriginalUrl(), parameters);

} catch (final Exception e) {
LOGGER.error(e.getMessage());
}
}

if (ResponseType.POST == this.responseType) {
Expand Down

0 comments on commit a4ab7be

Please sign in to comment.