Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| ValidationRegistry | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
| getValidators | |
100.00% |
2 / 2 |
|
100.00% |
1 / 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) 2020 (original work) Open Assessment Technologies SA |
| 19 | */ |
| 20 | |
| 21 | declare(strict_types=1); |
| 22 | |
| 23 | namespace oat\taoLti\models\classes\LtiProvider\Validation; |
| 24 | |
| 25 | use oat\oatbox\service\ConfigurableService; |
| 26 | use oat\tao\model\oauth\DataStore; |
| 27 | use oat\taoLti\models\classes\LtiProvider\RdfLtiProviderRepository; |
| 28 | |
| 29 | class ValidationRegistry extends ConfigurableService |
| 30 | { |
| 31 | private const VALIDATORS = [ |
| 32 | '1.1' => [ |
| 33 | DataStore::PROPERTY_OAUTH_KEY => [['NotEmpty']], |
| 34 | DataStore::PROPERTY_OAUTH_SECRET => [['NotEmpty']], |
| 35 | RdfLtiProviderRepository::LTI_VERSION => [['NotEmpty']], |
| 36 | ], |
| 37 | '1.3' => [ |
| 38 | RdfLtiProviderRepository::LTI_VERSION => [['NotEmpty']], |
| 39 | RdfLtiProviderRepository::LTI_TOOL_CLIENT_ID => [['NotEmpty']], |
| 40 | RdfLtiProviderRepository::LTI_TOOL_IDENTIFIER => [['NotEmpty']], |
| 41 | RdfLtiProviderRepository::LTI_TOOL_NAME => [['NotEmpty']], |
| 42 | RdfLtiProviderRepository::LTI_TOOL_DEPLOYMENT_IDS => [['NotEmpty']], |
| 43 | RdfLtiProviderRepository::LTI_TOOL_AUDIENCE => [['NotEmpty']], |
| 44 | RdfLtiProviderRepository::LTI_TOOL_OIDC_LOGIN_INITATION_URL => [['NotEmpty'], ['Url']], |
| 45 | RdfLtiProviderRepository::LTI_TOOL_LAUNCH_URL => [['Url']], |
| 46 | RdfLtiProviderRepository::LTI_TOOL_JWKS_URL => [ |
| 47 | [ |
| 48 | 'Url', |
| 49 | ['allow_empty' => true], |
| 50 | ], |
| 51 | [ |
| 52 | 'AnyOf', |
| 53 | [ |
| 54 | 'reference' => |
| 55 | [RdfLtiProviderRepository::LTI_TOOL_PUBLIC_KEY,], |
| 56 | |
| 57 | ] |
| 58 | ], |
| 59 | ], |
| 60 | RdfLtiProviderRepository::LTI_TOOL_PUBLIC_KEY => [ |
| 61 | [ |
| 62 | 'AnyOf', |
| 63 | [ |
| 64 | 'reference' => |
| 65 | [RdfLtiProviderRepository::LTI_TOOL_JWKS_URL,], |
| 66 | |
| 67 | ] |
| 68 | ], |
| 69 | ] |
| 70 | ], |
| 71 | ]; |
| 72 | |
| 73 | public function getValidators(string $schema, string $field = null): array |
| 74 | { |
| 75 | $validators = self::VALIDATORS[$schema] ?? []; |
| 76 | return isset($validators[$field]) ? [$validators[$field]] : $validators; |
| 77 | } |
| 78 | } |