简体   繁体   中英

Configure Jasig CAS deployerContextConfig using cas.properties

I'm working on an implementation of Jasig CAS version 3.5.2.1

CAS 3.5.2.1 is a Spring 3.1 MVC application.

Currently, the app uses a ContextLoaderListener to populate the WebApplicationContext from an xml file called deployerContextConfig.xml

Can I use properties (such as those loaded from cas.properties ) within the deployerContextConfig.xml file? If so, how?

I am on CAS 3.5.0 but I think it would be the same as your version. First the web.xml will load all the *.xml file inside /WEB-INF/spring-configuration directory and /WEB-INF/deployerConfigContext.xml

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
      /WEB-INF/spring-configuration/*.xml
      /WEB-INF/deployerConfigContext.xml
    </param-value>
</context-param>

The /WEB-INF/spring-configuration/propertyFileConfigurer.xml will load the cas.properties file

<bean id="propertyPlaceholderConfigurer" 
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
    p:location="/WEB-INF/cas.properties" />

Inside the deployerConfigContext.xml:

<!-- Define the contextSource -->
<bean id="contextSourceRepository" class="org.springframework.ldap.core.support.LdapContextSource">
       <property name="pooled" value="false" />
       <property name="urls">
           <bean class="org.springframework.util.StringUtils"
                    factory-method="commaDelimitedListToSet">
                    <constructor-arg type="java.lang.String"
                           value="${ldap.repository.server.urls}" />
            </bean>
        </property>
        <property name="userDn" value="${ldap.authentication.manager.userdn}" />
        <property name="password" value="${ldap.authentication.manager.password}" />

        <property name="baseEnvironmentProperties">
             <map>
                 <entry key="com.sun.jndi.ldap.connect.timeout" value="${ldap.authentication.jndi.connect.timeout}" />
                 <entry key="com.sun.jndi.ldap.read.timeout" value="${ldap.authentication.jndi.read.timeout}" />
                 <entry key="java.naming.security.authentication" value="${ldap.authentication.jndi.security.level}" />
             </map>
        </property>
</bean>

And your cas.properties:

ldap.repository.server.urls=ldap://ldap.usfca.edu:389

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM