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

Commit 892c8b6

Browse files
committed
Added properties to Group model
Added properties voId and uniqueName for Group model
1 parent 4051a72 commit 892c8b6

File tree

5 files changed

+63
-14
lines changed

5 files changed

+63
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file.
1010
[Changed]
1111
- Connectors methods are not static for now.
1212
- Added constructors to Adapters, which allows specified config file for each connections.
13+
- New properties voId and uniqueName in Group model
1314

1415
## [v1.0.0]
1516

lib/AdapterLdap.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function getMemberGroups($user, $vo)
9393
"(objectClass=perunGroup)",
9494
array("perunGroupId", "cn", "perunUniqueGroupName", "perunVoId", "description")
9595
);
96-
array_push($groups, new sspmod_perun_model_Group($group['perunGroupId'][0], $group['perunUniqueGroupName'][0], $group['description'][0]));
96+
array_push($groups, new sspmod_perun_model_Group($group['perunGroupId'][0], $group['perunVoId'][0], $group['cn'][0], $group['perunUniqueGroupName'][0], $group['description'][0]));
9797
}
9898

9999
return $groups;
@@ -114,7 +114,7 @@ public function getSpGroups($spEntityId, $vo)
114114
"(objectClass=perunGroup)",
115115
array("perunGroupId", "cn", "perunUniqueGroupName", "perunVoId", "description")
116116
);
117-
array_push($groups, new sspmod_perun_model_Group($group['perunGroupId'][0], $group['perunUniqueGroupName'][0], $group['description'][0]));
117+
array_push($groups, new sspmod_perun_model_Group($group['perunGroupId'][0], $group['perunVoId'][0], $group['cn'], $group['perunUniqueGroupName'][0], $group['description'][0]));
118118
}
119119
}
120120

@@ -134,8 +134,7 @@ public function getGroupByName($vo, $name)
134134
if (is_null($group)) {
135135
throw new SimpleSAML_Error_Exception("Group with name: $name in VO: ".$vo->getName()." does not exists in Perun LDAP.");
136136
}
137-
$groupName = substr($group['perunUniqueGroupName'][0], strlen($vo->getShortName().':'));
138-
return new sspmod_perun_model_Group($group['perunGroupId'][0], $groupName, $group['description'][0]);
137+
return new sspmod_perun_model_Group($group['perunGroupId'][0], $group['perunVoId'][0], $group['cn'][0], $group['perunUniqueGroupName'][0], $group['description'][0]);
139138
}
140139

141140

@@ -223,8 +222,7 @@ public function getUsersGroupsOnFacility($spEntityId, $userId)
223222
);
224223

225224
foreach ($groups as $group) {
226-
array_push($resultGroups, new sspmod_perun_model_Group($group['perunGroupId'][0], $group['perunUniqueGroupName'][0], $group['description'][0]));
227-
225+
array_push($resultGroups, new sspmod_perun_model_Group($group['perunGroupId'][0], $group['perunVoId'][0], $group['cn'][0], $group['perunUniqueGroupName'][0], $group['description'][0]));
228226
}
229227
$resultGroups = $this->removeDuplicateEntities($resultGroups);
230228
SimpleSAML\Logger::debug("Groups - ".var_export($resultGroups, true));

lib/AdapterRpc.php

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,16 @@ public function getMemberGroups($user, $vo)
8888

8989
$convertedGroups = array();
9090
foreach ($memberGroups as $group) {
91-
array_push($convertedGroups, new sspmod_perun_model_Group($group['id'], $group['name'], $group['description']));
91+
try {
92+
$attr = $this->connector->get('attributesManager', 'getAttribute', array(
93+
'group' => $group['id'],
94+
'attributeName' => 'urn:perun:group:attribute-def:virt:voShortName'
95+
));
96+
$uniqueName = $attr['value'] . ":" . $group['name'];
97+
array_push($convertedGroups, new sspmod_perun_model_Group($group['id'], $group['voId'], $group['name'], $uniqueName, $group['description']));
98+
} catch (sspmod_perun_Exception $e) {
99+
continue;
100+
}
92101
}
93102

94103
return $convertedGroups;
@@ -127,7 +136,12 @@ public function getSpGroups($spEntityId, $vo)
127136
));
128137
$convertedGroups = array();
129138
foreach ($groups as $group) {
130-
array_push($convertedGroups, new sspmod_perun_model_Group($group['id'], $group['name'], $group['description']));
139+
$attr = $this->connector->get('attributesManager', 'getAttribute', array(
140+
'group' => $group['id'],
141+
'attributeName' => 'urn:perun:group:attribute-def:virt:voShortName'
142+
));
143+
$uniqueName = $attr['value'] . ":" . $group['name'];
144+
array_push($convertedGroups, new sspmod_perun_model_Group($group['id'], $group['voId'], $group['name'], $uniqueName, $group['description']));
131145
}
132146
$spGroups = array_merge($spGroups, $convertedGroups);
133147
}
@@ -144,8 +158,12 @@ public function getGroupByName($vo, $name)
144158
'vo' => $vo->getId(),
145159
'name' => $name,
146160
));
147-
148-
return new sspmod_perun_model_Group($group['id'], $group['name'], $group['description']);
161+
$attr = $this->connector->get('attributesManager', 'getAttribute', array(
162+
'group' => $group['id'],
163+
'attributeName' => 'urn:perun:group:attribute-def:virt:voShortName'
164+
));
165+
$uniqueName = $attr['value'] . ":" . $group['name'];
166+
return new sspmod_perun_model_Group($group['id'], $group['voId'], $group['name'], $uniqueName, $group['description']);
149167
}
150168

151169

@@ -255,7 +273,12 @@ public function getUsersGroupsOnFacility($spEntityId, $userId)
255273
'member' => $member['id'],
256274
));
257275
foreach ($groups as $group) {
258-
array_push($allGroups, new sspmod_perun_model_Group($group['id'], $group['name'], $group['description']));
276+
$attr = $this->connector->get('attributesManager', 'getAttribute', array(
277+
'group' => $group['id'],
278+
'attributeName' => 'urn:perun:group:attribute-def:virt:voShortName'
279+
));
280+
$uniqueName = $attr['value'] . ":" . $group['name'];
281+
array_push($allGroups, new sspmod_perun_model_Group($group['id'], $group['voId'], $group['name'], $uniqueName, $group['description']));
259282
}
260283
}
261284
}

lib/Auth/Process/PerunGroups.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ public function process(&$request)
7777
throw new SimpleSAML_Error_Exception("perun:PerunGroups: missing mandatory configuration options 'groupNameAuthority' or 'groupNamePrefix'.");
7878
}
7979

80-
$groupName = $this->groupNamePrefix . rawurlencode($group->getName()) . '#' . $this->groupNameAuthority;
80+
$groupName = $this->groupNamePrefix . rawurlencode($group->getUniqueName()) . '#' . $this->groupNameAuthority;
8181
} else {
82-
$groupName = $this->mapGroupName($request, $group->getName());
82+
$groupName = $this->mapGroupName($request, $group->getUniqueName());
8383
}
8484
array_push($request['Attributes'][$this->attrName], $groupName);
8585
}

lib/model/Group.php

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,44 @@
66
class sspmod_perun_model_Group implements sspmod_perun_model_HasId
77
{
88
private $id;
9+
private $voId;
910
private $name;
11+
private $uniqueName;
1012
private $description;
1113

1214
/**
1315
* sspmod_perun_model_Group constructor.
1416
* @param $id
17+
* @param $voId
1518
* @param $name
19+
* @param $uniqueName
1620
* @param $description
1721
*/
18-
public function __construct($id, $name, $description)
22+
public function __construct($id, $voId, $name, $uniqueName, $description)
1923
{
2024
$this->id = $id;
25+
$this->voId = $voId;
2126
$this->name = $name;
27+
$this->uniqueName = $uniqueName;
2228
$this->description = $description;
2329
}
2430

31+
2532
public function getId()
2633
{
2734
return $this->id;
2835
}
2936

37+
/**
38+
* @return int
39+
*/
40+
public function getVoId()
41+
{
42+
return $this->voId;
43+
}
44+
45+
46+
3047
/**
3148
* @return string
3249
*/
@@ -35,6 +52,16 @@ public function getName()
3552
return $this->name;
3653
}
3754

55+
/**
56+
* @return string
57+
*/
58+
public function getUniqueName()
59+
{
60+
return $this->uniqueName;
61+
}
62+
63+
64+
3865
/**
3966
* @return string
4067
*/

0 commit comments

Comments
 (0)