cas 4.0 返回更多信息

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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值