@@ -76,7 +76,7 @@ |
||
| 76 | 76 | * are not configured to be used with the usage given |
| 77 | 77 | * |
| 78 | 78 | * @param array $configuredKeys |
| 79 | - * @param $usage |
|
| 79 | + * @param null|string $usage |
|
| 80 | 80 | */ |
| 81 | 81 | public function loadKeys(array $configuredKeys, $usage) |
| 82 | 82 | { |
@@ -248,7 +248,7 @@ |
||
| 248 | 248 | * |
| 249 | 249 | * @param DOMElement $node The element we should fetch the attribute from. |
| 250 | 250 | * @param string $attributeName The name of the attribute. |
| 251 | - * @param mixed $default The value that should be returned if the attribute doesn't exist. |
|
| 251 | + * @param false|null $default The value that should be returned if the attribute doesn't exist. |
|
| 252 | 252 | * @return bool|mixed The value of the attribute, or $default if the attribute doesn't exist. |
| 253 | 253 | * @throws Exception |
| 254 | 254 | */ |
@@ -493,7 +493,7 @@ |
||
| 493 | 493 | * namespaces needed to parse the XML. |
| 494 | 494 | */ |
| 495 | 495 | $xml = '<root xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" '. |
| 496 | - 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' . |
|
| 496 | + 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' . |
|
| 497 | 497 | $decrypted . |
| 498 | 498 | '</root>'; |
| 499 | 499 | |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /* Check the signature. */ |
| 168 | - if (! $objXMLSecDSig->verify($key)) { |
|
| 168 | + if (!$objXMLSecDSig->verify($key)) { |
|
| 169 | 169 | throw new \Exception("Unable to validate Signature"); |
| 170 | 170 | } |
| 171 | 171 | } |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | foreach ($namespaces as $prefix => $uri) { |
| 249 | - $newElement->setAttributeNS($uri, $prefix . ':__ns_workaround__', 'tmp'); |
|
| 249 | + $newElement->setAttributeNS($uri, $prefix.':__ns_workaround__', 'tmp'); |
|
| 250 | 250 | $newElement->removeAttributeNS($uri, '__ns_workaround__'); |
| 251 | 251 | } |
| 252 | 252 | |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | case 'true': |
| 280 | 280 | return true; |
| 281 | 281 | default: |
| 282 | - throw new \Exception('Invalid value of boolean attribute ' . var_export($attributeName, true) . ': ' . var_export($value, true)); |
|
| 282 | + throw new \Exception('Invalid value of boolean attribute '.var_export($attributeName, true).': '.var_export($value, true)); |
|
| 283 | 283 | } |
| 284 | 284 | } |
| 285 | 285 | |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | $symKeyInfoAlgo = $symmetricKeyInfo->getAlgorith(); |
| 412 | 412 | |
| 413 | 413 | if (in_array($symKeyInfoAlgo, $blacklist, true)) { |
| 414 | - throw new \Exception('Algorithm disabled: ' . var_export($symKeyInfoAlgo, true)); |
|
| 414 | + throw new \Exception('Algorithm disabled: '.var_export($symKeyInfoAlgo, true)); |
|
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | if ($symKeyInfoAlgo === XMLSecurityKey::RSA_OAEP_MGF1P && $inputKeyAlgo === XMLSecurityKey::RSA_1_5) { |
@@ -427,9 +427,9 @@ discard block |
||
| 427 | 427 | /* Make sure that the input key format is the same as the one used to encrypt the key. */ |
| 428 | 428 | if ($inputKeyAlgo !== $symKeyInfoAlgo) { |
| 429 | 429 | throw new \Exception( |
| 430 | - 'Algorithm mismatch between input key and key used to encrypt ' . |
|
| 431 | - ' the symmetric key for the message. Key was: ' . |
|
| 432 | - var_export($inputKeyAlgo, true) . '; message was: ' . |
|
| 430 | + 'Algorithm mismatch between input key and key used to encrypt '. |
|
| 431 | + ' the symmetric key for the message. Key was: '. |
|
| 432 | + var_export($inputKeyAlgo, true).'; message was: '. |
|
| 433 | 433 | var_export($symKeyInfoAlgo, true) |
| 434 | 434 | ); |
| 435 | 435 | } |
@@ -443,20 +443,20 @@ discard block |
||
| 443 | 443 | /* To protect against "key oracle" attacks, we need to be able to create a |
| 444 | 444 | * symmetric key, and for that we need to know the key size. |
| 445 | 445 | */ |
| 446 | - throw new \Exception('Unknown key size for encryption algorithm: ' . var_export($symmetricKey->type, true)); |
|
| 446 | + throw new \Exception('Unknown key size for encryption algorithm: '.var_export($symmetricKey->type, true)); |
|
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | try { |
| 450 | 450 | $key = $encKey->decryptKey($symmetricKeyInfo); |
| 451 | 451 | if (strlen($key) != $keySize) { |
| 452 | 452 | throw new \Exception( |
| 453 | - 'Unexpected key size (' . strlen($key) * 8 . 'bits) for encryption algorithm: ' . |
|
| 453 | + 'Unexpected key size ('.strlen($key)*8.'bits) for encryption algorithm: '. |
|
| 454 | 454 | var_export($symmetricKey->type, true) |
| 455 | 455 | ); |
| 456 | 456 | } |
| 457 | 457 | } catch (\Exception $e) { |
| 458 | 458 | /* We failed to decrypt this key. Log it, and substitute a "random" key. */ |
| 459 | - Utils::getContainer()->getLogger()->error('Failed to decrypt symmetric key: ' . $e->getMessage()); |
|
| 459 | + Utils::getContainer()->getLogger()->error('Failed to decrypt symmetric key: '.$e->getMessage()); |
|
| 460 | 460 | /* Create a replacement key, so that it looks like we fail in the same way as if the key was correctly padded. */ |
| 461 | 461 | |
| 462 | 462 | /* We base the symmetric key on the encrypted key and private key, so that we always behave the |
@@ -465,7 +465,7 @@ discard block |
||
| 465 | 465 | $encryptedKey = $encKey->getCipherValue(); |
| 466 | 466 | $pkey = openssl_pkey_get_details($symmetricKeyInfo->key); |
| 467 | 467 | $pkey = sha1(serialize($pkey), true); |
| 468 | - $key = sha1($encryptedKey . $pkey, true); |
|
| 468 | + $key = sha1($encryptedKey.$pkey, true); |
|
| 469 | 469 | |
| 470 | 470 | /* Make sure that the key has the correct length. */ |
| 471 | 471 | if (strlen($key) > $keySize) { |
@@ -480,8 +480,8 @@ discard block |
||
| 480 | 480 | /* Make sure that the input key has the correct format. */ |
| 481 | 481 | if ($inputKeyAlgo !== $symKeyAlgo) { |
| 482 | 482 | throw new \Exception( |
| 483 | - 'Algorithm mismatch between input key and key in message. ' . |
|
| 484 | - 'Key was: ' . var_export($inputKeyAlgo, true) . '; message was: ' . |
|
| 483 | + 'Algorithm mismatch between input key and key in message. '. |
|
| 484 | + 'Key was: '.var_export($inputKeyAlgo, true).'; message was: '. |
|
| 485 | 485 | var_export($symKeyAlgo, true) |
| 486 | 486 | ); |
| 487 | 487 | } |
@@ -490,7 +490,7 @@ discard block |
||
| 490 | 490 | |
| 491 | 491 | $algorithm = $symmetricKey->getAlgorith(); |
| 492 | 492 | if (in_array($algorithm, $blacklist, true)) { |
| 493 | - throw new \Exception('Algorithm disabled: ' . var_export($algorithm, true)); |
|
| 493 | + throw new \Exception('Algorithm disabled: '.var_export($algorithm, true)); |
|
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | /** @var string $decrypted */ |
@@ -502,8 +502,8 @@ discard block |
||
| 502 | 502 | * namespaces needed to parse the XML. |
| 503 | 503 | */ |
| 504 | 504 | $xml = '<root xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" '. |
| 505 | - 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' . |
|
| 506 | - $decrypted . |
|
| 505 | + 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'. |
|
| 506 | + $decrypted. |
|
| 507 | 507 | '</root>'; |
| 508 | 508 | |
| 509 | 509 | try { |
@@ -542,7 +542,7 @@ discard block |
||
| 542 | 542 | * Something went wrong during decryption, but for security |
| 543 | 543 | * reasons we cannot tell the user what failed. |
| 544 | 544 | */ |
| 545 | - Utils::getContainer()->getLogger()->error('Decryption failed: ' . $e->getMessage()); |
|
| 545 | + Utils::getContainer()->getLogger()->error('Decryption failed: '.$e->getMessage()); |
|
| 546 | 546 | throw new \Exception('Failed to decrypt XML element.', 0, $e); |
| 547 | 547 | } |
| 548 | 548 | } |
@@ -704,7 +704,7 @@ discard block |
||
| 704 | 704 | $regex = '/^(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)T(\\d\\d):(\\d\\d):(\\d\\d)(?:\\.\\d+)?Z$/D'; |
| 705 | 705 | if (preg_match($regex, $time, $matches) == 0) { |
| 706 | 706 | throw new \Exception( |
| 707 | - 'Invalid SAML2 timestamp passed to xsDateTimeToTimestamp: ' . $time |
|
| 707 | + 'Invalid SAML2 timestamp passed to xsDateTimeToTimestamp: '.$time |
|
| 708 | 708 | ); |
| 709 | 709 | } |
| 710 | 710 | |
@@ -68,7 +68,7 @@ |
||
| 68 | 68 | if (strpos($keyword, "+") !== FALSE) { |
| 69 | 69 | throw new Exception('Keywords may not contain a "+" character.'); |
| 70 | 70 | } |
| 71 | - $value .= str_replace(' ', '+', $keyword) . ' '; |
|
| 71 | + $value .= str_replace(' ', '+', $keyword).' '; |
|
| 72 | 72 | } |
| 73 | 73 | $value = rtrim($value); |
| 74 | 74 | $e->appendChild($doc->createTextNode($value)); |
@@ -173,8 +173,8 @@ |
||
| 173 | 173 | foreach ($this->certificates as $cert) { |
| 174 | 174 | |
| 175 | 175 | /* We have found a matching fingerprint. */ |
| 176 | - $pemCert = "-----BEGIN CERTIFICATE-----\n" . |
|
| 177 | - chunk_split($cert, 64) . |
|
| 176 | + $pemCert = "-----BEGIN CERTIFICATE-----\n". |
|
| 177 | + chunk_split($cert, 64). |
|
| 178 | 178 | "-----END CERTIFICATE-----\n"; |
| 179 | 179 | |
| 180 | 180 | /* Extract the public key from the certificate for validation. */ |
@@ -22,8 +22,8 @@ |
||
| 22 | 22 | return sprintf( |
| 23 | 23 | '%s%s%s', |
| 24 | 24 | $this->truncateStatus($responseStatus['Code']), |
| 25 | - $responseStatus['SubCode'] ? '/' . $this->truncateStatus($responseStatus['SubCode']) : '', |
|
| 26 | - $responseStatus['Message'] ? ' ' . $responseStatus['Message'] : '' |
|
| 25 | + $responseStatus['SubCode'] ? '/'.$this->truncateStatus($responseStatus['SubCode']) : '', |
|
| 26 | + $responseStatus['Message'] ? ' '.$responseStatus['Message'] : '' |
|
| 27 | 27 | ); |
| 28 | 28 | } |
| 29 | 29 | |
@@ -62,11 +62,11 @@ |
||
| 62 | 62 | */ |
| 63 | 63 | private $encryptionKey; |
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * The earliest time this assertion is valid, as an UNIX timestamp. |
|
| 67 | - * |
|
| 68 | - * @var int |
|
| 69 | - */ |
|
| 65 | + /** |
|
| 66 | + * The earliest time this assertion is valid, as an UNIX timestamp. |
|
| 67 | + * |
|
| 68 | + * @var int |
|
| 69 | + */ |
|
| 70 | 70 | private $notBefore; |
| 71 | 71 | |
| 72 | 72 | /** |
@@ -657,7 +657,7 @@ discard block |
||
| 657 | 657 | /** |
| 658 | 658 | * Check whether the NameId is encrypted. |
| 659 | 659 | * |
| 660 | - * @return true if the NameId is encrypted, false if not. |
|
| 660 | + * @return boolean if the NameId is encrypted, false if not. |
|
| 661 | 661 | */ |
| 662 | 662 | public function isNameIdEncrypted() |
| 663 | 663 | { |
@@ -785,7 +785,7 @@ discard block |
||
| 785 | 785 | * This function returns null if there are no restrictions on how early the |
| 786 | 786 | * assertion can be used. |
| 787 | 787 | * |
| 788 | - * @return int|null The earliest timestamp this assertion is valid. |
|
| 788 | + * @return integer The earliest timestamp this assertion is valid. |
|
| 789 | 789 | */ |
| 790 | 790 | public function getNotBefore() |
| 791 | 791 | { |
@@ -812,7 +812,7 @@ discard block |
||
| 812 | 812 | * This function returns null if there are no restrictions on how |
| 813 | 813 | * late the assertion can be used. |
| 814 | 814 | * |
| 815 | - * @return int|null The latest timestamp this assertion is valid. |
|
| 815 | + * @return integer The latest timestamp this assertion is valid. |
|
| 816 | 816 | */ |
| 817 | 817 | public function getNotOnOrAfter() |
| 818 | 818 | { |
@@ -870,7 +870,7 @@ discard block |
||
| 870 | 870 | /** |
| 871 | 871 | * Retrieve the AuthnInstant of the assertion. |
| 872 | 872 | * |
| 873 | - * @return int|null The timestamp the user was authenticated, or NULL if the user isn't authenticated. |
|
| 873 | + * @return integer The timestamp the user was authenticated, or NULL if the user isn't authenticated. |
|
| 874 | 874 | */ |
| 875 | 875 | public function getAuthnInstant() |
| 876 | 876 | { |
@@ -1032,7 +1032,7 @@ discard block |
||
| 1032 | 1032 | * See: |
| 1033 | 1033 | * @url http://docs.oasis-open.org/security/saml/v2.0/saml-authn-context-2.0-os.pdf |
| 1034 | 1034 | * |
| 1035 | - * @return \SAML2\XML\Chunk|null |
|
| 1035 | + * @return Chunk |
|
| 1036 | 1036 | */ |
| 1037 | 1037 | public function getAuthnContextDecl() |
| 1038 | 1038 | { |
@@ -1062,7 +1062,7 @@ discard block |
||
| 1062 | 1062 | * |
| 1063 | 1063 | * The URI reference MAY directly resolve into an XML document containing the referenced declaration. |
| 1064 | 1064 | * |
| 1065 | - * @return string |
|
| 1065 | + * @return Chunk |
|
| 1066 | 1066 | */ |
| 1067 | 1067 | public function getAuthnContextDeclRef() |
| 1068 | 1068 | { |
@@ -1094,7 +1094,7 @@ discard block |
||
| 1094 | 1094 | /** |
| 1095 | 1095 | * Retrieve all attributes. |
| 1096 | 1096 | * |
| 1097 | - * @return array All attributes, as an associative array. |
|
| 1097 | + * @return \DOMElement[] All attributes, as an associative array. |
|
| 1098 | 1098 | */ |
| 1099 | 1099 | public function getAttributes() |
| 1100 | 1100 | { |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | |
| 241 | 241 | if ($xml->getAttribute('Version') !== '2.0') { |
| 242 | 242 | /* Currently a very strict check. */ |
| 243 | - throw new \Exception('Unsupported version: ' . $xml->getAttribute('Version')); |
|
| 243 | + throw new \Exception('Unsupported version: '.$xml->getAttribute('Version')); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | $this->issueInstant = Utils::xsDateTimeToTimestamp($xml->getAttribute('IssueInstant')); |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | continue; |
| 341 | 341 | } |
| 342 | 342 | if ($node->namespaceURI !== Constants::NS_SAML) { |
| 343 | - throw new \Exception('Unknown namespace of condition: ' . var_export($node->namespaceURI, true)); |
|
| 343 | + throw new \Exception('Unknown namespace of condition: '.var_export($node->namespaceURI, true)); |
|
| 344 | 344 | } |
| 345 | 345 | switch ($node->localName) { |
| 346 | 346 | case 'AudienceRestriction': |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | /* Currently ignored. */ |
| 364 | 364 | break; |
| 365 | 365 | default: |
| 366 | - throw new \Exception('Unknown condition: ' . var_export($node->localName, true)); |
|
| 366 | + throw new \Exception('Unknown condition: '.var_export($node->localName, true)); |
|
| 367 | 367 | } |
| 368 | 368 | } |
| 369 | 369 | } |
@@ -1244,7 +1244,7 @@ discard block |
||
| 1244 | 1244 | $document = $parentElement->ownerDocument; |
| 1245 | 1245 | } |
| 1246 | 1246 | |
| 1247 | - $root = $document->createElementNS(Constants::NS_SAML, 'saml:' . 'Assertion'); |
|
| 1247 | + $root = $document->createElementNS(Constants::NS_SAML, 'saml:'.'Assertion'); |
|
| 1248 | 1248 | $parentElement->appendChild($root); |
| 1249 | 1249 | |
| 1250 | 1250 | /* Ugly hack to add another namespace declaration to the root element. */ |
@@ -1296,7 +1296,7 @@ discard block |
||
| 1296 | 1296 | if ($this->encryptedNameId === null) { |
| 1297 | 1297 | Utils::addNameId($subject, $this->nameId); |
| 1298 | 1298 | } else { |
| 1299 | - $eid = $subject->ownerDocument->createElementNS(Constants::NS_SAML, 'saml:' . 'EncryptedID'); |
|
| 1299 | + $eid = $subject->ownerDocument->createElementNS(Constants::NS_SAML, 'saml:'.'EncryptedID'); |
|
| 1300 | 1300 | $subject->appendChild($eid); |
| 1301 | 1301 | $eid->appendChild($subject->ownerDocument->importNode($this->encryptedNameId, true)); |
| 1302 | 1302 | } |
@@ -51,25 +51,25 @@ |
||
| 51 | 51 | |
| 52 | 52 | // ported from |
| 53 | 53 | // https://github.com/simplesamlphp/simplesamlphp/blob/3d735912342767d391297cc5e13272a76730aca0/lib/SimpleSAML/Configuration.php#L1092 |
| 54 | - if ($configuration->hasValue($prefix . 'keys')) { |
|
| 55 | - $extracted['keys'] = $configuration->getArray($prefix . 'keys'); |
|
| 54 | + if ($configuration->hasValue($prefix.'keys')) { |
|
| 55 | + $extracted['keys'] = $configuration->getArray($prefix.'keys'); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | // ported from |
| 59 | 59 | // https://github.com/simplesamlphp/simplesamlphp/blob/3d735912342767d391297cc5e13272a76730aca0/lib/SimpleSAML/Configuration.php#L1108 |
| 60 | - if ($configuration->hasValue($prefix . 'certData')) { |
|
| 61 | - $extracted['certificateData'] = $configuration->getString($prefix . 'certData'); |
|
| 60 | + if ($configuration->hasValue($prefix.'certData')) { |
|
| 61 | + $extracted['certificateData'] = $configuration->getString($prefix.'certData'); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | // ported from |
| 65 | 65 | // https://github.com/simplesamlphp/simplesamlphp/blob/3d735912342767d391297cc5e13272a76730aca0/lib/SimpleSAML/Configuration.php#L1119 |
| 66 | - if ($configuration->hasValue($prefix . 'certificate')) { |
|
| 67 | - $extracted['certificateData'] = $configuration->getString($prefix . 'certificate'); |
|
| 66 | + if ($configuration->hasValue($prefix.'certificate')) { |
|
| 67 | + $extracted['certificateData'] = $configuration->getString($prefix.'certificate'); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | // ported from |
| 71 | 71 | // https://github.com/simplesamlphp/simplesamlphp/blob/3d735912342767d391297cc5e13272a76730aca0/modules/saml/lib/Message.php#L161 |
| 72 | - if ($configuration->hasValue($prefix . 'certFingerprint')) { |
|
| 72 | + if ($configuration->hasValue($prefix.'certFingerprint')) { |
|
| 73 | 73 | $extracted['certificateFingerprint'] = $configuration->getArrayizeString('certFingerprint'); |
| 74 | 74 | } |
| 75 | 75 | |
@@ -68,7 +68,7 @@ |
||
| 68 | 68 | |
| 69 | 69 | throw new SAML2_Signature_MissingConfigurationException(sprintf( |
| 70 | 70 | 'No certificates or fingerprints have been configured%s', |
| 71 | - $configuration->has('entityid') ? ' for "' . $configuration->get('entityid') . '"' : '' |
|
| 71 | + $configuration->has('entityid') ? ' for "'.$configuration->get('entityid').'"' : '' |
|
| 72 | 72 | )); |
| 73 | 73 | } |
| 74 | 74 | } |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | SAML2_SignedElement $signedElement, |
| 58 | 58 | SAML2_Configuration_CertificateProvider $configuration |
| 59 | 59 | ) { |
| 60 | - $this->certificates = array_map(function ($certificate) { |
|
| 60 | + $this->certificates = array_map(function($certificate) { |
|
| 61 | 61 | return SAML2_Certificate_X509::createFromCertificateData($certificate); |
| 62 | 62 | }, $this->certificates); |
| 63 | 63 | |