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

CAS server events

dima767 edited this page Dec 7, 2012 · 6 revisions

Since version 1.1 of cas-addons there is an AOP component that intercepts significant CAS server runtime actions and publishes them as Spring's typed ApplicationEvents containing particular event's context data to a Spring's ApplicationContext where a CAS server is deployed. This opens up a possibility to register Spring's ApplicationListeners for event(s) of interest and proceed with custom computation(s) based on those events.

CAS actions intercepted and turned into events

Currently the following CAS actions are intercepted:

  • Establishing of an SSO session - by means of CentralAuthenticationService#createTicketGrantingTicket API execution
  • Destruction of an SSO session - by means of CentralAuthenticationService#destroyTicketGrantingTicket API execution
  • Generation of a Service Ticket - by means of CentralAuthenticationService#grantServiceTicket API execution
  • Validation of a Service Ticket - by means of CentralAuthenticationService#validateServiceTicket API execution

These actions are turned into the following Spring ApplicationEvents:

Configuration

  1. First configure the events publisher aspect using Spring's <aop:aspectj-autoproxy/>
  2. To configure listeners for these events in the CAS application context (configured in CAS maven overlay), one could simply create these listeners and annotate them with @Component to let Spring pick them up during bootstrap. Here is a sample config (taken from a sample app available in Unicon's sample CAS maven overlay):
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:c="http://www.springframework.org/schema/c"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">

       <aop:aspectj-autoproxy/>

       <bean id="authenticationSupport" class="net.unicon.cas.addons.authentication.internal.DefaultAuthenticationSupport"
             c:ticketRegistry-ref="ticketRegistry"/>

       <bean id="casEventsPublisher" class="net.unicon.cas.addons.info.events.CentralAuthenticationServiceEventsPublishingAspect"
             c:authenticationSupport-ref="authenticationSupport"/>

</beans>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">


  <context:component-scan base-package="net.unicon.cas.overlay.events"/>
  <context:annotation-config/>

</beans>

Sample CAS overlay

Here is a sample CAS overlay demonstrating capturing of all the CAS events and then publishing them to preconfigured Apache Camel's websocket endpoint to be instantly picked up by a WebSocket client running in a browser. Here are the relevant parts of interest:

Clone this wiki locally