19 'attributeauthority-remote' 31 $this->metadata =
array();
34 $this->changed = FALSE;
79 if (preg_match(
'@^https?://@i',
$source[
'src'])) {
91 if(!isset($responseHeaders)) {
96 } elseif(preg_match(
'@^HTTP/1\.[01]\s304\s@', $responseHeaders[0])) {
101 } elseif(!preg_match(
'@^HTTP/1\.[01]\s200\s@', $responseHeaders[0])) {
110 $responseHeaders = NULL;
114 if (isset(
$source[
'conditionalGET']) &&
$source[
'conditionalGET']) {
127 foreach($entities as $entity) {
129 if(isset(
$source[
'blacklist'])) {
130 if(!empty(
$source[
'blacklist']) && in_array($entity->getEntityID(),
$source[
'blacklist'],
true)) {
136 if(isset(
$source[
'whitelist'])) {
137 if(!empty(
$source[
'whitelist']) && !in_array($entity->getEntityID(),
$source[
'whitelist'],
true)) {
143 if(array_key_exists(
'certificates',
$source) &&
$source[
'certificates'] !== NULL) {
144 if(!$entity->validateSignature(
$source[
'certificates'])) {
145 SimpleSAML\Logger::info(
'Skipping "' . $entity->getEntityId() .
'" - could not verify signature using certificate.' .
"\n");
150 if(array_key_exists(
'validateFingerprint',
$source) &&
$source[
'validateFingerprint'] !== NULL) {
151 if(!array_key_exists(
'certificates',
$source) ||
$source[
'certificates'] == NULL) {
152 if(!$entity->validateFingerprint(
$source[
'validateFingerprint'])) {
153 SimpleSAML\Logger::info(
'Skipping "' . $entity->getEntityId() .
'" - could not verify signature using fingerprint.' .
"\n");
168 $attributeAuthorities = $entity->getAttributeAuthorities();
169 if (!empty($attributeAuthorities)) {
185 $name =
$config->getString(
'technicalcontact_name', NULL);
186 $mail =
$config->getString(
'technicalcontact_email', NULL);
188 $rawheader =
"User-Agent: SimpleSAMLphp metarefresh, run by $name <$mail>\r\n";
190 if (isset(
$source[
'conditionalGET']) &&
$source[
'conditionalGET']) {
191 if(array_key_exists(
$source[
'src'], $this->state)) {
193 $sourceState = $this->state[
$source[
'src']];
195 if(isset($sourceState[
'last-modified'])) {
196 $rawheader .=
'If-Modified-Since: ' . $sourceState[
'last-modified'] .
"\r\n";
199 if(isset($sourceState[
'etag'])) {
200 $rawheader .=
'If-None-Match: ' . $sourceState[
'etag'] .
"\r\n";
205 return array(
'http' =>
array(
'header' => $rawheader));
210 if(isset($this->oldMetadataSrc)) {
211 foreach($this->types as
$type) {
212 foreach($this->oldMetadataSrc->getMetadataSet($type) as $entity) {
213 if(array_key_exists(
'metarefresh:src', $entity)) {
214 if($entity[
'metarefresh:src'] ==
$source[
'src']) {
229 if (isset(
$source[
'conditionalGET']) &&
$source[
'conditionalGET']) {
232 $candidates =
array(
'last-modified',
'etag');
234 foreach($candidates as $candidate) {
235 if(array_key_exists($candidate, $responseHeaders)) {
236 $this->state[
$source[
'src']][$candidate] = $responseHeaders[$candidate];
240 if(!empty($this->state[
$source[
'src']])) {
242 $this->state[$source[
'src']][
'requested_at'] = $this->
getTime();
244 $this->changed = TRUE;
260 if ($doc->documentElement === NULL) {
261 throw new Exception(
'Opened file is not an XML document: ' .
$source[
'src']);
276 "<?php\n/* This file was generated by the metarefresh module at ".$this->
getTime() .
".\n".
277 " Do not update it manually as it will get overwritten. */\n".
278 '$state = ' . var_export($this->state, TRUE) .
";\n?>\n",
290 foreach($this->metadata as $category => $elements) {
292 echo(
'/* The following data should be added to metadata/' . $category .
'.php. */' .
"\n");
295 foreach($elements as
$m) {
297 $entityID = $m[
'metadata'][
'entityid'];
300 echo(
'/* The following metadata was generated from ' .
$filename .
' on ' . $this->
getTime() .
'. */' .
"\n");
301 echo(
'$metadata[\'' . addslashes($entityID) .
'\'] =
' . var_export($m['metadata
'], TRUE) . ';
' . "\n"); 320 private function addMetadata($filename, $metadata, $type, $template = NULL) { 322 if($metadata === NULL) { 326 if (isset($template)) { 327 $metadata = array_merge($metadata, $template); 330 $metadata['metarefresh:src
'] = $filename; 331 if(!array_key_exists($type, $this->metadata)) { 332 $this->metadata[$type] = array(); 335 // If expire is defined in constructor... 336 if (!empty($this->expire)) { 338 // If expire is already in metadata 339 if (array_key_exists('expire
', $metadata)) { 341 // Override metadata expire with more restrictive global config- 342 if ($this->expire < $metadata['expire
']) 343 $metadata['expire
'] = $this->expire; 345 // If expire is not already in metadata use global config 347 $metadata['expire
'] = $this->expire; 353 $this->metadata[$type][] = array('filename
' => $filename, 'metadata
' => $metadata); 360 function writeARPfile($config) { 362 assert('is_a(
$config, \
'SimpleSAML_Configuration\')');
364 $arpfile =
$config->getValue(
'arpfile');
368 foreach($this->metadata as $category => $elements) {
369 if (!in_array($category,
$types,
true))
continue;
370 $md = array_merge($md, $elements);
375 $config->getValue(
'attributemap',
''),
376 $config->getValue(
'prefix',
''),
377 $config->getValue(
'suffix',
'')
384 file_put_contents($arpfile, $arpxml);
401 if (
$res === FALSE) {
406 foreach($this->types as
$type) {
410 if(array_key_exists($type, $this->metadata)) {
411 $elements = $this->metadata[
$type];
414 $content =
'<?php' .
"\n" .
'/* This file was generated by the metarefresh module at '. $this->
getTime() .
"\n";
415 $content .=
' Do not update it manually as it will get overwritten' .
"\n" .
'*/' .
"\n";
417 foreach($elements as $m) {
418 $entityID = $m[
'metadata'][
'entityid'];
420 $content .=
'$metadata[\'' . addslashes($entityID) .
'\'] =
' . var_export($m['metadata
'], TRUE) . ';
' . "\n"; 423 $content .= "\n" . '?>
'; 425 SimpleSAML\Utils\System::writeFile($filename, $content, 0644); 426 } elseif(is_file($filename)) { 427 if(unlink($filename)) { 428 SimpleSAML\Logger::debug('Deleting stale metadata
file:
' . $filename); 430 SimpleSAML\Logger::warning('Could not
delete stale metadata
file:
' . $filename); 442 public function writeMetadataSerialize($outputDir) { 445 $metaHandler = new SimpleSAML_Metadata_MetaDataStorageHandlerSerialize(array('directory
' => $outputDir)); 447 /* First we add all the metadata entries to the metadata handler. */ 448 foreach ($this->metadata as $set => $elements) { 449 foreach ($elements as $m) { 450 $entityId = $m['metadata
']['entityid
']; 452 SimpleSAML\Logger::debug('metarefresh: Add metadata entry
' . 453 var_export($entityId, TRUE) . ' in
set ' . var_export($set, TRUE) . '.
'); 454 $metaHandler->saveMetadata($entityId, $set, $m['metadata
']); 458 /* Then we delete old entries which should no longer exist. */ 460 foreach ($metaHandler->getMetadataSets() as $set) { 461 foreach ($metaHandler->getMetadataSet($set) as $entityId => $metadata) { 462 if (!array_key_exists('expire
', $metadata)) { 463 SimpleSAML\Logger::warning('metarefresh: Metadata entry without expire timestamp:
' . var_export($entityId, TRUE) . 464 ' in
set ' . var_export($set, TRUE) . '.
'); 467 if ($metadata['expire
'] > $ct) { 470 SimpleSAML\Logger::debug('metarefresh:
' . $entityId . ' expired
' . date('l jS \of F Y h:i:
s A
', $metadata['expire
']) ); 471 SimpleSAML\Logger::debug('metarefresh: Delete expired metadata entry
' . 472 var_export($entityId, TRUE) . ' in
set ' . var_export($set, TRUE) . '. (
' . ($ct - $metadata['expire
']) . ' sec)
'); 473 $metaHandler->deleteMetadata($entityId, $set); 479 private function getTime() { 480 /* The current date, as a string. */ 481 date_default_timezone_set('UTC
'); 482 $when = date('Y-m-d\\TH:i:
s\\Z
');
static writeFile($filename, $data, $mode=0600)
Atomically write a file.
if(!array_key_exists('stateid', $_REQUEST)) $state
Handle linkback() response from LinkedIn.
foreach($_POST as $key=> $value) $res
Reload workbook from saved file
static fetch($url, $context=array(), $getHeaders=false)
Helper function to retrieve a file or URL with proxy support, also supporting proxy basic authorizati...
Create styles array
The data for the language used.
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.