1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Copyright 2018 SURFnet B.V. |
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
|
|
|
namespace Surfnet\StepupMiddleware\ApiBundle\Authorization\Value; |
20
|
|
|
|
21
|
|
|
use Surfnet\Stepup\Identity\Value\IdentityId; |
22
|
|
|
use Surfnet\Stepup\Identity\Value\Institution; |
23
|
|
|
|
24
|
|
|
class InstitutionAuthorizationContext implements InstitutionAuthorizationContextInterface |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* @var Institution |
28
|
|
|
*/ |
29
|
|
|
private $actorInstitution; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var InstitutionRoleSet |
33
|
|
|
*/ |
34
|
|
|
private $roleRequirements; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var IdentityId|null |
38
|
|
|
*/ |
39
|
|
|
private $identityId; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var bool |
43
|
|
|
*/ |
44
|
|
|
private $isSraa; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* AuthorizationContext constructor. |
48
|
|
|
* @param Institution $actorInstitution |
49
|
|
|
* @param InstitutionRoleSetInterface $roleRequirements |
50
|
|
|
* @param IdentityId|null $identityId |
51
|
|
|
* @param bool $isSraa describes if the actor is SRAA or not. Default: false |
52
|
|
|
*/ |
53
|
|
|
public function __construct( |
54
|
|
|
Institution $actorInstitution, |
55
|
|
|
InstitutionRoleSetInterface $roleRequirements, |
56
|
|
|
IdentityId $identityId, |
57
|
|
|
$isSraa = false |
58
|
|
|
) { |
59
|
|
|
$this->actorInstitution = $actorInstitution; |
60
|
|
|
$this->roleRequirements = $roleRequirements; |
|
|
|
|
61
|
|
|
$this->identityId = $identityId; |
62
|
|
|
$this->isSraa = $isSraa; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @return Institution |
67
|
|
|
*/ |
68
|
|
|
public function getActorInstitution() |
69
|
|
|
{ |
70
|
|
|
return $this->actorInstitution; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @return InstitutionRoleSet |
75
|
|
|
*/ |
76
|
|
|
public function getRoleRequirements() |
77
|
|
|
{ |
78
|
|
|
return $this->roleRequirements; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @return IdentityId |
|
|
|
|
83
|
|
|
*/ |
84
|
|
|
public function getIdentityId() |
85
|
|
|
{ |
86
|
|
|
return $this->identityId; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @return bool |
91
|
|
|
*/ |
92
|
|
|
public function isActorSraa() |
93
|
|
|
{ |
94
|
|
|
return $this->isSraa; |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
|
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.
Either this assignment is in error or an instanceof check should be added for that assignment.