resolvePath($casconfig->getValue('ticketcache', 'ticketcache'));
$ticketcontent = retrieveTicket($ticket, $path);
$usernamefield = $casconfig->getValue('attrname', 'eduPersonPrincipalName');
$dosendattributes = $casconfig->getValue('attributes', FALSE);
$attributes = $ticketcontent['attributes'];
$pgtiouxml = "";
if ($ticketcontent['service'] == $service
&& $ticketcontent['forceAuthn'] == $forceAuthn
&& array_key_exists($usernamefield, $attributes)
&& $ticketcontent['validbefore'] > time()) {
if (isset($_GET['pgtUrl'])) {
$pgtUrl = $_GET['pgtUrl'];
$pgtiou = str_replace( '_', 'PGTIOU-', SimpleSAML_Utilities::generateID());
$pgt = str_replace( '_', 'PGT-', SimpleSAML_Utilities::generateID());
$content = array(
'attributes' => $attributes,
'forceAuthn' => false,
'proxies' => array_merge(array($service), $ticketcontent['proxies']),
'validbefore' => time() + 60);
SimpleSAML_Utilities::fetch($pgtUrl . '?pgtIou=' . $pgtiou . '&pgtId=' . $pgt);
storeTicket($pgt, $path, $content);
$pgtiouxml = "\n$pgtiou\n";
}
$proxiesxml = join("\n", array_map(create_function('$a', 'return "$a";'), $ticketcontent['proxies']));
if ($proxiesxml) $proxiesxml = "\n$proxiesxml\n\n";
returnResponse('YES', $function, $attributes[$usernamefield][0], $dosendattributes ? $attributes : array(), $pgtiouxml.$proxiesxml);
} else {
returnResponse('NO', $function);
}
} catch (Exception $e) {
returnResponse('NO', $function, $e->getMessage());
}
function returnResponse($value, $function, $usrname = '', $attributes = array(), $xtraxml = "") {
if ($value === 'YES') {
if ($function != 'validate') {
$attributesxml = "";
foreach ($attributes as $attributename => $attributelist) {
$attr = htmlspecialchars($attributename);
foreach ($attributelist as $attributevalue) {
$attributesxml .= "" . htmlspecialchars($attributevalue) . "\n";
}
}
if (sizeof($attributes)) $attributesxml = "\n" . $attributesxml . "\n";
echo '
' . htmlspecialchars($usrname) . '' .
$xtraxml .
$attributesxml .
'
';
} else {
echo 'yes' . "\n" . $usrname;
}
} else {
if ($function != 'validate') {
echo '
';
} else {
echo 'no';
}
}
}
?>