1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace Limoncello\Auth\Authorization\PolicyDecision; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Copyright 2015-2019 [email protected] |
7
|
|
|
* |
8
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
9
|
|
|
* you may not use this file except in compliance with the License. |
10
|
|
|
* You may obtain a copy of the License at |
11
|
|
|
* |
12
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
13
|
|
|
* |
14
|
|
|
* Unless required by applicable law or agreed to in writing, software |
15
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
16
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
17
|
|
|
* See the License for the specific language governing permissions and |
18
|
|
|
* limitations under the License. |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
use Limoncello\Auth\Authorization\PolicyDecision\Algorithms\PoliciesOrSetsDenyOverrides; |
22
|
|
|
use Limoncello\Auth\Authorization\PolicyDecision\Algorithms\PoliciesOrSetsDenyUnlessPermit; |
23
|
|
|
use Limoncello\Auth\Authorization\PolicyDecision\Algorithms\PoliciesOrSetsFirstApplicable; |
24
|
|
|
use Limoncello\Auth\Authorization\PolicyDecision\Algorithms\PoliciesOrSetsPermitOverrides; |
25
|
|
|
use Limoncello\Auth\Authorization\PolicyDecision\Algorithms\PoliciesOrSetsPermitUnlessDeny; |
26
|
|
|
use Limoncello\Auth\Contracts\Authorization\PolicyAdministration\PolicyCombiningAlgorithmInterface; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @package Limoncello\Auth |
30
|
|
|
*/ |
31
|
|
|
abstract class PolicyAlgorithm |
32
|
|
|
{ |
33
|
|
|
/** |
34
|
3 |
|
* @return PolicyCombiningAlgorithmInterface |
35
|
|
|
*/ |
36
|
3 |
|
public static function firstApplicable(): PolicyCombiningAlgorithmInterface |
37
|
|
|
{ |
38
|
|
|
return new PoliciesOrSetsFirstApplicable(); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
9 |
|
* @return PolicyCombiningAlgorithmInterface |
43
|
|
|
*/ |
44
|
9 |
|
public static function denyOverrides(): PolicyCombiningAlgorithmInterface |
45
|
|
|
{ |
46
|
|
|
return new PoliciesOrSetsDenyOverrides(); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
1 |
|
* @return PolicyCombiningAlgorithmInterface |
51
|
|
|
*/ |
52
|
1 |
|
public static function permitOverrides(): PolicyCombiningAlgorithmInterface |
53
|
|
|
{ |
54
|
|
|
return new PoliciesOrSetsPermitOverrides(); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
2 |
|
* @return PolicyCombiningAlgorithmInterface |
59
|
|
|
*/ |
60
|
2 |
|
public static function denyUnlessPermit(): PolicyCombiningAlgorithmInterface |
61
|
|
|
{ |
62
|
|
|
return new PoliciesOrSetsDenyUnlessPermit(); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
1 |
|
* @return PolicyCombiningAlgorithmInterface |
67
|
|
|
*/ |
68
|
1 |
|
public static function permitUnlessDeny(): PolicyCombiningAlgorithmInterface |
69
|
|
|
{ |
70
|
|
|
return new PoliciesOrSetsPermitUnlessDeny(); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|