Conditions | 2 |
Paths | 2 |
Total Lines | 20 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 2 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
43 | 5 | public function isAuthentic(ResponseInterface $response) |
|
44 | { |
||
45 | 5 | if (!$response->hasHeader('X-Server-Authorization-HMAC-SHA256')) { |
|
46 | 2 | throw new MalformedResponseException( |
|
47 | 2 | 'Response is missing required X-Server-Authorization-HMAC-SHA256 header.', |
|
48 | 2 | null, |
|
49 | 2 | 0, |
|
50 | 2 | $response |
|
51 | ); |
||
52 | } |
||
53 | |||
54 | 3 | $responseSigner = new ResponseSigner($this->key, $this->request); |
|
55 | 3 | $compareResponse = $responseSigner->signResponse( |
|
56 | 3 | $response->withoutHeader('X-Server-Authorization-HMAC-SHA256') |
|
57 | ); |
||
58 | |||
59 | 3 | $responseSignature = $response->getHeaderLine('X-Server-Authorization-HMAC-SHA256'); |
|
60 | 3 | $compareSignature = $compareResponse->getHeaderLine('X-Server-Authorization-HMAC-SHA256'); |
|
61 | |||
62 | 3 | return hash_equals($compareSignature, $responseSignature); |
|
63 | } |
||
65 |