单点登录JA-SIG研究分析

时间:2021-01-07 00:41:57
  一、数据库配置
        1.复杂数据库驱动jar文件到cas服务端网站的lib目录下
        2.修改 CasServer/WEB-INF/deployerConfigContext.xml文件:
            
单点登录JA-SIG研究分析<!-- 注释掉如下代码-->
单点登录JA-SIG研究分析
<bean class="org.jasig.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler" />

        替换成:
        

单点登录JA-SIG研究分析                <bean class="org.jasig.cas.adaptors.jdbc.QueryDatabaseAuthenticationHandler">
单点登录JA-SIG研究分析                    
<property name="sql" value="select PASSWORD_ from ID_USER where NAME_=?"/>
单点登录JA-SIG研究分析                    
<property name="passwordEncoder" ref="passwordEncoder"/>
单点登录JA-SIG研究分析                    
<property name="dataSource" ref="dataSource"/>
单点登录JA-SIG研究分析                
</bean>

        在文件末尾加入:

单点登录JA-SIG研究分析<!-- 数据源定义 -->
单点登录JA-SIG研究分析    
<bean id="dataSource"
单点登录JA-SIG研究分析        class
="org.springframework.jdbc.datasource.DriverManagerDataSource">
单点登录JA-SIG研究分析        
<property name="driverClassName" value="${db.driver}" />
单点登录JA-SIG研究分析        
<property name="url" value="${db.url}" />
单点登录JA-SIG研究分析        
<property name="username" value="${db.username}" />
单点登录JA-SIG研究分析        
<property name="password" value="${db.password}" />
单点登录JA-SIG研究分析    
</bean>
单点登录JA-SIG研究分析    
<bean id="passwordEncoder"
单点登录JA-SIG研究分析        class
="org.jasig.cas.authentication.handler.DefaultPasswordEncoder"
单点登录JA-SIG研究分析        autowire
="byName">
单点登录JA-SIG研究分析        
<constructor-arg value="MD5" />
单点登录JA-SIG研究分析    
</bean>

        在CasServer/WEB-INF/cas.properties文件中添加:

单点登录JA-SIG研究分析database.hibernate.dialect=org.hibernate.dialect.OracleDialect
单点登录JA-SIG研究分析#database.hibernate.dialect
=org.hibernate.dialect.MySQLDialect
单点登录JA-SIG研究分析#database.hibernate.dialect
=org.hibernate.dialect.HSQLDialect
单点登录JA-SIG研究分析db.driver
=oracle.jdbc.driver.OracleDriver
单点登录JA-SIG研究分析db.url
=jdbc/:oracle/:thin/:@localhost/:1521/:master
单点登录JA-SIG研究分析db.username
=casusername
单点登录JA-SIG研究分析db.password
=caspwd

     二、LDAP配置
            1.复杂cas-server-support-ldap-3.2.jar文件到cas服务端网站的lib目录下
            2.修改CasServer/WEB-INF/deployerConfigContext.xml文件:
            

单点登录JA-SIG研究分析<!-- 注释掉如下代码-->
单点登录JA-SIG研究分析
<bean class="org.jasig.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler" />

 

        替换成:(注意:位置)

单点登录JA-SIG研究分析<bean
单点登录JA-SIG研究分析                    
class="com.jihong.cas.adaptors.ldap.BindLdapAuthenticationHandler">
单点登录JA-SIG研究分析                    
<property name="filter" value="uid=%u" />
单点登录JA-SIG研究分析                    
<!-- 基节点 -->
单点登录JA-SIG研究分析                    
<property name="searchBase"
单点登录JA-SIG研究分析                        value
="OU=单位,O=TJJU" />
单点登录JA-SIG研究分析                    
<property name="contextSource" ref="contextSource" />
单点登录JA-SIG研究分析                
</bean>

文件末尾加入:

单点登录JA-SIG研究分析<bean id="contextSource"
单点登录JA-SIG研究分析        class
="org.jasig.cas.adaptors.ldap.util.AuthenticatedLdapContextSource">
单点登录JA-SIG研究分析        
<property name="password" value="secret" />
单点登录JA-SIG研究分析        
<property name="pooled" value="true" />
单点登录JA-SIG研究分析        
<property name="urls">
单点登录JA-SIG研究分析            
<list>
单点登录JA-SIG研究分析                
<value>ldap://192.168.0.1:389/</value>
单点登录JA-SIG研究分析            
</list>
单点登录JA-SIG研究分析        
</property>
单点登录JA-SIG研究分析        
<!-- property name="userName" value="uid=admin,O=TJJU" /-->
单点登录JA-SIG研究分析        
<property name="baseEnvironmentProperties">
单点登录JA-SIG研究分析            
<map>
单点登录JA-SIG研究分析                
<entry>
单点登录JA-SIG研究分析                    
<key>
单点登录JA-SIG研究分析                        
<value>
单点登录JA-SIG研究分析                            java.naming.security.authentication
单点登录JA-SIG研究分析                        
</value>
单点登录JA-SIG研究分析                    
</key>
单点登录JA-SIG研究分析                    
<value>simple</value>
单点登录JA-SIG研究分析                
</entry>
单点登录JA-SIG研究分析            
</map>
单点登录JA-SIG研究分析        
</property>
单点登录JA-SIG研究分析    
</bean>

     三、分析deployerConfigContext.xml的其他配置
         1.客户端登陆服务配置:每加入一个客户端网站都需修改这个配置。   

单点登录JA-SIG研究分析<bean id="serviceRegistryDao"
单点登录JA-SIG研究分析        class
="org.jasig.cas.services.InMemoryServiceRegistryDaoImpl" />

        例如:

单点登录JA-SIG研究分析<bean id="serviceRegistryDao"
单点登录JA-SIG研究分析        class
="org.jasig.cas.services.InMemoryServiceRegistryDaoImpl">
单点登录JA-SIG研究分析        
<!-- 注册客户端 -->
单点登录JA-SIG研究分析        
<property name="registeredServices">
单点登录JA-SIG研究分析            
<list>
单点登录JA-SIG研究分析            
<!-- 一个客户端配置 -->
单点登录JA-SIG研究分析                
<bean
单点登录JA-SIG研究分析                    
class="org.jasig.cas.services.RegisteredServiceImpl" 
单点登录JA-SIG研究分析                    p:id
="1"
单点登录JA-SIG研究分析                    p:description
="Tout Nancy 2" 
单点登录JA-SIG研究分析                    p:serviceId
="*://localhost:8080/**"
单点登录JA-SIG研究分析                    p:name
="Tout Nancy 2" 
单点登录JA-SIG研究分析                    p:theme
="nancy2" 
单点登录JA-SIG研究分析                    p:allowedToProxy
="true"
单点登录JA-SIG研究分析                    p:enabled
="true" 
单点登录JA-SIG研究分析                    p:ssoEnabled
="true" 
单点登录JA-SIG研究分析                    p:anonymousAccess
="false">
单点登录JA-SIG研究分析                    
<!-- 允许的属性 -->
单点登录JA-SIG研究分析                    
<property name="allowedAttributes" value="Name,telephoneNumber,fullName,mail,eduPersonAffiliation,groupMembership"/>
单点登录JA-SIG研究分析                
</bean>
单点登录JA-SIG研究分析            
</list>
单点登录JA-SIG研究分析        
</property>
单点登录JA-SIG研究分析    
</bean>

        2.属性注册:从数据库中读取的属性

 

单点登录JA-SIG研究分析<bean id="attributeRepository"
单点登录JA-SIG研究分析        class
="org.jasig.services.persondir.support.StubPersonAttributeDao">
单点登录JA-SIG研究分析        
<property name="backingMap">
单点登录JA-SIG研究分析            
<map>
单点登录JA-SIG研究分析                
<entry key="uid" value="uid" />
单点登录JA-SIG研究分析                
<entry key="eduPersonAffiliation"
单点登录JA-SIG研究分析                    value
="eduPersonAffiliation" />
单点登录JA-SIG研究分析                
<entry key="groupMembership" value="groupMembership" />
单点登录JA-SIG研究分析            
</map>
单点登录JA-SIG研究分析        
</property>
单点登录JA-SIG研究分析    
</bean>

    例如:从LDAP中读取属性

单点登录JA-SIG研究分析<bean id="attributeRepository"
单点登录JA-SIG研究分析        class
="com.jihong.services.persondir.support.ldap.LdapPersonAttributeDao">
单点登录JA-SIG研究分析        
<property name="baseDN" value="OU=单位,O=TJJU" />
单点登录JA-SIG研究分析        
<property name="query" value="(uid={0})" />
单点登录JA-SIG研究分析        
<property name="contextSource" ref="contextSource" />
单点登录JA-SIG研究分析        
<property name="ldapAttributesToPortalAttributes">
单点登录JA-SIG研究分析            
<map>
单点登录JA-SIG研究分析                
<entry key="cn" value="Name" />
单点登录JA-SIG研究分析                
<entry value="Telephone" key="telephoneNumber" />
单点登录JA-SIG研究分析                
<entry value="Full Name" key="fullName" />
单点登录JA-SIG研究分析                
<entry value="Email" key="mail" />
单点登录JA-SIG研究分析                
<entry key="eduPersonAffiliation"
单点登录JA-SIG研究分析                    value
="eduPersonAffiliation" />
单点登录JA-SIG研究分析                
<entry key="groupMembership" value="groupMembership" />
单点登录JA-SIG研究分析            
</map>
单点登录JA-SIG研究分析        
</property>
单点登录JA-SIG研究分析    
</bean>



转自:http://www.cnblogs.com/huangzhex/archive/2008/05/12/1193750.html