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

Custom CAS configuration XML namespace

Dmitriy Kopylenko edited this page Mar 25, 2015 · 21 revisions

Since version 1.4 of cas-addons there is a custom Spring beans XML configuration namespace for key cas-addons beans as well as some core CAS beans. Having such a namespace should greatly reduce a copy/paste generic bean boilerplate and add more intention revealing shape to the application context config when working with custom war overlays of CAS server software. Another advantage for this custom namespace schema is a wonderful support of modern IDEs for XML schemas and code/XML auto-completion.

Namespace declaration

Just declare the http://unicon.net/schema/cas namespace in the beans header of Spring's application context file where elements of this namespace will be used:

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:cas="http://unicon.net/schema/cas"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://unicon.net/schema/cas
                           http://unicon.net/schema/cas/cas-addons.xsd">

...

</beans>

Available elements

JSON Services Registry

<cas:json-services-registry/>

Note that the default location of a configuration file containing JSON blocks for registered services is /etc/cas/servicesRegistry.conf. If more explicit configuration of this file's location is desired, use this form:

<cas:json-services-registry config-file="file:/some/other/path/servicesRegistry.conf"/>

This is equivalent of the following standard Spring bean declaration:

<bean id="serviceRegistryDao" class="net.unicon.cas.addons.serviceregistry.JsonServiceRegistryDao" 
                              init-method="loadServices">
        <constructor-arg index="0" value="file:/some/other/path/servicesRegistry.conf"/>
</bean>

Except you almost certainly want to externalize that path to a cas.properties property value, so what you really want is

<cas:json-services-registry config-file="${service.registry.config.location:file:/etc/cas/registeredServices.conf}"/>

Which is equivalent to

<bean id="serviceRegistryDao" class="net.unicon.cas.addons.serviceregistry.JsonServiceRegistryDao" 
                              init-method="loadServices">
        <constructor-arg index="0" value="${service.registry.config.location:file:/etc/cas/registeredServices.conf}"/>
</bean>

JSON Attribute Repository

<cas:json-attribute-repository/>

Note that the default location of a configuration file containing JSON blocks for principal attributes is /etc/cas/person-attributes.conf. If more explicit configuration of this file's location is desired, use this form:

<cas:json-attribute-repository config-file="file:/some/other/path/person-attributes.conf"/>

This is equivalent of the following standard Spring bean declaration:

<bean id="serviceRegistryDao" class="net.unicon.cas.addons.persondir.JsonBackedComplexStubPersonAttributeDao" 
                              init-method="init">
        <constructor-arg index="0" value="file:/some/other/path/person-attributes.conf"/>
</bean>

And likewise, what you probably really want is to externalize this path into a cas.properties path, so

<cas:json-attribute-repository config-file="${person.attributes.config.location:file:/etc/cas/person-attributes.conf}"/>

Resource Change Detector

<cas:resource-change-detector id="registeredServicesChangeDetector" 
    watched-resource="file:/etc/cas/servicesRegistry.conf"/>

This is equivalent of the following standard Spring bean declaration:

<bean id="registeredServicesChangeDetector"
          class="net.unicon.cas.addons.support.ResourceChangeDetectingEventNotifier"
          c:watchedResource="file:/etc/cas/servicesRegistry.conf"/>

Default Authentication Support

<cas:default-authentication-support/>

This is equivalent of the following standard Spring bean declaration:

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

Default CAS Events Publisher

<cas:default-events-publisher/>

This is equivalent of the following standard Spring bean declaration:

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

Default Registered Services Policies

<cas:default-registered-services-policies/>

This is equivalent of the following standard Spring bean declaration:

<bean id="registeredServicesPolicies" class="net.unicon.cas.addons.serviceregistry.services.internal.DefaultRegisteredServicesPolicies"/>

Slf4j Inspektr AuditTrailManager

<cas:inspektr-log-files-audit-manager/>

This is equivalent of the following standard Spring bean declaration:

<bean id="auditTrailManager class="com.github.inspektr.audit.support.Slf4jLoggingAuditTrailManager"/>

Default Health Check Monitor

<cas:default-health-check-monitor/>

This is equivalent of the following standard Spring bean declaration:

<bean id="healthCheckMonitor" class="org.jasig.cas.monitor.HealthCheckMonitor">
        <property name="monitors">
            <list>
                <bean class="org.jasig.cas.monitor.MemoryMonitor"
                      p:freeMemoryWarnThreshold="10"/>
            </list>
        </property>
    </bean>

Default Testing Authentication Manager

<cas:default-test-authentication-manager/>

This is equivalent of the following standard Spring bean declaration:

<bean id="authenticationManager"
          class="org.jasig.cas.authentication.AuthenticationManagerImpl">

        <property name="credentialsToPrincipalResolvers">
            <list>
                <bean class="org.jasig.cas.authentication.principal.UsernamePasswordCredentialsToPrincipalResolver"
                        p:attributeRepository-ref="attributeRepository"/>

                <bean class="org.jasig.cas.authentication.principal.HttpBasedServiceCredentialsToPrincipalResolver"/>
            </list>
        </property>
        <property name="authenticationHandlers">
            <list>
                <bean class="org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler"
                      p:httpClient-ref="httpClient" />
                <bean class="org.jasig.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler"/>                
            </list>
        </property>
    </bean>

In version 1.16

Version 1.16 introduces an ability to inject an attribute repository bean reference into an internally created UsernamePasswordCredentialsToPrincipalResolver by using a new optional attribute-repository-for-principal-resolver attribute like so:

<cas:default-test-authentication-manager attribute-repository-for-principal-resolver="attributeRepository"/>
        

Example config

The example config files utilizing this namespace could be found in Unicon's reference implementation of CAS war overlay:

Clone this wiki locally