Monday 7 October 2013

[JasperServer 5.2] Concurrent User Control

Control concurrency inside jasperserver can be very tricky. However after few iteration, I've manage to get it working. Please take note that this is applicable when I use CAS Server 3.5.2 and CAS Client above 3.1.5 (Jasper bundled) and I haven't test any other version yet.

Here are the steps using overlay method:
1. Open the file "/WEB-INF/applicationContext-externalAuth-CAS-db-mt.xml"
2. Add concurrency handler bean and logout handler on top


<!-- Concurrency control -->
<bean id="concurrentSessionController" class="org.springframework.security.concurrent.ConcurrentSessionControllerImpl">   
    <property name="sessionRegistry" ref="sessionRegistry" />
    <property name="maximumSessions" value="1" />
    <property name="exceptionIfMaximumExceeded" value="false" />

</bean>
 

<bean id="concurrentSessionFilter" class="org.springframework.security.concurrent.ConcurrentSessionFilter">
  <property name="sessionRegistry" ref="sessionRegistry" />
  <property name="expiredUrl" value="${cas.slo.expired.path}" />
  <property name="logoutHandlers">
    <list>
      <ref bean = "logoutHandler"/>
    </list>
  </property>

</bean>
        

<bean id="logoutHandler" class="org.springframework.security.ui.logout.SecurityContextLogoutHandler" />

<bean id="logoutFilter" class="org.springframework.security.ui.logout.LogoutFilter">
  <constructor-arg value="${cas.slo.logout.url}"/>
    <constructor-arg>
      <ref bean = "logoutHandler"/>
    </constructor-arg>
    <property name="filterProcessesUrl" value="${cas.slo.expired.path}"/>

</bean>
<!-- End of Concurrency control -->

3. Find bean id "casAuthenticationManager" and add new property below

<!-- Concurrency control -->
<property name="sessionController" ref="concurrentSessionController" />

4. Open the file "/WEB-INF/applicationContext-security-web.xml"
5. Find bean id "filterChainProxy" and for pattern "/**" add "concurrentSessionFilter" before "filterInvocationInterceptor"
6. For me, I need to put configuration into one place, so adding property file to the classpath by modifying file "/WEB-INF/applicationContext-webapp.xml"
7. Find bean id "propertyConfigurer"
8. Add new value inside property "locations"

<value>classpath*:jasperserver-cas.properties</value>

9. I can then make use of "${cas.slo.expired.path}" as stated above
10. Startup the application and enjoy. User log into first browser then login again into second browser will kick user in the first browser.

Cheers,
Deddy

No comments:

Post a Comment