@@ -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