2012-10-21 79 views
1

我有CAS 3.5服務器,並根據此鏈接已修改deployerConfigContext.xml和casServiceValidationSuccess.jsp =>LINK。在CAS調試日誌中,我可以看到附加屬性映射正在創建,並且屬性值也被記錄。CAS 3.5不返回附加屬性

2012-10-21 18:29:34,556 DEBUG [org.jasig.cas.adaptors.ldap.FastBindLdapAuthenticationHandler] - <Performing LDAP bind with credential: [email protected],CN=Users,DC=mygroup,DC=local> 
2012-10-21 18:29:34,557 INFO [org.jasig.cas.authentication.AuthenticationManagerImpl] - <org.jasig.cas.adaptors.ldap.FastBindLdapAuthenticationHandler successfully authenticated [username: [email protected]]> 
2012-10-21 18:29:34,560 DEBUG [org.jasig.cas.authentication.principal.UsernamePasswordCredentialsToPrincipalResolver] - <Attempting to resolve a principal...> 
2012-10-21 18:29:34,561 DEBUG [org.jasig.cas.authentication.principal.UsernamePasswordCredentialsToPrincipalResolver] - <Creating SimplePrincipal for [[email protected]]> 
2012-10-21 18:29:34,562 DEBUG [org.jasig.services.persondir.support.ldap.LdapPersonAttributeDao] - <Created seed map='{username=[[email protected]]}' for uid='[email protected]'> 
2012-10-21 18:29:34,564 DEBUG [org.jasig.services.persondir.support.ldap.LdapPersonAttributeDao] - <Adding attribute 'cn' with value '[[email protected]]' to query builder 'null'> 
2012-10-21 18:29:34,565 DEBUG [org.jasig.services.persondir.support.ldap.LdapPersonAttributeDao] - <Generated query builder '([email protected])' from query Map {username=[[email protected]]}.> 
2012-10-21 18:29:34,678 INFO [org.jasig.cas.authentication.AuthenticationManagerImpl] - <Resolved principal [email protected]> 
2012-10-21 18:29:34,678 INFO [org.jasig.cas.authentication.AuthenticationManagerImpl] - <Principal found: [email protected]> 
2012-10-21 18:29:34,681 DEBUG [org.jasig.cas.authentication.AuthenticationManagerImpl] - <Attribute map for [email protected]: {[email protected], mem=[CN=WFC,OU=Applications,DC=mygroup,DC=local, CN=User Management,OU=Applications,DC=mygroup,DC=local, CN=Wshop,OU=Applications,DC=mygroup,DC=local], dName=Scott}> 

但是,當我從我的PHP CAS客戶端訪問「attributes」數組時,它返回一個空數組。

<?php print_r(phpCAS::getAttributes());?> 

給出一個空白數組。如果我硬編碼casServiceValidationSuccess.jsp中的任何東西,它會顯示數組中的屬性,但值爲空。

<cas:serviceResponse xmlns:cas='http://www.yale.edu/tp/cas'> 
    <cas:authenticationSuccess> 
    <!-- Begin Ldap Attributes --> 
    <c:if test="${fn:length(assertion.chainedAuthentications) > 0}"> 
    <cas:attributes> 
    <cas:mem>${fn:escapeXml(assertion.chainedAuthentications[fn:length(assertion.chainedAuthentications)-1].principal.attributes.mem)}</cas:mem> 
    </cas:attributes> 
... 
... 

我是否缺少任何東西?

+0

任何想法的人? –

+0

我在某處讀到服務URL(我試圖用CAS保護的URL)必須在SSL上並且應該有有效的證書,只有這樣,CAS纔會在回調響應中返回屬性映射。是這樣嗎? –

回答

0

我在CAS issue 655找到了答案。這是我的casServiceValidationSuccess.jsp結果如下:

<%@ page session="false" %> 
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> 
<cas:serviceResponse xmlns:cas='http://www.yale.edu/tp/cas'> 
    <cas:authenticationSuccess> 
     <cas:user>${fn:escapeXml(assertion.chainedAuthentications[fn:length(assertion.chainedAuthentications)-1].principal.id)}</cas:user> 

    <%-- Added attributes in response--%> 
    <cas:attributes> 
     <c:forEach var="attr" 
       items="${assertion.chainedAuthentications[fn:length(assertion.chainedAuthentications)-1].principal.attributes}" 
       varStatus="loopStatus" begin="0" 
       end="${fn:length(assertion.chainedAuthentications[fn:length(assertion.chainedAuthentications)-1].principal.attributes)-1}" 
       step="1"> 
     <%-- Produce output exactly as CAS client code expects it: <cas:attrName>attrValue</cas:attrName> --%> 
     <cas:${fn:escapeXml(attr.key)}>${fn:escapeXml(attr.value)}</cas:${fn:escapeXml(attr.key)}> 
     </c:forEach> 
    </cas:attributes> 
<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>