@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | assert('is_string($id)'); |
| 191 | 191 | |
| 192 | 192 | $this->id = $id; |
| 193 | - $this->logLoc = 'aggregator2:'.$this->id.': '; |
|
| 193 | + $this->logLoc = 'aggregator2:' . $this->id . ': '; |
|
| 194 | 194 | |
| 195 | 195 | $this->cronTag = $config->getString('cron.tag', null); |
| 196 | 196 | |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | $signKey = System::resolvePath($signKey, $certDir); |
| 222 | 222 | $this->signKey = @file_get_contents($signKey); |
| 223 | 223 | if ($this->signKey === null) { |
| 224 | - throw new Exception('Unable to load private key from '.var_export($signKey, true)); |
|
| 224 | + throw new Exception('Unable to load private key from ' . var_export($signKey, true)); |
|
| 225 | 225 | } |
| 226 | 226 | } |
| 227 | 227 | |
@@ -232,13 +232,13 @@ discard block |
||
| 232 | 232 | $signCert = System::resolvePath($signCert, $certDir); |
| 233 | 233 | $this->signCert = @file_get_contents($signCert); |
| 234 | 234 | if ($this->signCert === null) { |
| 235 | - throw new Exception('Unable to load certificate file from '.var_export($signCert, true)); |
|
| 235 | + throw new Exception('Unable to load certificate file from ' . var_export($signCert, true)); |
|
| 236 | 236 | } |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | $this->signAlg = $config->getString('sign.algorithm', XMLSecurityKey::RSA_SHA1); |
| 240 | 240 | if (!in_array($this->signAlg, self::$SUPPORTED_SIGNATURE_ALGORITHMS)) { |
| 241 | - throw new Exception('Unsupported signature algorithm '.var_export($this->signAlg, true)); |
|
| 241 | + throw new Exception('Unsupported signature algorithm ' . var_export($this->signAlg, true)); |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | $this->sslCAFile = $config->getString('ssl.cafile', null); |
@@ -304,24 +304,24 @@ discard block |
||
| 304 | 304 | assert('is_int($expires)'); |
| 305 | 305 | assert('is_null($tag) || is_string($tag)'); |
| 306 | 306 | |
| 307 | - $cacheFile = $this->cacheDirectory.'/'.$id; |
|
| 307 | + $cacheFile = $this->cacheDirectory . '/' . $id; |
|
| 308 | 308 | try { |
| 309 | 309 | System::writeFile($cacheFile, $data); |
| 310 | 310 | } catch (\Exception $e) { |
| 311 | - Logger::warning($this->logLoc.'Unable to write to cache file '.var_export($cacheFile, true)); |
|
| 311 | + Logger::warning($this->logLoc . 'Unable to write to cache file ' . var_export($cacheFile, true)); |
|
| 312 | 312 | return; |
| 313 | 313 | } |
| 314 | 314 | |
| 315 | - $expireInfo = (string)$expires; |
|
| 315 | + $expireInfo = (string) $expires; |
|
| 316 | 316 | if ($tag !== null) { |
| 317 | - $expireInfo .= ':'.$tag; |
|
| 317 | + $expireInfo .= ':' . $tag; |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | - $expireFile = $cacheFile.'.expire'; |
|
| 320 | + $expireFile = $cacheFile . '.expire'; |
|
| 321 | 321 | try { |
| 322 | 322 | System::writeFile($expireFile, $expireInfo); |
| 323 | 323 | } catch (\Exception $e) { |
| 324 | - Logger::warning($this->logLoc.'Unable to write expiration info to '.var_export($expireFile, true)); |
|
| 324 | + Logger::warning($this->logLoc . 'Unable to write expiration info to ' . var_export($expireFile, true)); |
|
| 325 | 325 | } |
| 326 | 326 | } |
| 327 | 327 | |
@@ -338,12 +338,12 @@ discard block |
||
| 338 | 338 | assert('is_string($id)'); |
| 339 | 339 | assert('is_null($tag) || is_string($tag)'); |
| 340 | 340 | |
| 341 | - $cacheFile = $this->cacheDirectory.'/'.$id; |
|
| 341 | + $cacheFile = $this->cacheDirectory . '/' . $id; |
|
| 342 | 342 | if (!file_exists($cacheFile)) { |
| 343 | 343 | return false; |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | - $expireFile = $cacheFile.'.expire'; |
|
| 346 | + $expireFile = $cacheFile . '.expire'; |
|
| 347 | 347 | if (!file_exists($expireFile)) { |
| 348 | 348 | return false; |
| 349 | 349 | } |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | return null; |
| 390 | 390 | } |
| 391 | 391 | |
| 392 | - $cacheFile = $this->cacheDirectory.'/'.$id; |
|
| 392 | + $cacheFile = $this->cacheDirectory . '/' . $id; |
|
| 393 | 393 | return @file_get_contents($cacheFile); |
| 394 | 394 | } |
| 395 | 395 | |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | { |
| 405 | 405 | assert('is_string($id)'); |
| 406 | 406 | |
| 407 | - $cacheFile = $this->cacheDirectory.'/'.$id; |
|
| 407 | + $cacheFile = $this->cacheDirectory . '/' . $id; |
|
| 408 | 408 | if (!file_exists($cacheFile)) { |
| 409 | 409 | return null; |
| 410 | 410 | } |
@@ -616,7 +616,7 @@ discard block |
||
| 616 | 616 | } |
| 617 | 617 | $this->excluded = $entities; |
| 618 | 618 | sort($this->excluded); |
| 619 | - $this->cacheId = sha1($this->cacheId.serialize($this->excluded)); |
|
| 619 | + $this->cacheId = sha1($this->cacheId . serialize($this->excluded)); |
|
| 620 | 620 | } |
| 621 | 621 | |
| 622 | 622 | |
@@ -675,7 +675,7 @@ discard block |
||
| 675 | 675 | $options = ['saml2', 'shib13', 'saml20-aa', 'shib13-aa']; |
| 676 | 676 | $this->roles['SAML2_XML_md_AttributeAuthorityDescriptor'] = (array_intersect($set, $options) !== []); |
| 677 | 677 | |
| 678 | - $this->cacheId = sha1($this->cacheId.serialize($this->protocols).serialize($this->roles)); |
|
| 678 | + $this->cacheId = sha1($this->cacheId . serialize($this->protocols) . serialize($this->roles)); |
|
| 679 | 679 | } |
| 680 | 680 | |
| 681 | 681 | |
@@ -698,7 +698,7 @@ discard block |
||
| 698 | 698 | $xml = $xml->ownerDocument->saveXML($xml); |
| 699 | 699 | |
| 700 | 700 | if ($this->cacheGenerated !== null) { |
| 701 | - Logger::debug($this->logLoc.'Saving generated metadata to cache.'); |
|
| 701 | + Logger::debug($this->logLoc . 'Saving generated metadata to cache.'); |
|
| 702 | 702 | $this->addCacheItem($this->cacheId, $xml, time() + $this->cacheGenerated, $this->cacheTag); |
| 703 | 703 | } |
| 704 | 704 | |
@@ -716,7 +716,7 @@ discard block |
||
| 716 | 716 | if ($this->cacheGenerated !== null) { |
| 717 | 717 | $xml = $this->getCacheItem($this->cacheId, $this->cacheTag); |
| 718 | 718 | if ($xml !== null) { |
| 719 | - Logger::debug($this->logLoc.'Loaded generated metadata from cache.'); |
|
| 719 | + Logger::debug($this->logLoc . 'Loaded generated metadata from cache.'); |
|
| 720 | 720 | return $xml; |
| 721 | 721 | } |
| 722 | 722 | } |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | |
| 7 | 7 | <?php |
| 8 | 8 | if (count($this->data['sources']) === 0) { |
| 9 | - echo " <p>".$this->t('{aggregator2:aggregator:no_aggregators}')."</p>\n"; |
|
| 9 | + echo " <p>" . $this->t('{aggregator2:aggregator:no_aggregators}') . "</p>\n"; |
|
| 10 | 10 | } else { |
| 11 | 11 | echo " <ul>"; |
| 12 | 12 | |
@@ -15,17 +15,17 @@ discard block |
||
| 15 | 15 | $params = [ |
| 16 | 16 | 'id' => $encId, |
| 17 | 17 | ]; |
| 18 | - echo str_repeat(' ', 8)."<li>\n"; |
|
| 19 | - echo str_repeat(' ', 12).'<a href="'; |
|
| 20 | - echo SimpleSAML\Module::getModuleURL('aggregator2/get.php', $params).'">'.htmlspecialchars($id)."</a>\n"; |
|
| 21 | - echo str_repeat(' ', 12).'<a href="'; |
|
| 18 | + echo str_repeat(' ', 8) . "<li>\n"; |
|
| 19 | + echo str_repeat(' ', 12) . '<a href="'; |
|
| 20 | + echo SimpleSAML\Module::getModuleURL('aggregator2/get.php', $params) . '">' . htmlspecialchars($id) . "</a>\n"; |
|
| 21 | + echo str_repeat(' ', 12) . '<a href="'; |
|
| 22 | 22 | $params['mimetype'] = 'text/plain'; |
| 23 | - echo SimpleSAML\Module::getModuleURL('aggregator2/get.php', $params).'">['. |
|
| 24 | - $this->t('{aggregator2:aggregator:text}')."]</a>\n"; |
|
| 25 | - echo str_repeat(' ', 12).'<a href="'; |
|
| 23 | + echo SimpleSAML\Module::getModuleURL('aggregator2/get.php', $params) . '">[' . |
|
| 24 | + $this->t('{aggregator2:aggregator:text}') . "]</a>\n"; |
|
| 25 | + echo str_repeat(' ', 12) . '<a href="'; |
|
| 26 | 26 | $params['mimetype'] = 'application/xml'; |
| 27 | - echo SimpleSAML\Module::getModuleURL('aggregator2/get.php', $params)."\">[XML]</a>\n"; |
|
| 28 | - echo str_repeat(' ', 8)."</li>\n"; |
|
| 27 | + echo SimpleSAML\Module::getModuleURL('aggregator2/get.php', $params) . "\">[XML]</a>\n"; |
|
| 28 | + echo str_repeat(' ', 8) . "</li>\n"; |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | echo " </ul>\n"; |
@@ -1,10 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | $projectRoot = dirname(__DIR__); |
| 4 | -require_once($projectRoot.'/vendor/autoload.php'); |
|
| 4 | +require_once($projectRoot . '/vendor/autoload.php'); |
|
| 5 | 5 | |
| 6 | 6 | // Symlink module into ssp vendor lib so that templates and urls can resolve correctly |
| 7 | -$linkPath = $projectRoot.'/vendor/simplesamlphp/simplesamlphp/modules/aggregator2'; |
|
| 7 | +$linkPath = $projectRoot . '/vendor/simplesamlphp/simplesamlphp/modules/aggregator2'; |
|
| 8 | 8 | if (file_exists($linkPath) === false) { |
| 9 | 9 | echo "Linking '$linkPath' to '$projectRoot'\n"; |
| 10 | 10 | symlink($projectRoot, $linkPath); |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | public function __construct(Aggregator $aggregator, Configuration $config) |
| 94 | 94 | { |
| 95 | - $this->logLoc = 'aggregator2:'.$aggregator->getId().': '; |
|
| 95 | + $this->logLoc = 'aggregator2:' . $aggregator->getId() . ': '; |
|
| 96 | 96 | $this->aggregator = $aggregator; |
| 97 | 97 | |
| 98 | 98 | $this->url = $config->getString('url'); |
@@ -116,12 +116,12 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | private function downloadMetadata() |
| 118 | 118 | { |
| 119 | - Logger::debug($this->logLoc.'Downloading metadata from '.var_export($this->url, true)); |
|
| 119 | + Logger::debug($this->logLoc . 'Downloading metadata from ' . var_export($this->url, true)); |
|
| 120 | 120 | |
| 121 | 121 | $context = ['ssl' => []]; |
| 122 | 122 | if ($this->sslCAFile !== null) { |
| 123 | 123 | $context['ssl']['cafile'] = Config::getCertPath($this->sslCAFile); |
| 124 | - Logger::debug($this->logLoc.'Validating https connection against CA certificate(s) found in '. |
|
| 124 | + Logger::debug($this->logLoc . 'Validating https connection against CA certificate(s) found in ' . |
|
| 125 | 125 | var_export($context['ssl']['cafile'], true)); |
| 126 | 126 | $context['ssl']['verify_peer'] = true; |
| 127 | 127 | $context['ssl']['CN_match'] = parse_url($this->url, PHP_URL_HOST); |
@@ -129,26 +129,26 @@ discard block |
||
| 129 | 129 | |
| 130 | 130 | $data = HTTP::fetch($this->url, $context); |
| 131 | 131 | if ($data === false || $data === null) { |
| 132 | - Logger::error($this->logLoc.'Unable to load metadata from '.var_export($this->url, true)); |
|
| 132 | + Logger::error($this->logLoc . 'Unable to load metadata from ' . var_export($this->url, true)); |
|
| 133 | 133 | return null; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | $doc = new \DOMDocument(); |
| 137 | 137 | $res = $doc->loadXML($data); |
| 138 | 138 | if (!$res) { |
| 139 | - Logger::error($this->logLoc.'Error parsing XML from '.var_export($this->url, true)); |
|
| 139 | + Logger::error($this->logLoc . 'Error parsing XML from ' . var_export($this->url, true)); |
|
| 140 | 140 | return null; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | $root = Utils::xpQuery($doc->firstChild, '/saml_metadata:EntityDescriptor|/saml_metadata:EntitiesDescriptor'); |
| 144 | 144 | if (count($root) === 0) { |
| 145 | - Logger::error($this->logLoc.'No <EntityDescriptor> or <EntitiesDescriptor> in metadata from '. |
|
| 145 | + Logger::error($this->logLoc . 'No <EntityDescriptor> or <EntitiesDescriptor> in metadata from ' . |
|
| 146 | 146 | var_export($this->url, true)); |
| 147 | 147 | return null; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | if (count($root) > 1) { |
| 151 | - Logger::error($this->logLoc.'More than one <EntityDescriptor> or <EntitiesDescriptor> in metadata from '. |
|
| 151 | + Logger::error($this->logLoc . 'More than one <EntityDescriptor> or <EntitiesDescriptor> in metadata from ' . |
|
| 152 | 152 | var_export($this->url, true)); |
| 153 | 153 | return null; |
| 154 | 154 | } |
@@ -161,8 +161,8 @@ discard block |
||
| 161 | 161 | $md = new EntitiesDescriptor($root); |
| 162 | 162 | } |
| 163 | 163 | } catch (\Exception $e) { |
| 164 | - Logger::error($this->logLoc.'Unable to parse metadata from '. |
|
| 165 | - var_export($this->url, true).': '.$e->getMessage()); |
|
| 164 | + Logger::error($this->logLoc . 'Unable to parse metadata from ' . |
|
| 165 | + var_export($this->url, true) . ': ' . $e->getMessage()); |
|
| 166 | 166 | return null; |
| 167 | 167 | } |
| 168 | 168 | |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | $file = Config::getCertPath($this->certificate); |
| 171 | 171 | $certData = file_get_contents($file); |
| 172 | 172 | if ($certData === false) { |
| 173 | - throw new Exception('Error loading certificate from '.var_export($file, true)); |
|
| 173 | + throw new Exception('Error loading certificate from ' . var_export($file, true)); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | // Extract the public key from the certificate for validation |
@@ -178,10 +178,10 @@ discard block |
||
| 178 | 178 | $key->loadKey($file, true); |
| 179 | 179 | |
| 180 | 180 | if (!$md->validate($key)) { |
| 181 | - Logger::error($this->logLoc.'Error validating signature on metadata.'); |
|
| 181 | + Logger::error($this->logLoc . 'Error validating signature on metadata.'); |
|
| 182 | 182 | return null; |
| 183 | 183 | } |
| 184 | - Logger::debug($this->logLoc.'Validated signature on metadata from '.var_export($this->url, true)); |
|
| 184 | + Logger::debug($this->logLoc . 'Validated signature on metadata from ' . var_export($this->url, true)); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | return $md; |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | return null; |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - Logger::debug($this->logLoc.'Using cached metadata from '.var_export($cacheFile, true)); |
|
| 247 | + Logger::debug($this->logLoc . 'Using cached metadata from ' . var_export($cacheFile, true)); |
|
| 248 | 248 | |
| 249 | 249 | $metadata = file_get_contents($cacheFile); |
| 250 | 250 | if ($metadata !== null) { |
@@ -35,13 +35,13 @@ |
||
| 35 | 35 | $xml = \SimpleSAML\Utils\XML::formatXMLString($xml); |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | -header('Content-Type: '.$mimetype); |
|
| 38 | +header('Content-Type: ' . $mimetype); |
|
| 39 | 39 | header('Content-Length: ' . strlen($xml)); |
| 40 | 40 | |
| 41 | 41 | /* |
| 42 | 42 | * At this point, if the ID was forged, getMetadata() would |
| 43 | 43 | * have failed to find a valid metadata set, so we can trust it. |
| 44 | 44 | */ |
| 45 | -header('Content-Disposition: filename='.$id.'.xml'); |
|
| 45 | +header('Content-Disposition: filename=' . $id . '.xml'); |
|
| 46 | 46 | |
| 47 | 47 | echo $xml; |