casServer3.5.2登录从数据库认证、回到更多用户信息(仅供自己用)

casServer3.5.2登录从数据库认证、返回更多用户信息(仅供自己用)

拷入btp的类、配置文件:

 

1.从数据库进行登录认证

添加cas-server-support-jdbc-3.5.2.jar到lib

修改数据库连接

 

deployerConfigContext.xml

<property name="authenticationHandlers">下,注掉默认认证beanSimpleTestUsernamePasswordAuthenticationHandler,

新建认证bean SearchModeSearchDatabaseAuthenticationHandler,通过数据库指定表名、用户名及密码字段进行认证。

 

//?修改ApplicationContext-db.xml的PropertyPlaceholderConfigurer配置

//?修改propertyFileConfigurer.xml的PropertyPlaceholderConfigurer配置

 

2.返回更多用户信息

重写CredentialsToPrincipalResolver接口的方法,并配置deployerConfigContext.xml:

注掉property credentialsToPrincipalResolvers的list中的UsernamePasswordCredentialsToPrincipalResolver,添加自定义的类;

//?删除serviceRegistryDao下的所有属性,添加的用户属性才会被允许返回到客户端;

修改casServiceValidationSuccess.jsp,将属性循环打印出