[java-idp-testbed] branch master updated: Add additional CAS test options.

Scott Cantor cantor.2 at osu.edu
Thu Apr 9 11:07:42 EDT 2020


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch master
in repository java-idp-testbed.

View the commit online:
http://git.shibboleth.net/view/?p=java-idp-testbed.git;a=commit;h=577c9e3e7383f65d41c59b46c82d5407c4d79076

The following commit(s) were added to refs/heads/master by this push:
       new  577c9e3   Add additional CAS test options.
577c9e3 is described below

commit 577c9e3e7383f65d41c59b46c82d5407c4d79076
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Apr 9 11:00:38 2020 -0400

    Add additional CAS test options.
---
 src/main/java/sp/CASController.java | 75 ++++++++++++++++++++++++++++++++++++-
 src/main/webapp/index.html          |  4 +-
 2 files changed, 76 insertions(+), 3 deletions(-)

diff --git a/src/main/java/sp/CASController.java b/src/main/java/sp/CASController.java
index 8980782..22c4866 100644
--- a/src/main/java/sp/CASController.java
+++ b/src/main/java/sp/CASController.java
@@ -78,6 +78,68 @@ public class CASController {
     }
 
     /**
+     * Init SSO by redirecting to the CAS login service with the gateway parameter.
+     * 
+     * @param servletRequest ...
+     * @param servletResponse ...
+     * 
+     * @throws Exception if something bad happens
+     */
+    @RequestMapping(value = "/InitSSOGateway", method = RequestMethod.GET)
+    public void initLoginGateway(HttpServletRequest servletRequest, HttpServletResponse servletResponse) throws Exception {
+
+        final String baseUrl = getBaseUrl(servletRequest);
+
+        final String endpointURL = baseUrl + idpCASEndpointPath + "/login";
+
+        final URLBuilder urlBuilder = new URLBuilder(endpointURL);
+
+        final List<Pair<String, String>> queryParams = urlBuilder.getQueryParams();
+
+        queryParams.add(new Pair<String, String>(ProtocolParam.Service.id(), baseUrl + casSPServicePath));
+        queryParams.add(new Pair<String, String>(ProtocolParam.Gateway.id(), "true"));
+
+        final String redirectURL = urlBuilder.buildURL();
+
+        HttpServletSupport.addNoCacheHeaders(servletResponse);
+        HttpServletSupport.setUTF8Encoding(servletResponse);
+
+        log.debug("Sending redirect to '{}'", redirectURL);
+        servletResponse.sendRedirect(redirectURL);
+    }
+
+    /**
+     * Init SSO by redirecting to the CAS login service with the renew parameter.
+     * 
+     * @param servletRequest ...
+     * @param servletResponse ...
+     * 
+     * @throws Exception if something bad happens
+     */
+    @RequestMapping(value = "/InitSSORenew", method = RequestMethod.GET)
+    public void initLoginGatewayRenew(HttpServletRequest servletRequest, HttpServletResponse servletResponse) throws Exception {
+
+        final String baseUrl = getBaseUrl(servletRequest);
+
+        final String endpointURL = baseUrl + idpCASEndpointPath + "/login";
+
+        final URLBuilder urlBuilder = new URLBuilder(endpointURL);
+
+        final List<Pair<String, String>> queryParams = urlBuilder.getQueryParams();
+
+        queryParams.add(new Pair<String, String>(ProtocolParam.Service.id(), baseUrl + casSPServicePath));
+        queryParams.add(new Pair<String, String>(ProtocolParam.Renew.id(), "true"));
+
+        final String redirectURL = urlBuilder.buildURL();
+
+        HttpServletSupport.addNoCacheHeaders(servletResponse);
+        HttpServletSupport.setUTF8Encoding(servletResponse);
+
+        log.debug("Sending redirect to '{}'", redirectURL);
+        servletResponse.sendRedirect(redirectURL);
+    }
+
+    /**
      * Produce a page displaying a link to the CAS validation endpoint.
      * 
      * @param servletRequest ...
@@ -90,14 +152,23 @@ public class CASController {
     @RequestMapping(value = "/Service", method = RequestMethod.GET)
     public ResponseEntity<String> handleCASResponse(HttpServletRequest servletRequest, HttpServletResponse servletResponse) throws Exception {
 
+        final String ticket = servletRequest.getParameter(ProtocolParam.Ticket.id());
+        if (ticket == null) {
+            final String html = "<html><body>No CAS ticket returned.</body></html>";
+            log.trace("Returning html '{}'", html);
+
+            final HttpHeaders headers = new HttpHeaders();
+            headers.add("Content-Type", "text/html");
+
+            return new ResponseEntity<>(html, headers, HttpStatus.FORBIDDEN);
+        }
+
         final String baseUrl = getBaseUrl(servletRequest);
 
         final String endpointURL = baseUrl + idpCASEndpointPath + "/serviceValidate";
 
         final URLBuilder urlBuilder = new URLBuilder(endpointURL);
 
-        final String ticket = servletRequest.getParameter(ProtocolParam.Ticket.id());
-
         final List<Pair<String, String>> queryParams = urlBuilder.getQueryParams();
         queryParams.add(new Pair<String, String>(ProtocolParam.Service.id(), baseUrl + casSPServicePath));
         queryParams.add(new Pair<String, String>(ProtocolParam.Ticket.id(), ticket));
diff --git a/src/main/webapp/index.html b/src/main/webapp/index.html
index 7714370..4fd59e0 100644
--- a/src/main/webapp/index.html
+++ b/src/main/webapp/index.html
@@ -9,7 +9,9 @@
 <h1>Testbed Execution Menu</h1>
 
 <ul>
-<li><a href="sp/casclient">Init CAS SSO</a></li>
+<li><a href="sp/CAS/InitSSO">Init CAS SSO</a></li>
+<li><a href="sp/CAS/InitSSOGateway">Init CAS SSO with gateway</a></li>
+<li><a href="sp/CAS/InitSSORenew">Init CAS SSO with renew</a></li>
 
 <li><a href="sp/SAML2/InitSSO/Redirect">Init SAML 2 SSO, Redirect Binding</a></li>
 <li><a href="sp/SAML2/InitSSO/Passive">Init SAML 2 SSO, Redirect Binding, Passive Request</a></li>

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list