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

Commit 45b2096

Browse files
committed
New methods for getting data from Perun LDAP and Perun RPC
* Added method getVoById for Perun LDAP and PErun RPC * Added methods getMemberByUser, and hasRegistrationForm to PerunRPC
1 parent a94e76d commit 45b2096

File tree

4 files changed

+63
-0
lines changed

4 files changed

+63
-0
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
- Added page with configurable table of SPs on Proxy
99
- Added new model Member
1010
- Added new model Resource
11+
- New methods for getting data from Perun LDAP and Perun RPC
1112

1213
[Changed]
1314
- Connectors methods are not static for now.

lib/Adapter.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ public abstract function getGroupByName($vo, $name);
5555
*/
5656
public abstract function getVoByShortName($voShortName);
5757

58+
/**
59+
* @param integer $id
60+
* @return sspmod_perun_model_Vo
61+
* @throws SimpleSAML_Error_Exception if does not exists
62+
*/
63+
public abstract function getVoById($id);
64+
5865
/**
5966
* @param sspmod_perun_model_User $user perun user
6067
* @param sspmod_perun_model_Vo $vo vo we are working with.

lib/AdapterLdap.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,19 @@ public function getVoByShortName($voShortName)
151151
return new sspmod_perun_model_Vo($vo['perunVoId'][0], $vo['description'][0], $vo['o'][0]);
152152
}
153153

154+
public function getVoById($id)
155+
{
156+
$vo = sspmod_perun_LdapConnector::searchForEntity($this->ldapBase,
157+
"(&(objectClass=perunVo)(perunVoId=$id))",
158+
array("o", "description")
159+
);
160+
if (is_null($vo)) {
161+
throw new SimpleSAML_Error_Exception("Vo with id: $id does not exists in Perun LDAP.");
162+
}
163+
164+
return new sspmod_perun_model_Vo($id, $vo['description'][0], $vo['o'][0]);
165+
}
166+
154167

155168
public function getUserAttributes($user, $attrNames)
156169
{

lib/AdapterRpc.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,14 @@ public function getVoByShortName($voShortName)
176176
return new sspmod_perun_model_Vo($vo['id'], $vo['name'], $vo['shortName']);
177177
}
178178

179+
public function getVoById($id)
180+
{
181+
$vo = $this->connector->get('vosManager', 'getVoById', array(
182+
'id' => $id,
183+
));
184+
185+
return new sspmod_perun_model_Vo($vo['id'], $vo['name'], $vo['shortName']);
186+
}
179187

180188
public function getUserAttributes($user, $attrNames)
181189
{
@@ -300,6 +308,40 @@ public function getFacilitiesByEntityId($spEntityId)
300308
return $facilities;
301309
}
302310

311+
/**
312+
* Returns member by User and Vo
313+
* @param sspmod_perun_model_User $user
314+
* @param sspmod_perun_model_Vo $vo
315+
* @return sspmod_perun_model_Member
316+
*/
317+
public function getMemberByUser($user, $vo) {
318+
$member = sspmod_perun_RpcConnector::get('membersManager', 'getMemberByUser', array(
319+
'user' => $user->getId(),
320+
'vo' => $vo->getId(),
321+
));
322+
if (is_null($member)) {
323+
throw new SimpleSAML_Error_Exception("Member for User with name " . $user->getName() . " and Vo with shortName " .
324+
$vo->getShortName() . "does not exist in Perun!");
325+
}
326+
return new sspmod_perun_model_Member($member['id'], $member['voId'], $member['status']);
327+
}
328+
329+
/**
330+
* Returns true if group has registration form, false otherwise
331+
* @param sspmod_perun_model_Group $group
332+
* @return bool
333+
*/
334+
public function hasRegistrationForm($group) {
335+
try {
336+
sspmod_perun_RpcConnector::get( 'registrarManager', 'getApplicationForm', array(
337+
'group' => $group->getId(),
338+
));
339+
return true;
340+
} catch (Exception $exception) {
341+
return false;
342+
}
343+
}
344+
303345
public function searchFacilitiesByAttributeValue($attribute)
304346
{
305347
$perunAttrs = $this->connector->post('searcher', 'getFacilities', array(

0 commit comments

Comments
 (0)