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

Commit add657c

Browse files
committed
Use object Configuration for getting base module configuration
1 parent c1d5cb9 commit add657c

File tree

2 files changed

+21
-30
lines changed

2 files changed

+21
-30
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ All notable changes to this project will be documented in this file.
55
#### Added
66
- Added facility capabilities to PerunEntitlement
77

8+
#### Changed
9+
- Use object `Configuration` for getting base module configuration
10+
811
#### Fixed
912
- Fixed the width of showed tagged idps in case the count of idps is equal to (x * 3) + 1
1013

lib/Auth/Process/PerunEntitlement.php

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -43,42 +43,30 @@ public function __construct($config, $reserved)
4343
$modulePerunConfiguration = Configuration::getConfig(self::CONFIG_FILE_NAME);
4444
assert('is_array($config)');
4545

46-
if (!isset($config[self::EDU_PERSON_ENTITLEMENT])) {
47-
throw new Exception(
48-
'perun:PerunEntitlement: missing mandatory configuration option ' .
49-
self::EDU_PERSON_ENTITLEMENT . '.'
50-
);
51-
}
5246
$configuration = Configuration::loadFromArray($config);
5347

54-
$this->eduPersonEntitlement = $config[self::EDU_PERSON_ENTITLEMENT];
55-
48+
$this->eduPersonEntitlement = $configuration->getString(self::EDU_PERSON_ENTITLEMENT);
5649
$this->releaseForwardedEntitlement = $configuration->getBoolean(self::RELEASE_FORWARDED_ENTITLEMENT, true);
50+
$this->forwardedEduPersonEntitlement = $configuration->getString(
51+
self::FORWARDED_EDU_PERSON_ENTITLEMENT,
52+
$this->releaseForwardedEntitlement ? Configuration::REQUIRED_OPTION : ''
53+
);
5754

58-
if (!isset($config[self::FORWARDED_EDU_PERSON_ENTITLEMENT])) {
59-
throw new Exception(
60-
'perun:PerunEntitlement: missing mandatory configuration option ' .
61-
self::FORWARDED_EDU_PERSON_ENTITLEMENT . '.'
62-
);
63-
}
64-
$this->forwardedEduPersonEntitlement = $config[self::FORWARDED_EDU_PERSON_ENTITLEMENT];
65-
66-
$this->entitlementPrefix = $modulePerunConfiguration->getString(self::ENTITLEMENTPREFIX_ATTR, '');
67-
$this->entitlementAuthority = $modulePerunConfiguration->getString(self::ENTITLEMENTAUTHORITY_ATTR, '');
6855
$this->groupNameAARC = $modulePerunConfiguration->getBoolean(self::GROUPNAMEAARC_ATTR, false);
56+
$this->entitlementPrefix = $modulePerunConfiguration->getString(
57+
self::ENTITLEMENTPREFIX_ATTR,
58+
$this->groupNameAARC ? Configuration::REQUIRED_OPTION : ''
59+
);
60+
$this->entitlementAuthority = $modulePerunConfiguration->getString(
61+
self::ENTITLEMENTAUTHORITY_ATTR,
62+
$this->groupNameAARC ? Configuration::REQUIRED_OPTION : ''
63+
);
6964

70-
if ($this->groupNameAARC && (empty($this->entitlementAuthority) || empty($this->entitlementPrefix))) {
71-
throw new Exception(
72-
'perun:PerunEntitlement: \'groupNameAARC\' has been set, \'entitlementAuthority\' ' .
73-
'and \'entitlementPrefix\' options must be set as well'
74-
);
75-
}
76-
77-
if (!isset($config[self::INTERFACE_PROPNAME])) {
78-
$config[self::INTERFACE_PROPNAME] = Adapter::RPC;
79-
}
80-
81-
$this->interface = (string)$config[self::INTERFACE_PROPNAME];
65+
$this->interface = $configuration->getValueValidate(
66+
self::INTERFACE_PROPNAME,
67+
[Adapter::RPC, Adapter::LDAP],
68+
Adapter::RPC
69+
);
8270
$this->adapter = Adapter::getInstance($this->interface);
8371
}
8472

0 commit comments

Comments
 (0)