Conditions | 6 |
Paths | 6 |
Total Lines | 30 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 42 |
Changes | 0 |
1 | <?php |
||
26 | public function getFirstAssertion(SamlResponse $response) |
||
27 | { |
||
28 | |||
29 | /** @var AbstractProvider $ownProvider */ |
||
30 | $ownProvider = Saml::getInstance()->getProvider()->findOwn(); |
||
31 | |||
32 | // grab the first one |
||
33 | $assertion = $response->getAssertions()[0]; |
||
34 | |||
35 | // decrypt if needed |
||
36 | if ($ownProvider->keychain && |
||
37 | $assertion instanceof EncryptedAssertion && |
||
38 | is_null($this->firstDecryptedAssertion) |
||
39 | ) { |
||
40 | $assertion = SecurityHelper::decryptAssertion( |
||
41 | $assertion, |
||
42 | $ownProvider->keychain->getDecryptedCertificate() |
||
43 | ); |
||
44 | |||
45 | // only do this once |
||
46 | $this->firstDecryptedAssertion = $assertion; |
||
47 | } |
||
48 | |||
49 | |||
50 | if (! isset($assertion)) { |
||
51 | throw new InvalidMessage("Invalid message. No assertions found in response."); |
||
52 | } |
||
53 | |||
54 | return $this->firstDecryptedAssertion ?: $assertion; |
||
55 | } |
||
56 | } |
||
57 |