Skip to content
This repository was archived by the owner on Sep 19, 2022. It is now read-only.

Commit dfc7227

Browse files
Merge pull request #113 from vyskocilpavel/entitlement_fix
Using try{}catch{} to avoid to PerunException in PerunEntitlement.php
2 parents 8d73201 + 6307072 commit dfc7227

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file.
1111

1212
#### Fixed
1313
- Fixed the width of showed tagged idps in case the count of idps is equal to (x * 3) + 1
14+
- Using try{}catch{} to avoid to PerunException in PerunEntitlement.php
1415

1516
## [v3.8.0]
1617
#### Changed

lib/Auth/Process/PerunEntitlement.php

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,16 +132,25 @@ private function getForwardedEduPersonEntitlement(&$request)
132132

133133
if (!isset($request['perun']['user'])) {
134134
Logger::debug(
135-
'perun:PerunEntitlement: Object Perun User is not specified. => Skipping getting forwardedEntitlement.'
135+
'perun:PerunEntitlement: Object Perun User is not specified.' .
136+
'=> Skipping getting forwardedEntitlement.'
136137
);
137138
return $forwardedEduPersonEntitlement;
138139
}
139140

140141
$user = $request['perun']['user'];
141-
$forwardedEduPersonEntitlementMap = $this->adapter->getUserAttributes(
142-
$user,
143-
[$this->forwardedEduPersonEntitlement]
144-
);
142+
143+
try {
144+
$forwardedEduPersonEntitlementMap = $this->adapter->getUserAttributes(
145+
$user,
146+
[$this->forwardedEduPersonEntitlement]
147+
);
148+
} catch (Exception $exception) {
149+
Logger::error(
150+
'perun:PerunEntitlement: Exception ' . $exception->getMessage() .
151+
' was thrown in method \'getForwardedEduPersonEntitlement\'.'
152+
);
153+
}
145154

146155
if (!empty($forwardedEduPersonEntitlementMap)) {
147156
$forwardedEduPersonEntitlement = array_values($forwardedEduPersonEntitlementMap)[0];
@@ -152,12 +161,22 @@ private function getForwardedEduPersonEntitlement(&$request)
152161

153162
private function getCapabilities(&$request)
154163
{
164+
$resourceCapabilities = [];
165+
$facilityCapabilities = [];
166+
$capabilitiesResult = [];
167+
155168
$spEntityId = $this->getSpEntityId($request);
156-
$resourceCapabilities = $this->adapter->getResourceCapabilities($spEntityId, $request['perun']['groups']);
157-
$facilityCapabilities = $this->adapter->getFacilityCapabilities($spEntityId);
169+
try {
170+
$resourceCapabilities = $this->adapter->getResourceCapabilities($spEntityId, $request['perun']['groups']);
171+
$facilityCapabilities = $this->adapter->getFacilityCapabilities($spEntityId);
172+
} catch (Exception $exception) {
173+
Logger::error(
174+
'perun:PerunEntitlement: Exception ' . $exception->getMessage() .
175+
' was thrown in method \'getCapabilities\'.'
176+
);
177+
}
158178

159179
$capabilities = array_unique(array_merge($resourceCapabilities, $facilityCapabilities));
160-
$capabilitiesResult = [];
161180

162181
foreach ($capabilities as $capability) {
163182
$wrappedCapability = $this->capabilitiesWrapper($capability);

0 commit comments

Comments
 (0)