|
11 | 11 | /** |
12 | 12 | * Class PerunEntitlement |
13 | 13 | * |
14 | | - * This filter joins eduPersonEntitlement, forwardedEduPersonEntitlement and resource capabilities |
| 14 | + * This filter joins eduPersonEntitlement, forwardedEduPersonEntitlement, resource capabilities |
| 15 | + * and facility capabilities |
15 | 16 | * |
16 | 17 | * @author Dominik Baránek <[email protected]> |
17 | 18 | * @author Pavel Vyskočil <[email protected]> |
@@ -88,12 +89,12 @@ public function process(&$request) |
88 | 89 | if ($this->releaseForwardedEntitlement) { |
89 | 90 | $forwardedEduPersonEntitlement = $this->getForwardedEduPersonEntitlement($request); |
90 | 91 | } |
91 | | - $resourceCapabilities = $this->getResourceCapabilities($request); |
| 92 | + $capabilities = $this->getCapabilities($request); |
92 | 93 |
|
93 | 94 | $request['Attributes'][$this->eduPersonEntitlement] = array_unique(array_merge( |
94 | 95 | $eduPersonEntitlement, |
95 | 96 | $forwardedEduPersonEntitlement, |
96 | | - $resourceCapabilities |
| 97 | + $capabilities |
97 | 98 | )); |
98 | 99 | } |
99 | 100 |
|
@@ -154,21 +155,18 @@ private function getForwardedEduPersonEntitlement(&$request) |
154 | 155 | return $forwardedEduPersonEntitlement; |
155 | 156 | } |
156 | 157 |
|
157 | | - private function getResourceCapabilities(&$request) |
| 158 | + private function getCapabilities(&$request) |
158 | 159 | { |
159 | | - if (isset($request['SPMetadata']['entityid'])) { |
160 | | - $spEntityId = $request['SPMetadata']['entityid']; |
161 | | - } else { |
162 | | - throw new Exception('perun:PerunEntitlement: Cannot find entityID of remote SP. ' . |
163 | | - 'hint: Do you have this filter in IdP context?'); |
164 | | - } |
| 160 | + $spEntityId = $this->getSpEntityId($request); |
| 161 | + $resourceCapabilities = $this->adapter->getResourceCapabilities($spEntityId, $request['perun']['groups']); |
| 162 | + $facilityCapabilities = $this->adapter->getFacilityCapabilities($spEntityId); |
165 | 163 |
|
166 | | - $capabilities = $this->adapter->getResourceCapabilities($spEntityId, $request['perun']['groups']); |
| 164 | + $capabilities = array_unique(array_merge($resourceCapabilities, $facilityCapabilities)); |
167 | 165 | $capabilitiesResult = []; |
168 | 166 |
|
169 | 167 | foreach ($capabilities as $capability) { |
170 | | - $resourceCapability = $this->capabilitiesWrapper($capability); |
171 | | - array_push($capabilitiesResult, $resourceCapability); |
| 168 | + $wrappedCapability = $this->capabilitiesWrapper($capability); |
| 169 | + array_push($capabilitiesResult, $wrappedCapability); |
172 | 170 | } |
173 | 171 |
|
174 | 172 | return $capabilitiesResult; |
@@ -243,4 +241,14 @@ private function encodeName($name) |
243 | 241 |
|
244 | 242 | return $name; |
245 | 243 | } |
| 244 | + |
| 245 | + private function getSpEntityId(&$request) |
| 246 | + { |
| 247 | + if (isset($request['SPMetadata']['entityid'])) { |
| 248 | + return $request['SPMetadata']['entityid']; |
| 249 | + } else { |
| 250 | + throw new Exception('perun:PerunEntitlement: Cannot find entityID of remote SP. ' . |
| 251 | + 'hint: Do you have this filter in IdP context?'); |
| 252 | + } |
| 253 | + } |
246 | 254 | } |
0 commit comments