phpCAS  version 1.4.0
Functions
InternalProxied

Functions

 CAS_Client::validateCAS20 (&$validate_url, &$text_response, &$tree_response, $renew=false)
 
 CAS_Client::_xml_to_array ($root, $namespace="cas")
 
 CAS_Client::_parse_json_like_array_value ($json_value)
 
 CAS_Client::_flatten_array ($arr)
 
 CAS_Client::_readExtraAttributesCas20 ($success_elements)
 
 CAS_Client::_addAttributeToArray (array &$attributeArray, $name, $value)
 

Detailed Description

Function Documentation

◆ _addAttributeToArray()

CAS_Client::_addAttributeToArray ( array &  $attributeArray,
  $name,
  $value 
)
private

Add an attribute value to an array of attributes.

Parameters
array&$attributeArrayreference to array
string$namename of attribute
string$valuevalue of attribute
Returns
void

Definition at line 3851 of file Client.php.

◆ _flatten_array()

CAS_Client::_flatten_array (   $arr)
private

This method recursively removes unneccessary hirarchy levels in array-trees. into an array of strings

Parameters
array$arrthe array to flatten e.g.: Array ( [attributes] => Array ( [attribute] => Array ( [0] => Array ( [name] => surname [value] => Smith ) [1] => Array ( [name] => givenName [value] => John ) [2] => Array ( [name] => memberOf [value] => ['CN=Staff,OU=Groups,DC=example,DC=edu', 'CN=Spanish Department,OU=Departments,OU=Groups,DC=example,DC=edu'] ) ) ) )
Returns
array the flattened array e.g.: Array ( [attribute] => Array ( [surname] => Smith [givenName] => John [memberOf] => Array ( [0] => CN=Staff, OU=Groups, DC=example, DC=edu [1] => CN=Spanish Department, OU=Departments, OU=Groups, DC=example, DC=edu ) ) )

Definition at line 3745 of file Client.php.

References CAS_Client\_endsWith(), CAS_Client\_parse_json_like_array_value(), and CAS_Client\_startsWith().

Referenced by CAS_Client\_readExtraAttributesCas20().

◆ _parse_json_like_array_value()

CAS_Client::_parse_json_like_array_value (   $json_value)
private

This method parses a "JSON-like array" of strings into an array of strings

Parameters
string$json_valuethe json-like string: e.g.: ['CN=Staff,OU=Groups,DC=example,DC=edu', 'CN=Spanish Department,OU=Departments,OU=Groups,DC=example,DC=edu']
Returns
array of strings Description e.g.: Array ( [0] => CN=Staff,OU=Groups,DC=example,DC=edu [1] => CN=Spanish Department,OU=Departments,OU=Groups,DC=example,DC=edu )

Definition at line 3676 of file Client.php.

References CAS_Client\_endsWith(), and CAS_Client\_startsWith().

Referenced by CAS_Client\_flatten_array().

◆ _readExtraAttributesCas20()

CAS_Client::_readExtraAttributesCas20 (   $success_elements)
private

This method will parse the DOM and pull out the attributes from the XML payload and put them into an array, then put the array into the session.

Parameters
DOMNodeList$success_elementspayload of the response
Returns
bool true when successfull, halt otherwise by calling CAS_Client::_authError().

Definition at line 3810 of file Client.php.

References CAS_Client\_flatten_array(), CAS_Client\_xml_to_array(), CAS_Client\setAttributes(), phpCAS\trace(), phpCAS\traceBegin(), and phpCAS\traceEnd().

◆ _xml_to_array()

CAS_Client::_xml_to_array (   $root,
  $namespace = "cas" 
)
private

This method recursively parses the attribute XML. It also collapses name-value pairs into a single array entry. It parses all common formats of attributes and well formed XML files.

Parameters
string$rootthe DOM root element to be parsed
string$namespacenamespace of the elements
Returns
an array of the parsed XML elements

Formats tested:

"Jasig Style" Attributes:

<cas:serviceResponse xmlns:cas='http://www.yale.edu/tp/cas'>
    <cas:authenticationSuccess>
        <cas:user>jsmith</cas:user>
        <cas:attributes>
            <cas:attraStyle>RubyCAS</cas:attraStyle>
            <cas:surname>Smith</cas:surname>
            <cas:givenName>John</cas:givenName>
            <cas:memberOf>CN=Staff,OU=Groups,DC=example,DC=edu</cas:memberOf>
            <cas:memberOf>CN=Spanish Department,OU=Departments,OU=Groups,DC=example,DC=edu</cas:memberOf>
        </cas:attributes>
        <cas:proxyGrantingTicket>PGTIOU-84678-8a9d2sfa23casd</cas:proxyGrantingTicket>
    </cas:authenticationSuccess>
</cas:serviceResponse>

"Jasig Style" Attributes (longer version):

<cas:serviceResponse xmlns:cas='http://www.yale.edu/tp/cas'>
    <cas:authenticationSuccess>
        <cas:user>jsmith</cas:user>
        <cas:attributes>
            <cas:attribute>
                <cas:name>surname</cas:name>
                <cas:value>Smith</cas:value>
            </cas:attribute>
            <cas:attribute>
                <cas:name>givenName</cas:name>
                <cas:value>John</cas:value>
            </cas:attribute>
            <cas:attribute>
                <cas:name>memberOf</cas:name>
                <cas:value>['CN=Staff,OU=Groups,DC=example,DC=edu', 'CN=Spanish Department,OU=Departments,OU=Groups,DC=example,DC=edu']</cas:value>
            </cas:attribute>
        </cas:attributes>
        <cas:proxyGrantingTicket>PGTIOU-84678-8a9d2sfa23casd</cas:proxyGrantingTicket>
    </cas:authenticationSuccess>
</cas:serviceResponse>

"RubyCAS Style" attributes

<cas:serviceResponse xmlns:cas='http://www.yale.edu/tp/cas'>
    <cas:authenticationSuccess>
        <cas:user>jsmith</cas:user>

        <cas:attraStyle>RubyCAS</cas:attraStyle>
        <cas:surname>Smith</cas:surname>
        <cas:givenName>John</cas:givenName>
        <cas:memberOf>CN=Staff,OU=Groups,DC=example,DC=edu</cas:memberOf>
        <cas:memberOf>CN=Spanish Department,OU=Departments,OU=Groups,DC=example,DC=edu</cas:memberOf>

        <cas:proxyGrantingTicket>PGTIOU-84678-8a9d2sfa23casd</cas:proxyGrantingTicket>
    </cas:authenticationSuccess>
</cas:serviceResponse>

"Name-Value" attributes.

Attribute format from these mailing list thread: http://jasig.275507.n4.nabble.com/CAS-attributes-and-how-they-appear-in-the-CAS-response-td264272.html Note: This is a less widely used format, but in use by at least two institutions.

<cas:serviceResponse xmlns:cas='http://www.yale.edu/tp/cas'>
    <cas:authenticationSuccess>
        <cas:user>jsmith</cas:user>

        <cas:attribute name='attraStyle' value='Name-Value' />
        <cas:attribute name='surname' value='Smith' />
        <cas:attribute name='givenName' value='John' />
        <cas:attribute name='memberOf' value='CN=Staff,OU=Groups,DC=example,DC=edu' />
        <cas:attribute name='memberOf' value='CN=Spanish Department,OU=Departments,OU=Groups,DC=example,DC=edu' />

        <cas:proxyGrantingTicket>PGTIOU-84678-8a9d2sfa23casd</cas:proxyGrantingTicket>
    </cas:authenticationSuccess>
</cas:serviceResponse>

result:

 Array (
     [surname] => Smith
     [givenName] => John
     [memberOf] => Array (
         [0] => CN=Staff, OU=Groups, DC=example, DC=edu
         [1] => CN=Spanish Department, OU=Departments, OU=Groups, DC=example, DC=edu
     )
 )

Definition at line 3610 of file Client.php.

Referenced by CAS_Client\_readExtraAttributesCas20().

◆ validateCAS20()

CAS_Client::validateCAS20 ( $validate_url,
$text_response,
$tree_response,
  $renew = false 
)

This method is used to validate a cas 2.0 ST or PT; halt on failure Used for all CAS 2.0 validations

Parameters
string&$validate_urlthe url of the reponse
string&$text_responsethe text of the repsones
DOMElement&$tree_responsethe domxml tree of the respones
bool$renewtrue to force the authentication with the CAS server
Returns
bool true when successfull and issue a CAS_AuthenticationException and false on an error
Exceptions
CAS_AuthenticationException

Definition at line 3385 of file Client.php.

References CAS_Client\_getCallbackURL(), CAS_Client\_readURL(), CAS_Client\getAllowedProxyChains(), CAS_Client\getServerProxyValidateURL(), CAS_Client\getServerServiceValidateURL(), CAS_Client\getTicket(), CAS_Client\isProxy(), phpCAS\trace(), and phpCAS\traceBegin().