function cas_server_service_validate in CAS 6.3
Same name and namespace in other branches
- 5.4 cas_server.module \cas_server_service_validate()
- 5.3 cas_server.module \cas_server_service_validate()
- 6.2 cas_server.module \cas_server_service_validate()
- 7 cas_server.module \cas_server_service_validate()
serviceValidate method using cas 2.0 Returns data in xml
1 string reference to 'cas_server_service_validate'
- cas_server_menu in ./
cas_server.module - Implementation of hook_menu
File
- ./
cas_server.module, line 162 - Provides a protocol compliant version of CAS server 2.x
Code
function cas_server_service_validate() {
// Prevent this page from being cached.
global $conf;
$conf['cache'] = FALSE;
// Set content type.
drupal_set_header('Content-Type: text/xml; charset=utf-8');
$ticket = isset($_REQUEST['ticket']) ? $_REQUEST['ticket'] : '';
$service = isset($_REQUEST['service']) ? $_REQUEST['service'] : '';
$user_name = _cas_server_validate($service, $ticket);
if (!$user_name) {
$cas_error = 'INVALID_TICKET';
}
if (!$ticket || !$service) {
$cas_error = 'INVALID_REQUEST';
}
if ($user_name) {
//@TODO Generate proxy granting ticket
$account = user_load(array(
'name' => $user_name,
));
// Generate a list of attributes to return.
$attributes = module_invoke_all('cas_server_user_attributes', $account, $service, $ticket);
// Let other modules alter the list of attributes.
$context = array(
'service' => $service,
'ticket' => $ticket,
);
drupal_alter('cas_server_user_attributes', $attributes, $account, $context);
print theme('cas_service_validate_success', $user_name, $attributes);
watchdog('cas', 'User %name CAS sucessully authenticated.', array(
'%name' => $user_name,
));
}
else {
print theme('cas_service_validate_failure', $ticket, $cas_error);
watchdog('cas', 'Ticket %ticket for service %service not recognized.', array(
'%ticket' => $ticket,
'%service' => $service,
));
}
}