|
1
|
|
|
<?php namespace Limoncello\Tests\Auth\Authorization\PolicyEnforcement\Data; |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Copyright 2015-2017 [email protected] |
|
5
|
|
|
* |
|
6
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
7
|
|
|
* you may not use this file except in compliance with the License. |
|
8
|
|
|
* You may obtain a copy of the License at |
|
9
|
|
|
* |
|
10
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
|
11
|
|
|
* |
|
12
|
|
|
* Unless required by applicable law or agreed to in writing, software |
|
13
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
|
14
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15
|
|
|
* See the License for the specific language governing permissions and |
|
16
|
|
|
* limitations under the License. |
|
17
|
|
|
*/ |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @package Limoncello\Tests\Auth |
|
21
|
|
|
*/ |
|
22
|
|
|
use Limoncello\Auth\Authorization\PolicyDecision\Algorithms\BaseRuleAlgorithm; |
|
23
|
|
|
use Limoncello\Auth\Authorization\PolicyDecision\Algorithms\DefaultTargetSerializeTrait; |
|
24
|
|
|
use Limoncello\Auth\Contracts\Authorization\PolicyAdministration\EvaluationEnum; |
|
25
|
|
|
use Limoncello\Auth\Contracts\Authorization\PolicyInformation\ContextInterface; |
|
26
|
|
|
use Psr\Log\LoggerInterface; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @package Limoncello\Auth |
|
30
|
|
|
*/ |
|
31
|
|
|
class TestRuleAlgorithm extends BaseRuleAlgorithm |
|
32
|
|
|
{ |
|
33
|
|
|
use DefaultTargetSerializeTrait; |
|
34
|
|
|
|
|
35
|
|
|
/** @inheritdoc */ |
|
36
|
|
|
const METHOD = [self::class, 'evaluate']; |
|
37
|
|
|
|
|
38
|
|
|
public static $result = EvaluationEnum::NOT_APPLICABLE; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @param ContextInterface $context |
|
42
|
|
|
* @param array $optimizedTargets |
|
43
|
|
|
* @param array $encodedRules |
|
44
|
|
|
* @param LoggerInterface|null $logger |
|
45
|
|
|
* |
|
46
|
|
|
* @return array |
|
47
|
|
|
*/ |
|
48
|
|
|
public static function evaluate( |
|
49
|
|
|
ContextInterface $context, |
|
50
|
|
|
array $optimizedTargets, |
|
51
|
|
|
array $encodedRules, |
|
52
|
|
|
LoggerInterface $logger = null |
|
53
|
|
|
) { |
|
54
|
|
|
$context && $optimizedTargets && $encodedRules && $logger ?: null; |
|
55
|
|
|
|
|
56
|
|
|
return static::packEvaluationResult(static::$result); |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|