Skip to content
Snippets Groups Projects
Commit 8276751e authored by Tim van Dijen's avatar Tim van Dijen
Browse files

Fixes for modules/metarefresh

parent 80d770ba
No related branches found
No related tags found
No related merge requests found
...@@ -145,6 +145,7 @@ if ($toStdOut) { ...@@ -145,6 +145,7 @@ if ($toStdOut) {
/** /**
* This function prints the help output. * This function prints the help output.
* @return void
*/ */
function printHelp() function printHelp()
{ {
......
...@@ -6,6 +6,7 @@ use \SimpleSAML\Logger; ...@@ -6,6 +6,7 @@ use \SimpleSAML\Logger;
* Hook to run a cron job. * Hook to run a cron job.
* *
* @param array &$croninfo Output * @param array &$croninfo Output
* @return void
*/ */
function metarefresh_hook_cron(&$croninfo) function metarefresh_hook_cron(&$croninfo)
{ {
......
<?php <?php
/** /**
* Hook to add links to the frontpage. * Hook to add links to the frontpage.
* *
* @param array &$links The links on the frontpage, split into sections. * @param array &$links The links on the frontpage, split into sections.
* @return void
*/ */
function metarefresh_hook_frontpage(&$links) function metarefresh_hook_frontpage(&$links)
{ {
assert(is_array($links)); assert(is_array($links));
......
...@@ -6,7 +6,6 @@ namespace SimpleSAML\Module\metarefresh; ...@@ -6,7 +6,6 @@ namespace SimpleSAML\Module\metarefresh;
* @author Andreas Åkre Solberg <andreas.solberg@uninett.no> * @author Andreas Åkre Solberg <andreas.solberg@uninett.no>
* @package SimpleSAMLphp * @package SimpleSAMLphp
*/ */
class ARP class ARP
{ {
/** /**
...@@ -17,7 +16,7 @@ class ARP ...@@ -17,7 +16,7 @@ class ARP
/** /**
* @var array * @var array
*/ */
private $attributes; private $attributes = [];
/** /**
* @var string * @var string
......
...@@ -8,15 +8,27 @@ use SimpleSAML\Logger; ...@@ -8,15 +8,27 @@ use SimpleSAML\Logger;
* @package SimpleSAMLphp * @package SimpleSAMLphp
* @author Andreas Åkre Solberg <andreas.solberg@uninett.no> * @author Andreas Åkre Solberg <andreas.solberg@uninett.no>
*/ */
class MetaLoader class MetaLoader
{ {
/** @var int|null */
private $expire; private $expire;
private $metadata;
/** @var array */
private $metadata = [];
/** @var object|null */
private $oldMetadataSrc; private $oldMetadataSrc;
/** @var string|null */
private $stateFile; private $stateFile;
private $changed;
private $state; /** @var bool*/
private $changed = false;
/** @var array */
private $state = [];
/** @var array */
private $types = [ private $types = [
'saml20-idp-remote', 'saml20-idp-remote',
'saml20-sp-remote', 'saml20-sp-remote',
...@@ -25,29 +37,27 @@ class MetaLoader ...@@ -25,29 +37,27 @@ class MetaLoader
'attributeauthority-remote' 'attributeauthority-remote'
]; ];
/** /**
* Constructor * Constructor
* *
* @param integer $expire * @param int|null $expire
* @param string $stateFile * @param string|null $stateFile
* @param object $oldMetadataSrc * @param object|null $oldMetadataSrc
*/ */
public function __construct($expire = null, $stateFile = null, $oldMetadataSrc = null) public function __construct($expire = null, $stateFile = null, $oldMetadataSrc = null)
{ {
$this->expire = $expire; $this->expire = $expire;
$this->metadata = [];
$this->oldMetadataSrc = $oldMetadataSrc; $this->oldMetadataSrc = $oldMetadataSrc;
$this->stateFile = $stateFile; $this->stateFile = $stateFile;
$this->changed = false;
// Read file containing $state from disk // Read file containing $state from disk
if (is_readable($stateFile)) { if (is_readable($stateFile)) {
include $stateFile; include $stateFile;
} }
$this->state = [];
} }
/** /**
* Get the types of entities that will be loaded. * Get the types of entities that will be loaded.
* *
...@@ -58,11 +68,13 @@ class MetaLoader ...@@ -58,11 +68,13 @@ class MetaLoader
return $this->types; return $this->types;
} }
/** /**
* Set the types of entities that will be loaded. * Set the types of entities that will be loaded.
* *
* @param string|array $types Either a string with the name of one single type allowed, or an array with a list of * @param string|array $types Either a string with the name of one single type allowed, or an array with a list of
* types. Pass an empty array to reset to all types of entities. * types. Pass an empty array to reset to all types of entities.
* @return void
*/ */
public function setTypes($types) public function setTypes($types)
{ {
...@@ -72,10 +84,12 @@ class MetaLoader ...@@ -72,10 +84,12 @@ class MetaLoader
$this->types = $types; $this->types = $types;
} }
/** /**
* This function processes a SAML metadata file. * This function processes a SAML metadata file.
* *
* @param $source * @param $source array
* @return void
*/ */
public function loadSource($source) public function loadSource($source)
{ {
...@@ -198,8 +212,12 @@ class MetaLoader ...@@ -198,8 +212,12 @@ class MetaLoader
$this->saveState($source, $responseHeaders); $this->saveState($source, $responseHeaders);
} }
/** /**
* Create HTTP context, with any available caches taken into account * Create HTTP context, with any available caches taken into account
*
* @param array $source
* @return array
*/ */
private function createContext($source) private function createContext($source)
{ {
...@@ -227,6 +245,10 @@ class MetaLoader ...@@ -227,6 +245,10 @@ class MetaLoader
} }
/**
* @param array $source
* @return void
*/
private function addCachedMetadata($source) private function addCachedMetadata($source)
{ {
if (isset($this->oldMetadataSrc)) { if (isset($this->oldMetadataSrc)) {
...@@ -245,6 +267,10 @@ class MetaLoader ...@@ -245,6 +267,10 @@ class MetaLoader
/** /**
* Store caching state data for a source * Store caching state data for a source
*
* @param array $source
* @param array $responseHeaders
* @return void
*/ */
private function saveState($source, $responseHeaders) private function saveState($source, $responseHeaders)
{ {
...@@ -268,8 +294,14 @@ class MetaLoader ...@@ -268,8 +294,14 @@ class MetaLoader
} }
} }
/** /**
* Parse XML metadata and return entities * Parse XML metadata and return entities
*
* @param string $data
* @param array $source
* @return \SimpleSAML\Metadata\SAMLParser[]
* @throws \Exception
*/ */
private function loadXML($data, $source) private function loadXML($data, $source)
{ {
...@@ -287,6 +319,8 @@ class MetaLoader ...@@ -287,6 +319,8 @@ class MetaLoader
/** /**
* This function writes the state array back to disk * This function writes the state array back to disk
*
* @return void
*/ */
public function writeState() public function writeState()
{ {
...@@ -305,6 +339,8 @@ class MetaLoader ...@@ -305,6 +339,8 @@ class MetaLoader
/** /**
* This function writes the metadata to stdout. * This function writes the metadata to stdout.
*
* @return void
*/ */
public function dumpMetadataStdOut() public function dumpMetadataStdOut()
{ {
...@@ -332,8 +368,10 @@ class MetaLoader ...@@ -332,8 +368,10 @@ class MetaLoader
* This function will return without making any changes if $metadata is NULL. * This function will return without making any changes if $metadata is NULL.
* *
* @param string $filename The filename the metadata comes from. * @param string $filename The filename the metadata comes from.
* @param array $metadata The metadata. * @param array $metadata The metadata.
* @param string $type The metadata type. * @param string $type The metadata type.
* @param array|null $template The template.
* @return void
*/ */
private function addMetadata($filename, $metadata, $type, $template = null) private function addMetadata($filename, $metadata, $type, $template = null)
{ {
...@@ -370,6 +408,9 @@ class MetaLoader ...@@ -370,6 +408,9 @@ class MetaLoader
/** /**
* This function writes the metadata to an ARP file * This function writes the metadata to an ARP file
*
* @param \SimpleSAML\Configuration $config
* @return void
*/ */
public function writeARPfile($config) public function writeARPfile($config)
{ {
...@@ -404,6 +445,9 @@ class MetaLoader ...@@ -404,6 +445,9 @@ class MetaLoader
/** /**
* This function writes the metadata to to separate files in the output directory. * This function writes the metadata to to separate files in the output directory.
*
* @param string $outputDir
* @return void
*/ */
public function writeMetadataFiles($outputDir) public function writeMetadataFiles($outputDir)
{ {
...@@ -453,6 +497,7 @@ class MetaLoader ...@@ -453,6 +497,7 @@ class MetaLoader
* Save metadata for loading with the 'serialize' metadata loader. * Save metadata for loading with the 'serialize' metadata loader.
* *
* @param string $outputDir The directory we should save the metadata to. * @param string $outputDir The directory we should save the metadata to.
* @return void
*/ */
public function writeMetadataSerialize($outputDir) public function writeMetadataSerialize($outputDir)
{ {
...@@ -499,6 +544,9 @@ class MetaLoader ...@@ -499,6 +544,9 @@ class MetaLoader
} }
/**
* @return string
*/
private function getTime() private function getTime()
{ {
// The current date, as a string // The current date, as a string
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment