@@ -76,7 +76,7 @@ |
||
| 76 | 76 | $required = false; |
| 77 | 77 | } |
| 78 | 78 | $privateKeys = $this->get('privateKeys'); |
| 79 | - $key = array_filter($privateKeys, function (PrivateKey $key) use ($name) { |
|
| 79 | + $key = array_filter($privateKeys, function(PrivateKey $key) use ($name) { |
|
| 80 | 80 | return $key->getName() === $name; |
| 81 | 81 | }); |
| 82 | 82 | |
@@ -63,7 +63,7 @@ |
||
| 63 | 63 | CertificateProvider $configuration |
| 64 | 64 | ) : bool { |
| 65 | 65 | $logger = $this->logger; |
| 66 | - $pemCandidates = $this->configuredKeys->filter(function (Key $key) use ($logger) { |
|
| 66 | + $pemCandidates = $this->configuredKeys->filter(function(Key $key) use ($logger) { |
|
| 67 | 67 | if (!$key instanceof X509) { |
| 68 | 68 | $logger->debug(sprintf('Skipping unknown key type: "%s"', $key['type'])); |
| 69 | 69 | return false; |
@@ -76,7 +76,7 @@ |
||
| 76 | 76 | $required = false; |
| 77 | 77 | } |
| 78 | 78 | $privateKeys = $this->get('privateKeys'); |
| 79 | - $key = array_filter($privateKeys, function (PrivateKey $key) use ($name) { |
|
| 79 | + $key = array_filter($privateKeys, function(PrivateKey $key) use ($name) { |
|
| 80 | 80 | return $key->getName() === $name; |
| 81 | 81 | }); |
| 82 | 82 | |
@@ -47,11 +47,11 @@ discard block |
||
| 47 | 47 | if ($issuer === null) { |
| 48 | 48 | throw new \Exception('Cannot get redirect URL, no Issuer set in the message.'); |
| 49 | 49 | } |
| 50 | - $artifact = base64_encode("\x00\x04\x00\x00".sha1($issuer->getValue(), true).$generatedId); |
|
| 50 | + $artifact = base64_encode("\x00\x04\x00\x00" . sha1($issuer->getValue(), true) . $generatedId); |
|
| 51 | 51 | $artifactData = $message->toUnsignedXML(); |
| 52 | 52 | $artifactDataString = $artifactData->ownerDocument->saveXML($artifactData); |
| 53 | 53 | |
| 54 | - $store->set('artifact', $artifact, $artifactDataString, Temporal::getTime() + 15*60); |
|
| 54 | + $store->set('artifact', $artifact, $artifactDataString, Temporal::getTime() + 15 * 60); |
|
| 55 | 55 | |
| 56 | 56 | $params = [ |
| 57 | 57 | 'SAMLart' => $artifact, |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | $idpMetadata = $metadataHandler->getMetaDataConfigForSha1($sourceId, 'saml20-idp-remote'); |
| 110 | 110 | |
| 111 | 111 | if ($idpMetadata === null) { |
| 112 | - throw new \Exception('No metadata found for remote provider with SHA1 ID: '.var_export($sourceId, true)); |
|
| 112 | + throw new \Exception('No metadata found for remote provider with SHA1 ID: ' . var_export($sourceId, true)); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | $endpoint = null; |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | throw new \Exception('No ArtifactResolutionService with the correct index.'); |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - Utils::getContainer()->getLogger()->debug("ArtifactResolutionService endpoint being used is := ".$endpoint['Location']); |
|
| 127 | + Utils::getContainer()->getLogger()->debug("ArtifactResolutionService endpoint being used is := " . $endpoint['Location']); |
|
| 128 | 128 | |
| 129 | 129 | //Construct the ArtifactResolve Request |
| 130 | 130 | $ar = new ArtifactResolve(); |
@@ -55,21 +55,21 @@ discard block |
||
| 55 | 55 | $msg .= urlencode($msgStr); |
| 56 | 56 | |
| 57 | 57 | if ($relayState !== null) { |
| 58 | - $msg .= '&RelayState='.urlencode($relayState); |
|
| 58 | + $msg .= '&RelayState=' . urlencode($relayState); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | if ($key !== null) { // add the signature |
| 62 | 62 | /** @psalm-suppress PossiblyInvalidArgument */ |
| 63 | - $msg .= '&SigAlg='.urlencode($key->type); |
|
| 63 | + $msg .= '&SigAlg=' . urlencode($key->type); |
|
| 64 | 64 | |
| 65 | 65 | $signature = $key->signData($msg); |
| 66 | - $msg .= '&Signature='.urlencode(base64_encode($signature)); |
|
| 66 | + $msg .= '&Signature=' . urlencode(base64_encode($signature)); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | if (strpos($destination, '?') === false) { |
| 70 | - $destination .= '?'.$msg; |
|
| 70 | + $destination .= '?' . $msg; |
|
| 71 | 71 | } else { |
| 72 | - $destination .= '&'.$msg; |
|
| 72 | + $destination .= '&' . $msg; |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | return $destination; |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | public function send(Message $message) : void |
| 87 | 87 | { |
| 88 | 88 | $destination = $this->getRedirectURL($message); |
| 89 | - Utils::getContainer()->getLogger()->debug('Redirect to '.strlen($destination).' byte URL: '.$destination); |
|
| 89 | + Utils::getContainer()->getLogger()->debug('Redirect to ' . strlen($destination) . ' byte URL: ' . $destination); |
|
| 90 | 90 | Utils::getContainer()->redirect($destination); |
| 91 | 91 | } |
| 92 | 92 | |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | if (isset($data['SAMLEncoding']) && $data['SAMLEncoding'] !== self::DEFLATE) { |
| 116 | - throw new \Exception('Unknown SAMLEncoding: '.var_export($data['SAMLEncoding'], true)); |
|
| 116 | + throw new \Exception('Unknown SAMLEncoding: ' . var_export($data['SAMLEncoding'], true)); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | $message = base64_decode($message); |
@@ -192,18 +192,18 @@ discard block |
||
| 192 | 192 | switch ($name) { |
| 193 | 193 | case 'SAMLRequest': |
| 194 | 194 | case 'SAMLResponse': |
| 195 | - $sigQuery = $name.'='.$value; |
|
| 195 | + $sigQuery = $name . '=' . $value; |
|
| 196 | 196 | break; |
| 197 | 197 | case 'RelayState': |
| 198 | - $relayState = '&RelayState='.$value; |
|
| 198 | + $relayState = '&RelayState=' . $value; |
|
| 199 | 199 | break; |
| 200 | 200 | case 'SigAlg': |
| 201 | - $sigAlg = '&SigAlg='.$value; |
|
| 201 | + $sigAlg = '&SigAlg=' . $value; |
|
| 202 | 202 | break; |
| 203 | 203 | } |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - $data['SignedQuery'] = $sigQuery.$relayState.$sigAlg; |
|
| 206 | + $data['SignedQuery'] = $sigQuery . $relayState . $sigAlg; |
|
| 207 | 207 | |
| 208 | 208 | return $data; |
| 209 | 209 | } |
@@ -81,7 +81,7 @@ |
||
| 81 | 81 | |
| 82 | 82 | throw new MissingConfigurationException(sprintf( |
| 83 | 83 | 'No certificates have been configured%s', |
| 84 | - $configuration->has('entityid') ? ' for "'.$configuration->get('entityid').'"' : '' |
|
| 84 | + $configuration->has('entityid') ? ' for "' . $configuration->get('entityid') . '"' : '' |
|
| 85 | 85 | )); |
| 86 | 86 | } |
| 87 | 87 | } |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | foreach ($namespaces as $prefix => $uri) { |
| 274 | - $newElement->setAttributeNS($uri, $prefix.':__ns_workaround__', 'tmp'); |
|
| 274 | + $newElement->setAttributeNS($uri, $prefix . ':__ns_workaround__', 'tmp'); |
|
| 275 | 275 | $newElement->removeAttributeNS($uri, '__ns_workaround__'); |
| 276 | 276 | } |
| 277 | 277 | |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | case 'true': |
| 302 | 302 | return true; |
| 303 | 303 | default: |
| 304 | - throw new \Exception('Invalid value of boolean attribute '.var_export($attributeName, true).': '. |
|
| 304 | + throw new \Exception('Invalid value of boolean attribute ' . var_export($attributeName, true) . ': ' . |
|
| 305 | 305 | var_export($value, true)); |
| 306 | 306 | } |
| 307 | 307 | } |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | $symKeyInfoAlgo = $symmetricKeyInfo->getAlgorithm(); |
| 390 | 390 | |
| 391 | 391 | if (in_array($symKeyInfoAlgo, $blacklist, true)) { |
| 392 | - throw new \Exception('Algorithm disabled: '.var_export($symKeyInfoAlgo, true)); |
|
| 392 | + throw new \Exception('Algorithm disabled: ' . var_export($symKeyInfoAlgo, true)); |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | if ($symKeyInfoAlgo === XMLSecurityKey::RSA_OAEP_MGF1P && $inputKeyAlgo === XMLSecurityKey::RSA_1_5) { |
@@ -405,9 +405,9 @@ discard block |
||
| 405 | 405 | /* Make sure that the input key format is the same as the one used to encrypt the key. */ |
| 406 | 406 | if ($inputKeyAlgo !== $symKeyInfoAlgo) { |
| 407 | 407 | throw new \Exception( |
| 408 | - 'Algorithm mismatch between input key and key used to encrypt '. |
|
| 409 | - ' the symmetric key for the message. Key was: '. |
|
| 410 | - var_export($inputKeyAlgo, true).'; message was: '. |
|
| 408 | + 'Algorithm mismatch between input key and key used to encrypt ' . |
|
| 409 | + ' the symmetric key for the message. Key was: ' . |
|
| 410 | + var_export($inputKeyAlgo, true) . '; message was: ' . |
|
| 411 | 411 | var_export($symKeyInfoAlgo, true) |
| 412 | 412 | ); |
| 413 | 413 | } |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | * symmetric key, and for that we need to know the key size. |
| 423 | 423 | */ |
| 424 | 424 | throw new \Exception( |
| 425 | - 'Unknown key size for encryption algorithm: '.var_export($symmetricKey->type, true) |
|
| 425 | + 'Unknown key size for encryption algorithm: ' . var_export($symmetricKey->type, true) |
|
| 426 | 426 | ); |
| 427 | 427 | } |
| 428 | 428 | |
@@ -434,13 +434,13 @@ discard block |
||
| 434 | 434 | $key = $encKey->decryptKey($symmetricKeyInfo); |
| 435 | 435 | if (strlen($key) !== $keySize) { |
| 436 | 436 | throw new \Exception( |
| 437 | - 'Unexpected key size ('.strval(strlen($key)*8).'bits) for encryption algorithm: '. |
|
| 437 | + 'Unexpected key size (' . strval(strlen($key) * 8) . 'bits) for encryption algorithm: ' . |
|
| 438 | 438 | var_export($symmetricKey->type, true) |
| 439 | 439 | ); |
| 440 | 440 | } |
| 441 | 441 | } catch (\Exception $e) { |
| 442 | 442 | /* We failed to decrypt this key. Log it, and substitute a "random" key. */ |
| 443 | - Utils::getContainer()->getLogger()->error('Failed to decrypt symmetric key: '.$e->getMessage()); |
|
| 443 | + Utils::getContainer()->getLogger()->error('Failed to decrypt symmetric key: ' . $e->getMessage()); |
|
| 444 | 444 | /* Create a replacement key, so that it looks like we fail in the same way as if the key was correctly |
| 445 | 445 | * padded. */ |
| 446 | 446 | |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | /** @psalm-suppress PossiblyNullArgument */ |
| 456 | 456 | $pkey = openssl_pkey_get_details($symmetricKeyInfo->key); |
| 457 | 457 | $pkey = sha1(serialize($pkey), true); |
| 458 | - $key = sha1($encryptedKey.$pkey, true); |
|
| 458 | + $key = sha1($encryptedKey . $pkey, true); |
|
| 459 | 459 | |
| 460 | 460 | /* Make sure that the key has the correct length. */ |
| 461 | 461 | if (strlen($key) > $keySize) { |
@@ -470,8 +470,8 @@ discard block |
||
| 470 | 470 | /* Make sure that the input key has the correct format. */ |
| 471 | 471 | if ($inputKeyAlgo !== $symKeyAlgo) { |
| 472 | 472 | throw new \Exception( |
| 473 | - 'Algorithm mismatch between input key and key in message. '. |
|
| 474 | - 'Key was: '.var_export($inputKeyAlgo, true).'; message was: '. |
|
| 473 | + 'Algorithm mismatch between input key and key in message. ' . |
|
| 474 | + 'Key was: ' . var_export($inputKeyAlgo, true) . '; message was: ' . |
|
| 475 | 475 | var_export($symKeyAlgo, true) |
| 476 | 476 | ); |
| 477 | 477 | } |
@@ -480,7 +480,7 @@ discard block |
||
| 480 | 480 | |
| 481 | 481 | $algorithm = $symmetricKey->getAlgorithm(); |
| 482 | 482 | if (in_array($algorithm, $blacklist, true)) { |
| 483 | - throw new \Exception('Algorithm disabled: '.var_export($algorithm, true)); |
|
| 483 | + throw new \Exception('Algorithm disabled: ' . var_export($algorithm, true)); |
|
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | /** |
@@ -494,9 +494,9 @@ discard block |
||
| 494 | 494 | * tree was serialized for encryption. In that case, we may miss the |
| 495 | 495 | * namespaces needed to parse the XML. |
| 496 | 496 | */ |
| 497 | - $xml = '<root xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" '. |
|
| 498 | - 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'. |
|
| 499 | - $decrypted. |
|
| 497 | + $xml = '<root xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" ' . |
|
| 498 | + 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' . |
|
| 499 | + $decrypted . |
|
| 500 | 500 | '</root>'; |
| 501 | 501 | |
| 502 | 502 | try { |
@@ -533,7 +533,7 @@ discard block |
||
| 533 | 533 | * Something went wrong during decryption, but for security |
| 534 | 534 | * reasons we cannot tell the user what failed. |
| 535 | 535 | */ |
| 536 | - Utils::getContainer()->getLogger()->error('Decryption failed: '.$e->getMessage()); |
|
| 536 | + Utils::getContainer()->getLogger()->error('Decryption failed: ' . $e->getMessage()); |
|
| 537 | 537 | throw new \Exception('Failed to decrypt XML element.', 0, $e); |
| 538 | 538 | } |
| 539 | 539 | } |
@@ -697,7 +697,7 @@ discard block |
||
| 697 | 697 | $regex = '/^(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)T(\\d\\d):(\\d\\d):(\\d\\d)(?:\\.\\d{1,9})?Z$/D'; |
| 698 | 698 | if (preg_match($regex, $time, $matches) == 0) { |
| 699 | 699 | throw new \Exception( |
| 700 | - 'Invalid SAML2 timestamp passed to xsDateTimeToTimestamp: '.$time |
|
| 700 | + 'Invalid SAML2 timestamp passed to xsDateTimeToTimestamp: ' . $time |
|
| 701 | 701 | ); |
| 702 | 702 | } |
| 703 | 703 | |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | |
| 157 | 157 | if ($xml->getAttribute('Version') !== '2.0') { |
| 158 | 158 | /* Currently a very strict check. */ |
| 159 | - throw new \Exception('Unsupported version: '.$xml->getAttribute('Version')); |
|
| 159 | + throw new \Exception('Unsupported version: ' . $xml->getAttribute('Version')); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | $this->issueInstant = Utils::xsDateTimeToTimestamp($xml->getAttribute('IssueInstant')); |
@@ -437,7 +437,7 @@ discard block |
||
| 437 | 437 | { |
| 438 | 438 | $this->document = DOMDocumentFactory::create(); |
| 439 | 439 | |
| 440 | - $root = $this->document->createElementNS(Constants::NS_SAMLP, 'samlp:'.$this->tagName); |
|
| 440 | + $root = $this->document->createElementNS(Constants::NS_SAMLP, 'samlp:' . $this->tagName); |
|
| 441 | 441 | $this->document->appendChild($root); |
| 442 | 442 | |
| 443 | 443 | /* Ugly hack to add another namespace declaration to the root element. */ |
@@ -560,7 +560,7 @@ discard block |
||
| 560 | 560 | public static function fromXML(\DOMElement $xml) : Message |
| 561 | 561 | { |
| 562 | 562 | if ($xml->namespaceURI !== Constants::NS_SAMLP) { |
| 563 | - throw new \Exception('Unknown namespace of SAML message: '.var_export($xml->namespaceURI, true)); |
|
| 563 | + throw new \Exception('Unknown namespace of SAML message: ' . var_export($xml->namespaceURI, true)); |
|
| 564 | 564 | } |
| 565 | 565 | |
| 566 | 566 | switch ($xml->localName) { |
@@ -579,7 +579,7 @@ discard block |
||
| 579 | 579 | case 'ArtifactResolve': |
| 580 | 580 | return new ArtifactResolve($xml); |
| 581 | 581 | default: |
| 582 | - throw new \Exception('Unknown SAML message: '.var_export($xml->localName, true)); |
|
| 582 | + throw new \Exception('Unknown SAML message: ' . var_export($xml->localName, true)); |
|
| 583 | 583 | } |
| 584 | 584 | } |
| 585 | 585 | |
@@ -65,20 +65,20 @@ |
||
| 65 | 65 | |
| 66 | 66 | // ported from |
| 67 | 67 | // https://github.com/simplesamlphp/simplesamlphp/blob/3d735912342767d391297cc5e13272a76730aca0/lib/SimpleSAML/Configuration.php#L1092 |
| 68 | - if ($configuration->hasValue($prefix.'keys')) { |
|
| 69 | - $extracted['keys'] = $configuration->getArray($prefix.'keys'); |
|
| 68 | + if ($configuration->hasValue($prefix . 'keys')) { |
|
| 69 | + $extracted['keys'] = $configuration->getArray($prefix . 'keys'); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | // ported from |
| 73 | 73 | // https://github.com/simplesamlphp/simplesamlphp/blob/3d735912342767d391297cc5e13272a76730aca0/lib/SimpleSAML/Configuration.php#L1108 |
| 74 | - if ($configuration->hasValue($prefix.'certData')) { |
|
| 75 | - $extracted['certificateData'] = $configuration->getString($prefix.'certData'); |
|
| 74 | + if ($configuration->hasValue($prefix . 'certData')) { |
|
| 75 | + $extracted['certificateData'] = $configuration->getString($prefix . 'certData'); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | // ported from |
| 79 | 79 | // https://github.com/simplesamlphp/simplesamlphp/blob/3d735912342767d391297cc5e13272a76730aca0/lib/SimpleSAML/Configuration.php#L1119 |
| 80 | - if ($configuration->hasValue($prefix.'certificate')) { |
|
| 81 | - $extracted['certificateData'] = $configuration->getString($prefix.'certificate'); |
|
| 80 | + if ($configuration->hasValue($prefix . 'certificate')) { |
|
| 81 | + $extracted['certificateData'] = $configuration->getString($prefix . 'certificate'); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | $extracted['assertionEncryptionEnabled'] = $configuration->getBoolean('assertion.encryption', false); |