5 * Response callbacks for the CAS Server module.
9 * Returns a CAS 2.0 service response for a validation success.
12 * An associative array containing the keys:
13 * - 'name': CAS username.
14 * - 'attributes': (optional) CAS attributes.
16 function theme_cas_service_validate_success($variables) {
17 $cas_name = $variables['name'];
18 $output = "<cas:serviceResponse xmlns:cas='http://www.yale.edu/tp/cas'>\n";
19 $output .= "<cas:authenticationSuccess>\n";
20 $output .= "<cas:user>$cas_name</cas:user>\n";
21 $output .= theme('cas_service_validate_attributes', $variables);
22 $output .= "</cas:authenticationSuccess>\n";
23 $output .= "</cas:serviceResponse>\n";
29 * Returns CAS attributes as part of a CAS 2.0 service response.
32 * An associative array containing the keys 'attributes' and 'style', where
33 * the value of 'style' must be one of:
38 function theme_cas_service_validate_attributes($variables) {
39 $attributes = $variables['attributes'];
40 $style = $variables['style'];
46 $output .= "<cas:attributes>\n";
47 $output .= "<cas:attraStyle>Jasig</cas:attraStyle>\n";
48 foreach ($attributes as $name => $values) {
49 foreach ((array) $values as $value) {
50 $output .= strtr("<cas:!name>!value</cas:!name>\n", array('!name' => $name, '!value' => $value));
53 $output .= "</cas:attributes>\n";
56 $output .= "<cas:attraStyle>RubyCAS</cas:attraStyle>\n";
57 foreach ($attributes as $name => $values) {
58 foreach ((array) $values as $value) {
59 $output .= strtr("<cas:!name>!value</cas:!name>\n", array('!name' => $name, '!value' => $value));
64 $output .= "<cas:attribute name='attraStyle' value='Name-Value' />\n";
65 foreach ($attributes as $name => $values) {
66 foreach ((array) $values as $value) {
67 $output .= strtr("<cas:attribute name='!name' value='!value' />\n", array('!name' => $name, '!value' => $value));
78 * Returns a CAS 2.0 service response for a validation failure.
81 * An associative array containing the keys 'ticket' and 'error_code'.
83 function theme_cas_service_validate_failure($variables) {
84 $ticket = $variables['ticket'];
85 $error_code = $variables['error_code'];
86 $output = "<cas:serviceResponse xmlns:cas='http://www.yale.edu/tp/cas'>\n";
87 $output .= "<cas:authenticationFailure code=\"$error_code\">\n";
88 $output .= "Ticket $ticket not recognized.\n";
89 $output .= "</cas:authenticationFailure>\n";
90 $output .= "</cas:serviceResponse>\n";
97 * Returns a CAS 2.0 service response for a service not on the whitelist.
100 * An associative array containing the keys 'service' and 'error_code'.
102 function theme_cas_service_validate_whitelist_failure($variables) {
103 $service = $variables['service'];
104 $error_code = $variables['error_code'];
105 $output = "<cas:serviceReponse xmlns:cas='http://www.yale.edu/tp/cas'>\n" .
106 "<cas:authenticationFailure code=\"$error_code\">\n" .
107 "Service $service not recognized.\n" .
108 "</cas:authenticationFailure>\n" .
109 "</cas:serviceResponse>\n";
115 * Generate the Single Sign Out request.
117 * @param unknown_type $variables
118 * An associative array containing the key, date and logout id request
120 function theme_cas_service_logout_request($variables) {
121 $id = $variables['id'];
122 $date = $variables['date'];
123 $ticket = $variables['ticket'];
124 $output = "<samlp:LogoutRequest xmlns:samlp='urn:oasis:names:tc:SAML:2.0:protocol' ID='$id' Version='2.0' IssueInstant='$date'>\n";
125 $output .= "<saml:NameID xmlns:saml='urn:oasis:names:tc:SAML:2.0:assertion'>@NOT_USED@</saml:NameID>\n";
126 $output .= "<samlp:SessionIndex>$ticket</samlp:SessionIndex>\n";
127 $output .= "</samlp:LogoutRequest>\n";