Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 6 |
|
0.00% |
0 / 6 |
CRAP | |
0.00% |
0 / 1 |
| AclProxy | |
0.00% |
0 / 6 |
|
0.00% |
0 / 6 |
42 | |
0.00% |
0 / 1 |
| getImplementation | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setImplementation | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| hasAccess | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| accessPossible | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| applyRule | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| revokeRule | |
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) 2013 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | namespace oat\tao\model\accessControl\func; |
| 23 | |
| 24 | use oat\tao\model\accessControl\AccessControl; |
| 25 | use common_ext_ExtensionsManager; |
| 26 | use common_Logger; |
| 27 | use oat\oatbox\user\User; |
| 28 | use oat\oatbox\service\ServiceManager; |
| 29 | |
| 30 | /** |
| 31 | * Proxy for the Acl Implementation |
| 32 | * |
| 33 | * @access public |
| 34 | * @author Joel Bout, <joel@taotesting.com> |
| 35 | * @package tao |
| 36 | |
| 37 | */ |
| 38 | class AclProxy implements AccessControl |
| 39 | { |
| 40 | public const SERVICE_ID = 'tao/FuncAccessControl'; |
| 41 | |
| 42 | public const CONFIG_KEY_IMPLEMENTATION = 'FuncAccessControl'; |
| 43 | |
| 44 | public const FALLBACK_IMPLEMENTATION_CLASS = 'oat\tao\model\accessControl\func\implementation\NoAccess'; |
| 45 | |
| 46 | /** |
| 47 | * @return FuncAccessControl |
| 48 | */ |
| 49 | protected static function getImplementation() |
| 50 | { |
| 51 | return ServiceManager::getServiceManager()->get(self::SERVICE_ID); |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Change the implementation of the access control permanently |
| 56 | * |
| 57 | * @param FuncAccessControl $implementation |
| 58 | * @deprecated |
| 59 | */ |
| 60 | public static function setImplementation(FuncAccessControl $implementation) |
| 61 | { |
| 62 | ServiceManager::getServiceManager()->register(self::SERVICE_ID, $implementation); |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * (non-PHPdoc) |
| 67 | * @see \oat\tao\model\accessControl\AccessControl::hasAccess() |
| 68 | */ |
| 69 | public function hasAccess(User $user, $controller, $action, $parameters) |
| 70 | { |
| 71 | return self::accessPossible($user, $controller, $action); |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * (non-PHPdoc) |
| 76 | * @see \oat\tao\model\accessControl\func\FuncAccessControl::accessPossible() |
| 77 | */ |
| 78 | public static function accessPossible(User $user, $controller, $action) |
| 79 | { |
| 80 | return self::getImplementation()->accessPossible($user, $controller, $action); |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * (non-PHPdoc) |
| 85 | * @see \oat\tao\model\accessControl\func\FuncAccessControl::applyRule() |
| 86 | */ |
| 87 | public static function applyRule(AccessRule $rule) |
| 88 | { |
| 89 | self::getImplementation()->applyRule($rule); |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * (non-PHPdoc) |
| 94 | * @see \oat\tao\model\accessControl\func\FuncAccessControl::revokeRule() |
| 95 | */ |
| 96 | public static function revokeRule(AccessRule $rule) |
| 97 | { |
| 98 | self::getImplementation()->revokeRule($rule); |
| 99 | } |
| 100 | } |