JpaTicketRegistry

Table of Contents
Home
Overall Architecture
Authentication
Authentication Managers
Security Policy
TicketRegistry
Testing
Protocols
Advanced Features
Tutorials and HOWTOs
Troubleshooting
Services Management
Extensions

Enabling the JpaTicketRegistry

Overriding the ticketRegistry.xml

If you're not using the Maven2 WAR Overlay process, then you'll need to edit the WEB-INF/spring-configuration/ticketRegistry.xml.

If you are using the Maven2 WAR overlway process, then you'll need to place the "ticketRegistry.xml" file below into the WEB-INF/spring-configuration/ directory:

<?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:p="http://www.springframework.org/schema/p"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
       
    <!-- Ticket Registry -->
    <bean id="ticketRegistry" class="org.jasig.cas.ticket.registry.JpaTicketRegistry">
    	<constructor-arg index="0" ref="entityManagerFactory" />
    </bean>
    
	<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
		<property name="dataSource" ref="dataSource"/>
		<property name="jpaVendorAdapter">
			<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
				<property name="generateDdl" value="true"/>
				<property name="showSql" value="true" />
			</bean>
		</property>
		<property name="jpaProperties">
			<props>
				<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
				<prop key="hibernate.hbm2ddl.auto">update</prop>
			</props>
		</property>
	</bean>

	<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
		p:entityManagerFactory-ref="entityManagerFactory" />

	<tx:annotation-driven transaction-manager="transactionManager"/>

	<bean
		id="dataSource"
		class="org.apache.commons.dbcp.BasicDataSource"
		p:driverClassName="com.mysql.jdbc.Driver"
		p:url="jdbc:mysql://localhost:3306/test?autoReconnect=true"
		p:password=""
		p:username="" />
	
	<!--Quartz -->
	<!-- TICKET REGISTRY CLEANER -->
	<bean id="ticketRegistryCleaner" class="org.jasig.cas.ticket.registry.support.DefaultTicketRegistryCleaner"
		p:ticketRegistry-ref="ticketRegistry" />
	
	<bean id="jobDetailTicketRegistryCleaner" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"
		p:targetObject-ref="ticketRegistryCleaner"
		p:targetMethod="clean" />
	
	<bean id="triggerJobDetailTicketRegistryCleaner" class="org.springframework.scheduling.quartz.SimpleTriggerBean"
		p:jobDetail-ref="jobDetailTicketRegistryCleaner"
		p:startDelay="20000"
		p:repeatInterval="5000000" />

	<bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
		<property name="triggers">
			<list>
				<ref
					local="triggerJobDetailTicketRegistryCleaner" />
			</list>
		</property>
	</bean>
</beans>

Be sure to replace the dataSource information with your own. You may reference other data sources external to this file.

Setting up the Database

If your user has sufficient privileges (do this on a test/dev tier first), on start up, the database tables should be created. Note that MySql users MAY need to change BLOB to LONGBLOB if they have exceptionally large lists of services that a user accesses.

Updating the Maven2 POM

If you are using the Maven2 WAR overlay method, add these to your custom webapp POM. Otherwise add these to the CAS project's cas-server-webapp/pom.xml file:

<dependency>
	<groupId>org.hibernate</groupId>
	<artifactId>hibernate-entitymanager</artifactId>
	<version>3.3.1.ga</version>
	<scope>runtime</scope>
</dependency>

<dependency>
	<groupId>org.hibernate</groupId>
	<artifactId>hibernate-commons-annotations</artifactId>
	<version>3.3.0.ga</version>
	<scope>runtime</scope>
</dependency>

<dependency>
	<groupId>org.hibernate</groupId>
	<artifactId>hibernate-annotations</artifactId>
	<version>3.3.0.ga</version>
	<scope>runtime</scope>
</dependency>

<dependency>
	<groupId>org.hibernate</groupId>
	<artifactId>hibernate</artifactId>
	<version>3.2.4.sp1</version>
	<scope>runtime</scope>
</dependency>

<dependency>
	<groupId>concurrent</groupId>
	<artifactId>concurrent</artifactId>
	<version>1.3.4</version>
	<scope>runtime</scope>
</dependency>

Database Connection Pooling

It is strongly recommended that database connection pooling be used in a production environment. The following configuration makes use of the c3p0 connection pooling library. Virginia Tech has used this connection pooling library in preference to the Apache Jakarta project's commons-dbcp library in production for months as of this writing (2010-01-20) and have been very pleased with performance and configurability.

DataSource Configuration in deployerConfigContext.xml
<bean
    id="dataSource"
    class="com.mchange.v2.c3p0.ComboPooledDataSource"
    p:driverClass="${database.driverClass}"
    p:jdbcUrl="${database.url}"
    p:user="${database.user}"
    p:password="${database.password}"
    p:initialPoolSize="${database.pool.minSize}"
    p:minPoolSize="${database.pool.minSize}"
    p:maxPoolSize="${database.pool.maxSize}"
    p:maxIdleTimeExcessConnections="${database.pool.maxIdleTime}"
    p:checkoutTimeout="${database.pool.maxWait}"
    p:acquireIncrement="${database.pool.acquireIncrement}"
    p:acquireRetryAttempts="${database.pool.acquireRetryAttempts}"
    p:acquireRetryDelay="${database.pool.acquireRetryDelay}"
    p:idleConnectionTestPeriod="${database.pool.idleConnectionTestPeriod}"
    p:preferredTestQuery="${database.pool.connectionHealthQuery}"
  />

In order to use c3p0, the maven dependency for the library must be included in your Maven War Overlay POM.

c3p0 Maven Dependency
<dependency>
      <groupId>c3p0</groupId>
      <artifactId>c3p0</artifactId>
      <version>0.9.1.2</version>
      <scope>runtime</scope>
    </dependency>
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.