Completed
Push — master ( af52ac...726404 )
by Jaime Pérez
13:00
created
src/SAML2/Utils.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
             $symKeyInfoAlgo = $symmetricKeyInfo->getAlgorithm();
424 424
 
425 425
             if (in_array($symKeyInfoAlgo, $blacklist, true)) {
426
-                throw new \Exception('Algorithm disabled: ' . var_export($symKeyInfoAlgo, true));
426
+                throw new \Exception('Algorithm disabled: '.var_export($symKeyInfoAlgo, true));
427 427
             }
428 428
 
429 429
             if ($symKeyInfoAlgo === XMLSecurityKey::RSA_OAEP_MGF1P && $inputKeyAlgo === XMLSecurityKey::RSA_1_5) {
@@ -439,9 +439,9 @@  discard block
 block discarded – undo
439 439
             /* Make sure that the input key format is the same as the one used to encrypt the key. */
440 440
             if ($inputKeyAlgo !== $symKeyInfoAlgo) {
441 441
                 throw new \Exception(
442
-                    'Algorithm mismatch between input key and key used to encrypt ' .
443
-                    ' the symmetric key for the message. Key was: ' .
444
-                    var_export($inputKeyAlgo, true) . '; message was: ' .
442
+                    'Algorithm mismatch between input key and key used to encrypt '.
443
+                    ' the symmetric key for the message. Key was: '.
444
+                    var_export($inputKeyAlgo, true).'; message was: '.
445 445
                     var_export($symKeyInfoAlgo, true)
446 446
                 );
447 447
             }
@@ -455,20 +455,20 @@  discard block
 block discarded – undo
455 455
                 /* To protect against "key oracle" attacks, we need to be able to create a
456 456
                  * symmetric key, and for that we need to know the key size.
457 457
                  */
458
-                throw new \Exception('Unknown key size for encryption algorithm: ' . var_export($symmetricKey->type, true));
458
+                throw new \Exception('Unknown key size for encryption algorithm: '.var_export($symmetricKey->type, true));
459 459
             }
460 460
 
461 461
             try {
462 462
                 $key = $encKey->decryptKey($symmetricKeyInfo);
463 463
                 if (strlen($key) != $keySize) {
464 464
                     throw new \Exception(
465
-                        'Unexpected key size (' . strlen($key) * 8 . 'bits) for encryption algorithm: ' .
465
+                        'Unexpected key size ('.strlen($key)*8.'bits) for encryption algorithm: '.
466 466
                         var_export($symmetricKey->type, true)
467 467
                     );
468 468
                 }
469 469
             } catch (\Exception $e) {
470 470
                 /* We failed to decrypt this key. Log it, and substitute a "random" key. */
471
-                Utils::getContainer()->getLogger()->error('Failed to decrypt symmetric key: ' . $e->getMessage());
471
+                Utils::getContainer()->getLogger()->error('Failed to decrypt symmetric key: '.$e->getMessage());
472 472
                 /* Create a replacement key, so that it looks like we fail in the same way as if the key was correctly padded. */
473 473
 
474 474
                 /* We base the symmetric key on the encrypted key and private key, so that we always behave the
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
                 $encryptedKey = $encKey->getCipherValue();
478 478
                 $pkey = openssl_pkey_get_details($symmetricKeyInfo->key);
479 479
                 $pkey = sha1(serialize($pkey), true);
480
-                $key = sha1($encryptedKey . $pkey, true);
480
+                $key = sha1($encryptedKey.$pkey, true);
481 481
 
482 482
                 /* Make sure that the key has the correct length. */
483 483
                 if (strlen($key) > $keySize) {
@@ -492,8 +492,8 @@  discard block
 block discarded – undo
492 492
             /* Make sure that the input key has the correct format. */
493 493
             if ($inputKeyAlgo !== $symKeyAlgo) {
494 494
                 throw new \Exception(
495
-                    'Algorithm mismatch between input key and key in message. ' .
496
-                    'Key was: ' . var_export($inputKeyAlgo, true) . '; message was: ' .
495
+                    'Algorithm mismatch between input key and key in message. '.
496
+                    'Key was: '.var_export($inputKeyAlgo, true).'; message was: '.
497 497
                     var_export($symKeyAlgo, true)
498 498
                 );
499 499
             }
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
 
503 503
         $algorithm = $symmetricKey->getAlgorithm();
504 504
         if (in_array($algorithm, $blacklist, true)) {
505
-            throw new \Exception('Algorithm disabled: ' . var_export($algorithm, true));
505
+            throw new \Exception('Algorithm disabled: '.var_export($algorithm, true));
506 506
         }
507 507
 
508 508
         /** @var string $decrypted */
@@ -514,8 +514,8 @@  discard block
 block discarded – undo
514 514
          * namespaces needed to parse the XML.
515 515
          */
516 516
         $xml = '<root xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" '.
517
-                     'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' .
518
-            $decrypted .
517
+                     'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'.
518
+            $decrypted.
519 519
             '</root>';
520 520
 
521 521
         try {
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
              * Something went wrong during decryption, but for security
555 555
              * reasons we cannot tell the user what failed.
556 556
              */
557
-            Utils::getContainer()->getLogger()->error('Decryption failed: ' . $e->getMessage());
557
+            Utils::getContainer()->getLogger()->error('Decryption failed: '.$e->getMessage());
558 558
             throw new \Exception('Failed to decrypt XML element.', 0, $e);
559 559
         }
560 560
     }
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
         $regex = '/^(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)T(\\d\\d):(\\d\\d):(\\d\\d)(?:\\.\\d{1,9})?Z$/D';
717 717
         if (preg_match($regex, $time, $matches) == 0) {
718 718
             throw new \Exception(
719
-                'Invalid SAML2 timestamp passed to xsDateTimeToTimestamp: ' . $time
719
+                'Invalid SAML2 timestamp passed to xsDateTimeToTimestamp: '.$time
720 720
             );
721 721
         }
722 722
 
Please login to merge, or discard this patch.