@@ -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 | { |
@@ -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 |
@@ -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 | |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | $symKeyInfoAlgo = $symmetricKeyInfo->getAlgorith(); |
416 | 416 | |
417 | 417 | if (in_array($symKeyInfoAlgo, $blacklist, true)) { |
418 | - throw new \Exception('Algorithm disabled: ' . var_export($symKeyInfoAlgo, true)); |
|
418 | + throw new \Exception('Algorithm disabled: '.var_export($symKeyInfoAlgo, true)); |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | if ($symKeyInfoAlgo === XMLSecurityKey::RSA_OAEP_MGF1P && $inputKeyAlgo === XMLSecurityKey::RSA_1_5) { |
@@ -431,9 +431,9 @@ discard block |
||
431 | 431 | /* Make sure that the input key format is the same as the one used to encrypt the key. */ |
432 | 432 | if ($inputKeyAlgo !== $symKeyInfoAlgo) { |
433 | 433 | throw new \Exception( |
434 | - 'Algorithm mismatch between input key and key used to encrypt ' . |
|
435 | - ' the symmetric key for the message. Key was: ' . |
|
436 | - var_export($inputKeyAlgo, true) . '; message was: ' . |
|
434 | + 'Algorithm mismatch between input key and key used to encrypt '. |
|
435 | + ' the symmetric key for the message. Key was: '. |
|
436 | + var_export($inputKeyAlgo, true).'; message was: '. |
|
437 | 437 | var_export($symKeyInfoAlgo, true) |
438 | 438 | ); |
439 | 439 | } |
@@ -447,20 +447,20 @@ discard block |
||
447 | 447 | /* To protect against "key oracle" attacks, we need to be able to create a |
448 | 448 | * symmetric key, and for that we need to know the key size. |
449 | 449 | */ |
450 | - throw new \Exception('Unknown key size for encryption algorithm: ' . var_export($symmetricKey->type, true)); |
|
450 | + throw new \Exception('Unknown key size for encryption algorithm: '.var_export($symmetricKey->type, true)); |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | try { |
454 | 454 | $key = $encKey->decryptKey($symmetricKeyInfo); |
455 | 455 | if (strlen($key) != $keySize) { |
456 | 456 | throw new \Exception( |
457 | - 'Unexpected key size (' . strlen($key) * 8 . 'bits) for encryption algorithm: ' . |
|
457 | + 'Unexpected key size ('.strlen($key)*8.'bits) for encryption algorithm: '. |
|
458 | 458 | var_export($symmetricKey->type, true) |
459 | 459 | ); |
460 | 460 | } |
461 | 461 | } catch (\Exception $e) { |
462 | 462 | /* We failed to decrypt this key. Log it, and substitute a "random" key. */ |
463 | - Utils::getContainer()->getLogger()->error('Failed to decrypt symmetric key: ' . $e->getMessage()); |
|
463 | + Utils::getContainer()->getLogger()->error('Failed to decrypt symmetric key: '.$e->getMessage()); |
|
464 | 464 | /* Create a replacement key, so that it looks like we fail in the same way as if the key was correctly padded. */ |
465 | 465 | |
466 | 466 | /* We base the symmetric key on the encrypted key and private key, so that we always behave the |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | $encryptedKey = $encKey->getCipherValue(); |
470 | 470 | $pkey = openssl_pkey_get_details($symmetricKeyInfo->key); |
471 | 471 | $pkey = sha1(serialize($pkey), true); |
472 | - $key = sha1($encryptedKey . $pkey, true); |
|
472 | + $key = sha1($encryptedKey.$pkey, true); |
|
473 | 473 | |
474 | 474 | /* Make sure that the key has the correct length. */ |
475 | 475 | if (strlen($key) > $keySize) { |
@@ -484,8 +484,8 @@ discard block |
||
484 | 484 | /* Make sure that the input key has the correct format. */ |
485 | 485 | if ($inputKeyAlgo !== $symKeyAlgo) { |
486 | 486 | throw new \Exception( |
487 | - 'Algorithm mismatch between input key and key in message. ' . |
|
488 | - 'Key was: ' . var_export($inputKeyAlgo, true) . '; message was: ' . |
|
487 | + 'Algorithm mismatch between input key and key in message. '. |
|
488 | + 'Key was: '.var_export($inputKeyAlgo, true).'; message was: '. |
|
489 | 489 | var_export($symKeyAlgo, true) |
490 | 490 | ); |
491 | 491 | } |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | |
495 | 495 | $algorithm = $symmetricKey->getAlgorith(); |
496 | 496 | if (in_array($algorithm, $blacklist, true)) { |
497 | - throw new \Exception('Algorithm disabled: ' . var_export($algorithm, true)); |
|
497 | + throw new \Exception('Algorithm disabled: '.var_export($algorithm, true)); |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | /** @var string $decrypted */ |
@@ -506,8 +506,8 @@ discard block |
||
506 | 506 | * namespaces needed to parse the XML. |
507 | 507 | */ |
508 | 508 | $xml = '<root xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" '. |
509 | - 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' . |
|
510 | - $decrypted . |
|
509 | + 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'. |
|
510 | + $decrypted. |
|
511 | 511 | '</root>'; |
512 | 512 | |
513 | 513 | try { |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | * Something went wrong during decryption, but for security |
547 | 547 | * reasons we cannot tell the user what failed. |
548 | 548 | */ |
549 | - Utils::getContainer()->getLogger()->error('Decryption failed: ' . $e->getMessage()); |
|
549 | + Utils::getContainer()->getLogger()->error('Decryption failed: '.$e->getMessage()); |
|
550 | 550 | throw new \Exception('Failed to decrypt XML element.', 0, $e); |
551 | 551 | } |
552 | 552 | } |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | $regex = '/^(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)T(\\d\\d):(\\d\\d):(\\d\\d)(?:\\.\\d+)?Z$/D'; |
709 | 709 | if (preg_match($regex, $time, $matches) == 0) { |
710 | 710 | throw new \Exception( |
711 | - 'Invalid SAML2 timestamp passed to xsDateTimeToTimestamp: ' . $time |
|
711 | + 'Invalid SAML2 timestamp passed to xsDateTimeToTimestamp: '.$time |
|
712 | 712 | ); |
713 | 713 | } |
714 | 714 |
@@ -260,7 +260,7 @@ |
||
260 | 260 | * |
261 | 261 | * @param \DOMElement $node The element we should fetch the attribute from. |
262 | 262 | * @param string $attributeName The name of the attribute. |
263 | - * @param mixed $default The value that should be returned if the attribute doesn't exist. |
|
263 | + * @param false|null $default The value that should be returned if the attribute doesn't exist. |
|
264 | 264 | * @return bool|mixed The value of the attribute, or $default if the attribute doesn't exist. |
265 | 265 | * @throws \Exception |
266 | 266 | */ |
@@ -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 | /** |
@@ -753,7 +753,7 @@ discard block |
||
753 | 753 | /** |
754 | 754 | * Check whether the NameId is encrypted. |
755 | 755 | * |
756 | - * @return true if the NameId is encrypted, false if not. |
|
756 | + * @return boolean if the NameId is encrypted, false if not. |
|
757 | 757 | */ |
758 | 758 | public function isNameIdEncrypted() |
759 | 759 | { |
@@ -1155,7 +1155,7 @@ discard block |
||
1155 | 1155 | * |
1156 | 1156 | * The URI reference MAY directly resolve into an XML document containing the referenced declaration. |
1157 | 1157 | * |
1158 | - * @return string |
|
1158 | + * @return Chunk |
|
1159 | 1159 | */ |
1160 | 1160 | public function getAuthnContextDeclRef() |
1161 | 1161 | { |
@@ -1217,7 +1217,6 @@ discard block |
||
1217 | 1217 | /** |
1218 | 1218 | * Replace all attributes value types.. |
1219 | 1219 | * |
1220 | - * @param array $attributes All new attribute value types, as an associative array. |
|
1221 | 1220 | */ |
1222 | 1221 | public function setAttributesValueTypes(array $attributesValueTypes) |
1223 | 1222 | { |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | |
278 | 278 | if ($xml->getAttribute('Version') !== '2.0') { |
279 | 279 | /* Currently a very strict check. */ |
280 | - throw new \Exception('Unsupported version: ' . $xml->getAttribute('Version')); |
|
280 | + throw new \Exception('Unsupported version: '.$xml->getAttribute('Version')); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | $this->issueInstant = Utils::xsDateTimeToTimestamp($xml->getAttribute('IssueInstant')); |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | continue; |
380 | 380 | } |
381 | 381 | if ($node->namespaceURI !== Constants::NS_SAML) { |
382 | - throw new \Exception('Unknown namespace of condition: ' . var_export($node->namespaceURI, true)); |
|
382 | + throw new \Exception('Unknown namespace of condition: '.var_export($node->namespaceURI, true)); |
|
383 | 383 | } |
384 | 384 | switch ($node->localName) { |
385 | 385 | case 'AudienceRestriction': |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | /* Currently ignored. */ |
403 | 403 | break; |
404 | 404 | default: |
405 | - throw new \Exception('Unknown condition: ' . var_export($node->localName, true)); |
|
405 | + throw new \Exception('Unknown condition: '.var_export($node->localName, true)); |
|
406 | 406 | } |
407 | 407 | } |
408 | 408 | } |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | } |
590 | 590 | |
591 | 591 | if ($type === 'xs:integer') { |
592 | - $this->attributes[$attributeName][] = (int)$value->textContent; |
|
592 | + $this->attributes[$attributeName][] = (int) $value->textContent; |
|
593 | 593 | } else { |
594 | 594 | $this->attributes[$attributeName][] = trim($value->textContent); |
595 | 595 | } |
@@ -1367,7 +1367,7 @@ discard block |
||
1367 | 1367 | $document = $parentElement->ownerDocument; |
1368 | 1368 | } |
1369 | 1369 | |
1370 | - $root = $document->createElementNS(Constants::NS_SAML, 'saml:' . 'Assertion'); |
|
1370 | + $root = $document->createElementNS(Constants::NS_SAML, 'saml:'.'Assertion'); |
|
1371 | 1371 | $parentElement->appendChild($root); |
1372 | 1372 | |
1373 | 1373 | /* Ugly hack to add another namespace declaration to the root element. */ |
@@ -1423,7 +1423,7 @@ discard block |
||
1423 | 1423 | if ($this->encryptedNameId === null) { |
1424 | 1424 | $this->nameId->toXML($subject); |
1425 | 1425 | } else { |
1426 | - $eid = $subject->ownerDocument->createElementNS(Constants::NS_SAML, 'saml:' . 'EncryptedID'); |
|
1426 | + $eid = $subject->ownerDocument->createElementNS(Constants::NS_SAML, 'saml:'.'EncryptedID'); |
|
1427 | 1427 | $subject->appendChild($eid); |
1428 | 1428 | $eid->appendChild($subject->ownerDocument->importNode($this->encryptedNameId, true)); |
1429 | 1429 | } |
@@ -1575,7 +1575,7 @@ discard block |
||
1575 | 1575 | if (is_array($this->attributesValueTypes) && array_key_exists($name, $this->attributesValueTypes)) { |
1576 | 1576 | $valueTypes = $this->attributesValueTypes[$name]; |
1577 | 1577 | if (is_array($valueTypes) && count($valueTypes) != count($values)) { |
1578 | - throw new \Exception('Array of value types and array of values have different size for attribute '. var_export($name, true)); |
|
1578 | + throw new \Exception('Array of value types and array of values have different size for attribute '.var_export($name, true)); |
|
1579 | 1579 | } |
1580 | 1580 | } else { |
1581 | 1581 | // if no type(s), default behaviour |
@@ -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 |
@@ -107,7 +107,7 @@ |
||
107 | 107 | /** |
108 | 108 | * Check whether the NameId is encrypted. |
109 | 109 | * |
110 | - * @return true if the NameId is encrypted, false if not. |
|
110 | + * @return boolean if the NameId is encrypted, false if not. |
|
111 | 111 | */ |
112 | 112 | public function isNameIdEncrypted() |
113 | 113 | { |
@@ -264,7 +264,7 @@ |
||
264 | 264 | if ($this->encryptedNameId === null) { |
265 | 265 | $this->nameId->toXML($root); |
266 | 266 | } else { |
267 | - $eid = $root->ownerDocument->createElementNS(Constants::NS_SAML, 'saml:' . 'EncryptedID'); |
|
267 | + $eid = $root->ownerDocument->createElementNS(Constants::NS_SAML, 'saml:'.'EncryptedID'); |
|
268 | 268 | $root->appendChild($eid); |
269 | 269 | $eid->appendChild($root->ownerDocument->importNode($this->encryptedNameId, true)); |
270 | 270 | } |
@@ -45,7 +45,7 @@ |
||
45 | 45 | /** |
46 | 46 | * Retrieve the assertions in this response. |
47 | 47 | * |
48 | - * @return \SAML2\Assertion[]|\SAML2\EncryptedAssertion[] |
|
48 | + * @return Utilities\ArrayCollection |
|
49 | 49 | */ |
50 | 50 | public function getAssertions() |
51 | 51 | { |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * @param \SAML2\Configuration\Destination $currentDestination |
65 | 65 | * @param \SAML2\Response $response |
66 | 66 | * |
67 | - * @return \SAML2\Assertion[] Collection (\SAML2\Utilities\ArrayCollection) of \SAML2\Assertion objects |
|
67 | + * @return \SAML2\Utilities\ArrayCollection Collection (\SAML2\Utilities\ArrayCollection) of \SAML2\Assertion objects |
|
68 | 68 | */ |
69 | 69 | public function process( |
70 | 70 | ServiceProvider $serviceProviderConfiguration, |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | /** |
135 | 135 | * @param \SAML2\Response $response |
136 | 136 | * |
137 | - * @return \SAML2\Assertion[] |
|
137 | + * @return \SAML2\Utilities\ArrayCollection |
|
138 | 138 | */ |
139 | 139 | private function processAssertions(Response $response) |
140 | 140 | { |
@@ -212,6 +212,10 @@ |
||
212 | 212 | * @param $soapmessage Soap response needs to be type DOMDocument |
213 | 213 | * @return $soapfaultstring string|null |
214 | 214 | */ |
215 | + |
|
216 | + /** |
|
217 | + * @param \DOMDocument $soapMessage |
|
218 | + */ |
|
215 | 219 | private function getSOAPFault($soapMessage) |
216 | 220 | { |
217 | 221 | $soapFault = Utils::xpQuery($soapMessage->firstChild, '/soap-env:Envelope/soap-env:Body/soap-env:Fault'); |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | $privateKey = SimpleSAML_Utilities::loadPrivateKey($srcMetadata); |
52 | 52 | $publicKey = SimpleSAML_Utilities::loadPublicKey($srcMetadata); |
53 | 53 | if ($privateKey !== null && $publicKey !== null && isset($publicKey['PEM'])) { |
54 | - $keyCertData = $privateKey['PEM'] . $publicKey['PEM']; |
|
55 | - $file = SimpleSAML_Utilities::getTempDir() . '/' . sha1($keyCertData) . '.pem'; |
|
54 | + $keyCertData = $privateKey['PEM'].$publicKey['PEM']; |
|
55 | + $file = SimpleSAML_Utilities::getTempDir().'/'.sha1($keyCertData).'.pem'; |
|
56 | 56 | if (!file_exists($file)) { |
57 | 57 | SimpleSAML_Utilities::writeFile($file, $keyCertData); |
58 | 58 | } |
@@ -71,11 +71,11 @@ discard block |
||
71 | 71 | if ($key['type'] !== 'X509Certificate') { |
72 | 72 | continue; |
73 | 73 | } |
74 | - $certData .= "-----BEGIN CERTIFICATE-----\n" . |
|
75 | - chunk_split($key['X509Certificate'], 64) . |
|
74 | + $certData .= "-----BEGIN CERTIFICATE-----\n". |
|
75 | + chunk_split($key['X509Certificate'], 64). |
|
76 | 76 | "-----END CERTIFICATE-----\n"; |
77 | 77 | } |
78 | - $peerCertFile = SimpleSAML_Utilities::getTempDir() . '/' . sha1($certData) . '.pem'; |
|
78 | + $peerCertFile = SimpleSAML_Utilities::getTempDir().'/'.sha1($certData).'.pem'; |
|
79 | 79 | if (!file_exists($peerCertFile)) { |
80 | 80 | SimpleSAML_Utilities::writeFile($peerCertFile, $certData); |
81 | 81 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | |
101 | 101 | // Add soap-envelopes |
102 | 102 | $request = $msg->toSignedXML(); |
103 | - $request = self::START_SOAP_ENVELOPE . $request->ownerDocument->saveXML($request) . self::END_SOAP_ENVELOPE; |
|
103 | + $request = self::START_SOAP_ENVELOPE.$request->ownerDocument->saveXML($request).self::END_SOAP_ENVELOPE; |
|
104 | 104 | |
105 | 105 | Utils::getContainer()->debugMessage($request, 'out'); |
106 | 106 | |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | // There is a fault element but we haven't found out what the fault string is |
226 | 226 | $soapFaultString = "Unknown fault string found"; |
227 | 227 | // find out the fault string |
228 | - $faultStringElement = Utils::xpQuery($soapFaultElement, './soap-env:faultstring') ; |
|
228 | + $faultStringElement = Utils::xpQuery($soapFaultElement, './soap-env:faultstring'); |
|
229 | 229 | if (!empty($faultStringElement)) { |
230 | 230 | return $faultStringElement[0]->textContent; |
231 | 231 | } |