文档详情

CAS客户端获取更多用户信息.doc

发布:2017-05-24约7.68千字共10页下载文档
文本预览下载声明
CAS客户端获取更多用户信息 总述 首先,我是用的CAS Server版本是3..2,Servlet容器是Tomcat 程序中也可能遇到需要得到更多如姓名,手机号,email等更多用户信息的情况。 cas各种版本配置方式也不尽相同,这里讲的是3..2版本。 此文章中 CAS 基础环境: cas-server-3.5.2 CAS客户端:cas-client-3.2.1 第一种方式 服务器端配置 ? 一、首先需要配置属性attributeRepository 首先,你需要到WEB-INF目录找到? deployerConfigContext.xml文件,同时配置 attributeRepository 如下:? bean??class=org.jasig.services.persondir.support.jdbc.SingleRowJdbcPersonAttributeDao id=attributeRepository ????????constructor-arg index=0 ref=dataSource/ ????????constructor-arg index=1 value=select * from lead_system_user where {0}/ ????????property name=queryAttributeMapping ????????????map ????????????????entry key=username value=login_name/?? // 这里的key需写username,value对应数据库用户名字段 ????????????/map ????????/property ????????property name=resultAttributeMapping ????????????map ????????????????entry key=user_name value=user_name/ ????????????????entry key=user_mobile value=user_mobile/ ????????????????entry key=user_email value=user_email/ ????????????/map ????????/property ????/bean 其中: queryAttributeMapping 是组装sql用的查询条件属性,上述配置后,结合封装成查询sql就是?select * from where login_name=#username# resultAttributeMapping 是sql执行完毕后返回的结构属性,?key对应数据库字段,value对应客户端获取参数。 ?? 二、配置用户认证凭据转化的解析器 也是在 deployerConfigContext.xml 中,找到 credentialsToPrincipalResolvers,为 UsernamePasswordCredentialsToPrincipalResolver 注入 attributeRepository,那么 attributeRepository 就会被触发并通过此类进行解析,红色为新添部分。 property name=credentialsToPrincipalResolvers ????????????list???????? ????????????????bean class=org.jasig.cas.authentication.principal.UsernamePasswordCredentialsToPrincipalResolver ????????????????????property name=attributeRepository ref=attributeRepository/ ????????????????/bean ????????????????bean class=org.jasig.cas.authentication.principal.HttpBasedServiceCredentialsToPrincipalResolver/ ????????????/list ?/property 三、registeredServices 修改?deployerConfigContext.xml 中的?org.jasig.cas.services.InMemoryServiceRegistryDaoImpl 的属性?registeredServices 修改?registeredServices??列表中的每个协议中的 allowedAttributes 属性的值。列出的每个
显示全部
相似文档