您的位置:首页 > 其它

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: