cas 4.0 返回更多信息
2017-12-18 14:43
274 查看
1.修改WEB-INF下的deployerConfigContext.xml
<bean id="attributeRepository" class="org.jasig.services.persondir.support.StubPersonAttributeDao" p:backingMap-ref="attrRepoBackingMap" /> <util:map id="attrRepoBackingMap"> <entry key="uid" value="uid" /> <entry key="eduPersonAffiliation" value="eduPersonAffiliation" /> <entry key="groupMembership" value="groupMembership" /></util:map>替换为<bean class="org.jasig.services.persondir.support.jdbc.SingleRowJdbcPersonAttributeDao" id="attributeRepository" > <constructor-arg index="0" ref="dataSource"/> <constructor-arg index="1" value="SELECT id AS suid,`name`,mobile,mail FROM ebiz_mng_user where {0}"/> <property name="queryAttributeMapping"> <map> <!--这里的key需写username和登录页面一致,value对应数据库用户名字段--> <entry key="username" value="user_name"/> </map> </property> <property name="resultAttributeMapping"> <map> <!--key为对应的数据库字段名称,value为提供给客户端获取的属性名字,系统会自动填充值--> <entry key="suid" value="suid"/><entry key="name" value="name"/><entry key="mobile" value="mobile"/><entry key="mail" value="mail"/> </map> </property> </bean>修改: <bean class="org.jasig.cas.services.RegexRegisteredService" p:id="0" p:name="HTTP and IMAP" p:description="Allows HTTP(S) and IMAP(S) protocols" p:serviceId="^(https?|imaps?)://.*" p:evaluationOrder="10000001"/>--》<bean class="org.jasig.cas.services.RegexRegisteredService" p:id="0" p:name="HTTP and IMAP" p:description="Allows HTTP(S) and IMAP(S) protocols" p:serviceId="^(https?|imaps?)://.*" p:evaluationOrder="10000001"><!--允许放回属性-> <property name="allowedAttributes"> <list> <value>suid</value> <value>name</value> <value>mobile</value> <value>mail</value> </list> </property> </bean>2. 修改WEB-INF\view\jsp\protocol\2.0下的casServiceValidationSuccess.jsp由原来的<cas:serviceResponse xmlns:cas='http://www.yale.edu/tp/cas'><cas:authenticationSuccess><cas:user>${fn:escapeXml(assertion.primaryAuthentication.principal.id)}</cas:user> <c:if test="${not empty pgtIou}"> <cas:proxyGrantingTicket>${pgtIou}</cas:proxyGrantingTicket> </c:if> <c:if test="${fn:length(assertion.chainedAuthentications) > 1}"> <cas:proxies> <c:forEach var="proxy" items="${assertion.chainedAuthentications}" varStatus="loopStatus" begin="0" end="${fn:length(assertion.chainedAuthentications)-2}" step="1"> <cas:proxy>${fn:escapeXml(proxy.principal.id)}</cas:proxy> </c:forEach> </cas:proxies> </c:if></cas:authenticationSuccess></cas:serviceResponse>改为:<cas:serviceResponse xmlns:cas='http://www.yale.edu/tp/cas'><cas:authenticationSuccess><cas:user>${fn:escapeXml(assertion.primaryAuthentication.principal.id)}</cas:user><!--新增--><c:if test="${fn:length(assertion.chainedAuthentications[fn:length(assertion.chainedAuthentications)-1].principal.attributes) > 0}"> <cas:attributes> <c:forEach var="attr" items="${assertion.chainedAuthentications[fn:length(assertion.chainedAuthentications)-1].principal.attributes}"> <cas:${fn:escapeXml(attr.key)}>${fn:escapeXml(attr.value)}</cas:${fn:escapeXml(attr.key)}> </c:forEach> </cas:attributes> </c:if> <c:if test="${not empty pgtIou}"> <cas:proxyGrantingTicket>${pgtIou}</cas:proxyGrantingTicket> </c:if> <c:if test="${fn:length(assertion.chainedAuthentications) > 1}"> <cas:proxies> <c:forEach var="proxy" items="${assertion.chainedAuthentications}" varStatus="loopStatus" begin="0" end="${fn:length(assertion.chainedAuthentications)-2}" step="1"> <cas:proxy>${fn:escapeXml(proxy.principal.id)}</cas:proxy> </c:forEach> </cas:proxies> </c:if></cas:authenticationSuccess></cas:serviceResponse>客服端获取:AttributePrincipal principal = (AttributePrincipal) request.getUserPrincipal();Map attributes = principal.getAttributes();String email = (String)attributes.get("name");
参考文档:https://www.cnblogs.com/secsea/p/5177284.html
相关文章推荐
- CAS SSO 4.0 单点登录返回更多用户信息
- Cas 3.5.2 登录成功后,如何返回用户更多信息?
- CAS SSO 4.0.x 返回更多用户信息
- 【cas】利用Map返回更多信息
- CAS登录成功后返回更多信息
- CAS—登录后返回更多用户信息
- CAS 实现单点登录(SSO)返回更多用户信息(五)
- cas登录成功返回用户更多信息
- cas 服务器端能返回更多的信息
- 单点登录(十七)----cas4.2.x登录mongodb验证方式成功后返回更多信息更多属性到客户端
- cas 4.2.5 返回更多的用户信息
- cas 3.5.2 返回用户更多信息
- 单点登录(十七)----cas4.2.x登录mongodb验证方式成功后返回更多信息更多属性到客户端
- cas 3.5.2 登录成功后,如何返回用户更多信息?
- cas4.0.1返回给客户端登录用户的更多信息
- [置顶] CAS服务端返回更多的用户登录信息
- [原]基于CAS实现单点登录(SSO):登录成功后,cas client如何返回更多用户信息
- cas 3.5.2 登录成功后返回用户更多信息
- Mvc4单点登录之四 配置Cas服务端,返回更多的用户信息!
- cas 服务器端能返回更多的信息