-
Notifications
You must be signed in to change notification settings - Fork 26
CAS server events
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 ApplicationEvent
s 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 ApplicationListener
s for event(s) of interest and proceed with custom computation(s) based on those 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 ApplicationEvent
s:
- CasSsoSessionEstablishedEvent
- CasSsoSessionDestroyedEvent
- CasServiceTicketGrantedEvent
- CasServiceTicketValidatedEvent
- First configure the events publisher aspect using Spring's
<aop:aspectj-autoproxy/>
- 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>
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: