Theme Control

New CAS documentation site

CAS documentation has moved over to jasig.github.io/cas, starting with CAS version 4.x. The wiki will no longer be maintained. For the most recent version of the documentation, please refer to the aforementioned link.

With the introduction of Services Management application, deployers are now able to switch the themes based on different services. For example, you may want to have different login screens (different styles) for staff applications and student applications. Or, you want to show two layouts for day time and night time. This document could help you go through the basic settings to achieve this.

Procedures

  1. Add another set of theme properties file, which must be placed to the root of /WEB-INF/classes folder, name it as theme_name.properties
  2. Add related style files (optional)
    For instance, duplicate /themes/default folder as /themes/theme_name folder, change the styles inside cas.css file
  3. Change the value of cas.themeResolver.defaultThemeName in cas.properties file to the theme_name, this property value will be used if the required theme is not found (optional)
  4. Make use of it in JSP files

    <spring:theme code="css" />
    

    The taglib will retrieve the property css from the chosen theme_name.properties file

  5. Configure your CAS instance to determine which theme to be used according to configurations done by Services Management, change it like this in cas-servlet.xml.

    <bean id="themeResolver" class="org.jasig.cas.services.web.ServiceThemeResolver"
    p:defaultThemeName="${cas.themeResolver.defaultThemeName}"
    p:servicesManager-ref="servicesManager"
    p:argumentExtractors-ref="argumentExtractors" />
    
  6. Add a new service in the Services Management web interface, and in the field Theme Name, type in theme_name
  7. Try to invoke the service just added, you should be able to see the new styles defined in theme_name

Remarks

Since all information stored in a theme properties file are text, so you could actually not only customize the styles, but also text shown on the pages, image locations, scripts, etc.

Change the bold theme_name to the name you prefer. 

References

  1. http://static.springframework.org/spring/docs/2.5.x/reference/mvc.html#mvc-themeresolver