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

Commit a9f20f9

Browse files
BaranekDvyskocilpavel
authored andcommitted
Double qoutes changed to single quotes
1 parent 5affd88 commit a9f20f9

33 files changed

+297
-292
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file.
88
- is_null() changed to === null
99
- Using identity comparison instead of equality comparison
1010
- Removed checks in ifs that var is (not) null before empty(var) function (empty checks that itself)
11+
- Double quotes changed to single quotes
1112

1213
#### Fixed
1314
- Fixed wrong dictionary name in post.php

lib/AdapterLdap.php

Lines changed: 46 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,17 @@ public function getPerunUser($idpEntityId, $uids)
5454
# Build a LDAP query, we are searching for the user who has at least one of the uid
5555
$query = '';
5656
foreach ($uids as $uid) {
57-
$query .= "(eduPersonPrincipalNames=$uid)";
57+
$query .= '(eduPersonPrincipalNames=' . $uid . ')';
5858
}
5959

6060
if (empty($query)) {
6161
return null;
6262
}
6363

6464
$user = $this->connector->searchForEntity(
65-
"ou=People," . $this->ldapBase,
66-
"(|$query)",
67-
["perunUserId", "displayName", "cn", "givenName", "sn", "preferredMail", "mail"]
65+
'ou=People,' . $this->ldapBase,
66+
'(|' . $query . ')',
67+
['perunUserId', 'displayName', 'cn', 'givenName', 'sn', 'preferredMail', 'mail']
6868
);
6969
if ($user === null) {
7070
return $user;
@@ -84,9 +84,9 @@ public function getMemberGroups($user, $vo)
8484
{
8585
$userId = $user->getId();
8686
$userWithMembership = $this->connector->searchForEntity(
87-
"perunUserId=$userId,ou=People," . $this->ldapBase,
88-
"(objectClass=perunUser)",
89-
["perunUserId", "memberOf"]
87+
'perunUserId=' . $userId . ',ou=People,' . $this->ldapBase,
88+
'(objectClass=perunUser)',
89+
['perunUserId', 'memberOf']
9090
);
9191

9292
$groups = [];
@@ -98,8 +98,8 @@ public function getMemberGroups($user, $vo)
9898

9999
$group = $this->connector->searchForEntity(
100100
$groupDn,
101-
"(objectClass=perunGroup)",
102-
["perunGroupId", "cn", "perunUniqueGroupName", "perunVoId", "description"]
101+
'(objectClass=perunGroup)',
102+
['perunGroupId', 'cn', 'perunUniqueGroupName', 'perunVoId', 'description']
103103
);
104104
array_push(
105105
$groups,
@@ -120,25 +120,25 @@ public function getSpGroups($spEntityId)
120120
{
121121
$facility = $this->connector->searchForEntity(
122122
$this->ldapBase,
123-
"(&(objectClass=perunFacility)(entityID=$spEntityId))",
123+
'(&(objectClass=perunFacility)(entityID=' . $spEntityId . '))',
124124
['perunFacilityId']
125125
);
126126

127127
$id = $facility['perunFacilityId'][0];
128128
$resources = $this->connector->searchForEntities(
129129
$this->ldapBase,
130-
"(&(objectClass=perunResource)(perunFacilityDn=perunFacilityId=$id,$this->ldapBase))",
131-
["perunResourceId", "assignedGroupId", "perunVoId"]
130+
'(&(objectClass=perunResource)(perunFacilityDn=perunFacilityId=' . $id . ',' . $this->ldapBase . '))',
131+
['perunResourceId', 'assignedGroupId', 'perunVoId']
132132
);
133133

134134
$groups = [];
135135
foreach ($resources as $resource) {
136136
if (isset($resource['assignedGroupId'])) {
137137
foreach ($resource['assignedGroupId'] as $groupId) {
138138
$group = $this->connector->searchForEntity(
139-
"perunGroupId=$groupId,perunVoId=" . $resource['perunVoId'][0] . "," . $this->ldapBase,
140-
"(objectClass=perunGroup)",
141-
["perunGroupId", "cn", "perunUniqueGroupName", "perunVoId", "description"]
139+
'perunGroupId=' . $groupId . ',perunVoId=' . $resource['perunVoId'][0] . ',' . $this->ldapBase,
140+
'(objectClass=perunGroup)',
141+
['perunGroupId', 'cn', 'perunUniqueGroupName', 'perunVoId', 'description']
142142
);
143143
array_push(
144144
$groups,
@@ -162,13 +162,13 @@ public function getGroupByName($vo, $name)
162162
{
163163
$voId = $vo->getId();
164164
$group = $this->connector->searchForEntity(
165-
"perunVoId=$voId," . $this->ldapBase,
166-
"(&(objectClass=perunGroup)(perunUniqueGroupName=$name))",
167-
["perunGroupId", "cn", "perunUniqueGroupName", "perunVoId", "description"]
165+
'perunVoId=' . $voId . ',' . $this->ldapBase,
166+
'(&(objectClass=perunGroup)(perunUniqueGroupName=' . $name . '))',
167+
['perunGroupId', 'cn', 'perunUniqueGroupName', 'perunVoId', 'description']
168168
);
169169
if ($group === null) {
170170
throw new Exception(
171-
"Group with name: $name in VO: " . $vo->getName() . " does not exists in Perun LDAP."
171+
'Group with name: $name in VO: ' . $vo->getName() . ' does not exists in Perun LDAP.'
172172
);
173173
}
174174
return new Group(
@@ -184,12 +184,11 @@ public function getVoByShortName($voShortName)
184184
{
185185
$vo = $this->connector->searchForEntity(
186186
$this->ldapBase,
187-
"(&(objectClass=perunVo)(o=$voShortName))",
188-
["perunVoId", "o", "description"]
187+
'(&(objectClass=perunVo)(o=' . $voShortName . '))',
188+
['perunVoId', 'o', 'description']
189189
);
190-
191190
if ($vo === null) {
192-
throw new Exception("Vo with name: $vo does not exists in Perun LDAP.");
191+
throw new Exception('Vo with name: ' . $vo . ' does not exists in Perun LDAP.');
193192
}
194193

195194
return new Vo($vo['perunVoId'][0], $vo['description'][0], $vo['o'][0]);
@@ -199,12 +198,12 @@ public function getVoById($id)
199198
{
200199
$vo = $this->connector->searchForEntity(
201200
$this->ldapBase,
202-
"(&(objectClass=perunVo)(perunVoId=$id))",
203-
["o", "description"]
201+
'(&(objectClass=perunVo)(perunVoId=' . $id . '))',
202+
['o', 'description']
204203
);
205204

206205
if ($vo === null) {
207-
throw new Exception("Vo with id: $id does not exists in Perun LDAP.");
206+
throw new Exception('Vo with id: ' . $id . ' does not exists in Perun LDAP.');
208207
}
209208

210209
return new Vo($id, $vo['description'][0], $vo['o'][0]);
@@ -214,8 +213,8 @@ public function getUserAttributes($user, $attrNames)
214213
{
215214
$userId = $user->getId();
216215
$attributes = $this->connector->searchForEntity(
217-
"perunUserId=$userId,ou=People," . $this->ldapBase,
218-
"(objectClass=perunUser)",
216+
'perunUserId=' . $userId . ',ou=People,' . $this->ldapBase,
217+
'(objectClass=perunUser)',
219218
$attrNames
220219
);
221220
// user in ldap (simplified by LdapConnector method) is actually set of its attributes
@@ -229,31 +228,31 @@ public function getFacilitiesByEntityId($spEntityId)
229228

230229
public function getEntitylessAttribute($attrName)
231230
{
232-
throw new BadMethodCallException("NotImplementedException");
231+
throw new BadMethodCallException('NotImplementedException');
233232
// TODO: Implement getEntitylessAttribute() method.
234233
}
235234

236235
public function getVoAttributes($vo, $attrNames)
237236
{
238-
throw new BadMethodCallException("NotImplementedException");
237+
throw new BadMethodCallException('NotImplementedException');
239238
// TODO: Implement getVoAttribute() method.
240239
}
241240

242241
public function getFacilityAttribute($facility, $attrName)
243242
{
244-
throw new BadMethodCallException("NotImplementedException");
243+
throw new BadMethodCallException('NotImplementedException');
245244
// TODO: Implement getFacilityAttribute() method.
246245
}
247246

248247
public function searchFacilitiesByAttributeValue($attribute)
249248
{
250-
throw new BadMethodCallException("NotImplementedException");
249+
throw new BadMethodCallException('NotImplementedException');
251250
// TODO: Implement searchFacilitiesByAttributeValue() method.
252251
}
253252

254253
public function getFacilityAttributes($facility, $attrNames)
255254
{
256-
throw new BadMethodCallException("NotImplementedException");
255+
throw new BadMethodCallException('NotImplementedException');
257256
// TODO: Implement getFacilityAttributes() method.
258257
}
259258

@@ -281,34 +280,34 @@ public function getUsersGroupsOnFacility($spEntityId, $userId)
281280
{
282281
$facility = $this->connector->searchForEntity(
283282
$this->ldapBase,
284-
"(&(objectClass=perunFacility)(entityID=$spEntityId))",
283+
'(&(objectClass=perunFacility)(entityID=' . $spEntityId . '))',
285284
['perunFacilityId']
286285
);
287286

288287
$id = $facility['perunFacilityId'][0];
289288
$resources = $this->connector->searchForEntities(
290289
$this->ldapBase,
291-
"(&(objectClass=perunResource)(perunFacilityDn=perunFacilityId=$id,$this->ldapBase))",
292-
["perunResourceId"]
290+
'(&(objectClass=perunResource)(perunFacilityDn=perunFacilityId=' . $id . ',' . $this->ldapBase . '))',
291+
['perunResourceId']
293292
);
294-
Logger::debug("Resources - " . var_export($resources, true));
293+
Logger::debug('Resources - ' . var_export($resources, true));
295294

296295
if ($resources === null) {
297296
throw new Exception(
298-
"Service with spEntityId: " . $spEntityId . " hasn't assigned any resource."
297+
'Service with spEntityId: ' . $spEntityId . ' hasn\'t assigned any resource.'
299298
);
300299
}
301-
$resourcesString = "(|";
300+
$resourcesString = '(|';
302301
foreach ($resources as $resource) {
303-
$resourcesString .= "(assignedToResourceId=" . $resource['perunResourceId'][0] . ")";
302+
$resourcesString .= '(assignedToResourceId=' . $resource['perunResourceId'][0] . ')';
304303
}
305-
$resourcesString .= ")";
304+
$resourcesString .= ')';
306305

307306
$resultGroups = [];
308307
$groups = $this->connector->searchForEntities(
309308
$this->ldapBase,
310-
"(&(uniqueMember=perunUserId=" . $userId . ", ou=People," . $this->ldapBase . ")" . $resourcesString . ")",
311-
["perunGroupId", "cn", "perunUniqueGroupName", "perunVoId", "description"]
309+
'(&(uniqueMember=perunUserId=' . $userId . ', ou=People,' . $this->ldapBase . ')' . $resourcesString . ')',
310+
['perunGroupId', 'cn', 'perunUniqueGroupName', 'perunVoId', 'description']
312311
);
313312

314313
foreach ($groups as $group) {
@@ -324,17 +323,17 @@ public function getUsersGroupsOnFacility($spEntityId, $userId)
324323
);
325324
}
326325
$resultGroups = $this->removeDuplicateEntities($resultGroups);
327-
Logger::debug("Groups - " . var_export($resultGroups, true));
326+
Logger::debug('Groups - ' . var_export($resultGroups, true));
328327
return $resultGroups;
329328
}
330329

331330
public function getMemberStatusByUserAndVo($user, $vo)
332331
{
333332
$groupId = $this->connector->searchForEntity(
334333
$this->ldapBase,
335-
"(&(objectClass=perunGroup)(cn=members)(perunVoId=" . $vo->getId() .
336-
")(uniqueMember=perunUserId=" . $user->getId() . ", ou=People," . $this->ldapBase . "))",
337-
["perunGroupid"]
334+
'(&(objectClass=perunGroup)(cn=members)(perunVoId=' . $vo->getId() .
335+
')(uniqueMember=perunUserId=' . $user->getId() . ', ou=People,' . $this->ldapBase . '))',
336+
['perunGroupid']
338337
);
339338

340339
if (empty($groupId)) {

lib/AdapterRpc.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,8 @@ public function getMemberByUser($user, $vo)
377377
]);
378378
if ($member === null) {
379379
throw new Exception(
380-
"Member for User with name " . $user->getName() . " and Vo with shortName " .
381-
$vo->getShortName() . "does not exist in Perun!"
380+
'Member for User with name ' . $user->getName() . ' and Vo with shortName ' .
381+
$vo->getShortName() . 'does not exist in Perun!'
382382
);
383383
}
384384
return new Member($member['id'], $member['voId'], $member['status']);
@@ -443,31 +443,31 @@ public function getFacilityAttributes($facility, $attrNames)
443443
public function getUserExtSource($extSourceName, $extSourceLogin)
444444
{
445445
return $this->connector->get('usersManager', 'getUserExtSourceByExtLoginAndExtSourceName', [
446-
"extSourceName" => $extSourceName,
447-
"extSourceLogin" => $extSourceLogin
446+
'extSourceName' => $extSourceName,
447+
'extSourceLogin' => $extSourceLogin
448448
]);
449449
}
450450

451451
public function updateUserExtSourceLastAccess($userExtSource)
452452
{
453453
$this->connector->post('usersManager', 'updateUserExtSourceLastAccess', [
454-
"userExtSource" => $userExtSource
454+
'userExtSource' => $userExtSource
455455
]);
456456
}
457457

458458
public function getUserExtSourceAttributes($userExtSourceId, $attrNames)
459459
{
460460
return $this->connector->get('attributesManager', 'getAttributes', [
461-
"userExtSource" => $userExtSourceId,
462-
"attrNames" => $attrNames
461+
'userExtSource' => $userExtSourceId,
462+
'attrNames' => $attrNames
463463
]);
464464
}
465465

466466
public function setUserExtSourceAttributes($userExtSourceId, $attributes)
467467
{
468468
$this->connector->post('attributesManager', 'setAttributes', [
469-
"userExtSource" => $userExtSourceId,
470-
"attributes" => $attributes
469+
'userExtSource' => $userExtSourceId,
470+
'attributes' => $attributes
471471
]);
472472
}
473473

lib/Auth/Process/ForceAup.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,32 +55,32 @@ public function __construct($config, $reserved)
5555

5656
if (!isset($config[self::UID_ATTR])) {
5757
throw new Exception(
58-
"perun:ForceAup: missing mandatory configuration option '" . self::UID_ATTR . "'."
58+
'perun:ForceAup: missing mandatory configuration option \'' . self::UID_ATTR . '\'.'
5959
);
6060
}
6161
if (!isset($config[self::PERUN_AUPS_ATTR])) {
6262
throw new Exception(
63-
"perun:ForceAup: missing mandatory configuration option '" . self::PERUN_AUPS_ATTR . "'."
63+
'perun:ForceAup: missing mandatory configuration option \'' . self::PERUN_AUPS_ATTR . '\'.'
6464
);
6565
}
6666
if (!isset($config[self::PERUN_USER_AUP_ATTR])) {
6767
throw new Exception(
68-
"perun:ForceAup: missing mandatory configuration option '" . self::PERUN_USER_AUP_ATTR . "'."
68+
'perun:ForceAup: missing mandatory configuration option \'' . self::PERUN_USER_AUP_ATTR . '\'.'
6969
);
7070
}
7171
if (!isset($config[self::PERUN_VO_AUP_ATTR])) {
7272
throw new Exception(
73-
"perun:ForceAup: missing mandatory configuration option '" . self::PERUN_VO_AUP_ATTR . "'."
73+
'perun:ForceAup: missing mandatory configuration option \'' . self::PERUN_VO_AUP_ATTR . '\'.'
7474
);
7575
}
7676
if (!isset($config[self::PERUN_FACILITY_REQ_AUPS_ATTR])) {
7777
throw new Exception(
78-
"perun:ForceAup: missing mandatory configuration option '" . self::PERUN_FACILITY_REQ_AUPS_ATTR . "'."
78+
'perun:ForceAup: missing mandatory configuration option \'' . self::PERUN_FACILITY_REQ_AUPS_ATTR . '\'.'
7979
);
8080
}
8181
if (!isset($config[self::PERUN_FACILITY_VO_SHORT_NAMES])) {
8282
throw new Exception(
83-
"perun:ForceAup: missing mandatory configuration option '" . self::PERUN_FACILITY_REQ_AUPS_ATTR . "'."
83+
'perun:ForceAup: missing mandatory configuration option \'' . self::PERUN_FACILITY_REQ_AUPS_ATTR . '\'.'
8484
);
8585
}
8686
if (!isset($config[self::INTERFACE_PROPNAME])) {
@@ -111,9 +111,9 @@ public function process(&$request)
111111
$user = $request['perun']['user'];
112112
} else {
113113
throw new Exception(
114-
"perun:ForceAup: " .
115-
"missing mandatory field 'perun.user' in request." .
116-
"Hint: Did you configured PerunIdentity filter before this filter?"
114+
'perun:ForceAup: ' .
115+
'missing mandatory field \'perun.user\' in request.' .
116+
'Hint: Did you configured PerunIdentity filter before this filter?'
117117
);
118118
}
119119

@@ -206,11 +206,11 @@ public function process(&$request)
206206
}
207207
}
208208
} catch (\Exception $ex) {
209-
Logger::warning("perun:ForceAup - " . $ex->getMessage());
209+
Logger::warning('perun:ForceAup - ' . $ex->getMessage());
210210
$newAups = [];
211211
}
212212

213-
Logger::debug("perun:ForceAup - NewAups: " . print_r($newAups, true));
213+
Logger::debug('perun:ForceAup - NewAups: ' . print_r($newAups, true));
214214

215215
if (!empty($newAups)) {
216216
$request[self::UID_ATTR] = $this->uidAttr;

lib/Auth/Process/IdPAttribute.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function __construct($config, $reserved)
2424

2525
if (!isset($config['attrMap'])) {
2626
throw new Exception(
27-
"perun:IdPAttribute: missing mandatory configuration option 'attrMap'."
27+
'perun:IdPAttribute: missing mandatory configuration option \'attrMap\'.'
2828
);
2929
}
3030

0 commit comments

Comments
 (0)