Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 2 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| LisOauthService | |
0.00% |
0 / 2 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
| sign | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| validateBodyHash | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; under version 2 |
| 7 | * of the License (non-upgradable). |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | * |
| 18 | * Copyright (c) 2019 (original work) Open Assessment Technologies SA; |
| 19 | */ |
| 20 | |
| 21 | namespace oat\taoLti\models\classes\Lis; |
| 22 | |
| 23 | use common_exception_NoImplementation; |
| 24 | use common_http_Credentials; |
| 25 | use common_http_Request; |
| 26 | use oat\tao\model\oauth\OauthService; |
| 27 | |
| 28 | /** |
| 29 | * This class with own SERVICE_ID allows us to register in separately from oat\tao\model\oauth\OauthService with |
| 30 | * own config values. Used only to utilize existing validation logic at the moment |
| 31 | */ |
| 32 | class LisOauthService extends OauthService |
| 33 | { |
| 34 | public const SERVICE_ID = 'taoLti/LisOauthService'; |
| 35 | |
| 36 | /** |
| 37 | * @inheritDoc |
| 38 | * @throws common_exception_NoImplementation |
| 39 | */ |
| 40 | public function sign( |
| 41 | common_http_Request $request, |
| 42 | common_http_Credentials $credentials, |
| 43 | $authorizationHeader = false |
| 44 | ) { |
| 45 | throw new common_exception_NoImplementation('Signing not implemented'); |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Perform a real check of body hash |
| 50 | * @inheritDoc |
| 51 | */ |
| 52 | protected function validateBodyHash($body, $bodyHash) |
| 53 | { |
| 54 | // No need to perform time insensitive comparison here, because possible |
| 55 | // attacker already has both bodyHash and body |
| 56 | return $this->calculateOauthBodyHash($body) === $bodyHash; |
| 57 | } |
| 58 | } |