The following is an account of how to integrate CAS with the Apache Pluto portal driver and a sample CASified portlet. To reproduce this solution some prior familiarity with Tomcat, Pluto and an understanding of CAS proxying would be advantageous. For further coverage of why CAS and portlets should work together see: Portlets using Proxy CAS
Why use the Pluto portal driver instead of a real portal platform?
The Pluto portal is not meant to be a fully functional portal as it only meets the bare minimum requirements for the Pluto container. That said it is distributed as part of the reference implementation of JSR168 therefore any portlet that works in the Pluto portal driver can be assured as JSR168 compliant. Since the Pluto portal is a dedicated portlet platform it is lightweight and easy to deploy portlets to, which is very handy for development purposes.
Preparation: Establishing the Tomcat, Pluto and CAS server platform
The Apache Pluto binary bundled distribution includes a version of Tomcat 5. If you are using a 1.4X JVM you will also need to install an additional Tomcat 5 compatibility pack.
In order for the CAS proxying to work you need to ensure that a SSL certificate is installed into Tomcat and that the CAS server trusts this certificate. This is beyond the scope of this document but it is very easy to install a CAS server onto the Pluto Tomcat instance, generate a local Tomcat SSL certificate and import this into the local JVM (into %JAVA_HOME%/jre/lib/security/cacerts).
At this point, I will assume that you have a working installation of Pluto, a working CAS server and appropriate SSL certificates and trust relationships established.
In the recipe below I will assume that Tomcat is running at http://localhost:8080 and https://localhost:8443. This Tomcat instance has pluto, portlets and a CAS server installed.
Step One: Install CASFilter into the pluto web application.
You need to install the casclient.jar libraries into the Pluto webapp so that it can find the CAS classes. Then you need to modify the Pluto web.xml to install CASFilter and the CAS proxy servlet. An example modified web.xml might look like:
Re-start the Tomcat server and you should now be redirected to the CAS server for authentication when you access http://localhost:8080/pluto/portal. If after login you are redirected to the Pluto portal then all is well with the Pluto/CAS server trust relationships.
Step Two: Create a CASified portlet
The next step is to a create a "HelloWorld" type of portlet to be CASified (see attached helloWorldPortlet.zip). This uses copies of CASPortletWrapper, CASPortletUtils and ProxyTicketValidatorFactory taken from this Wiki. The attached example is a simple HelloWorld portlet whose VIEW mode includes the contents of a JSP page. This portlet is wrapped by the CASPortletWrapper. The portlet.xml for this portlet application will look something like this:
and the web.xml for this portlet will look something like this:
Install the portlet into the Pluto portal
At this point you can compile (using Ant) and install the portlet into the Pluto portal using the portlet admin application Deploy War (I found that I needed to create a temp directory for this to work), this will install the portlet for you into the Pluto portal and make any necessary adjustments for it to run as a portlet in this container. The portlet won't work yet because the Pluto portal has not yet been configured to pass CAS tickets to the backend portlets.
Step Three: Configure Pluto portal to pass CAS tickets
After a series of experiments I decided to integrate CAS into the portal by intercepting each portlet request as this seemed the least complicated technique. The officially endorsed method to pass dynamic information into the portlets would be to implement a DynamicInformationProvider but I found that this was not being called when establishing the inital portlet rendering.
Intercepting portlet requests is achieved by implementing a PortletContainerWrapper class. I created a new class CASPortletContainerWrapperImpl based on a mixture of Pluto container's PortletContainerImpl and Pluto portal's PortletContainerWrapperImpl with additional CAS specific methods to obtain proxy tickets for the portlets. This new class will be called everytime a portlet is invoked by the portal. I have attached CASPortletContainerWrapperImpl.java and CASPortletContainerWrapperImpl.class to this page and I have also included it with helloWorldPortlet.zip (although this is just for ease of build it is not used directly by the portlet).
You need to install this class into the Pluto portal by copying CASPortletContainerWrapperImpl.class into /pluto/WEB-INF/classes/org/apache/pluto/core directory.
I aimed to achieve Pluto/CAS integration with minimal changes to Pluto portal code so I wrote CASPortletContainerWrapperImpl as part of the org.apache.pluto.core package. This was done for convienience because if I was to move this class outside of the org.apache.pluto.core package I would no longer be able to use the default PortletContainerFactory from this package which would overcomplicate things.
You now need to configure Pluto to use this new wrapper, this is done by editing /pluto/WEB-INF/config/services/configServices.properties and commenting out the previous PortletContainerWrapperImpl and adding the new CAS wrapper thus:
If all has gone well, after a server restart you should be able to see something like the following screen:
This was example was produced using Pluto-1.0.1-rc4 (bundled with Tomcat 5.5.9), J2SE SDK v 1.4.2_09, Apache Ant 1.6.2 and Yale CAS Server 2.0.11.