@@ -34,52 +34,39 @@ class PerunEntitlement extends ProcessingFilter
3434 private $ entitlementPrefix ;
3535 private $ entitlementAuthority ;
3636 private $ groupNameAARC ;
37- private $ interface ;
3837 private $ adapter ;
3938
4039 public function __construct ($ config , $ reserved )
4140 {
4241 parent ::__construct ($ config , $ reserved );
43- $ conf = Configuration::getConfig (self ::CONFIG_FILE_NAME );
42+ $ modulePerunConfiguration = Configuration::getConfig (self ::CONFIG_FILE_NAME );
4443 assert ('is_array($config) ' );
4544
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- }
5245 $ configuration = Configuration::loadFromArray ($ config );
5346
54- $ this ->eduPersonEntitlement = $ config [self ::EDU_PERSON_ENTITLEMENT ];
55-
47+ $ this ->eduPersonEntitlement = $ configuration ->getString (self ::EDU_PERSON_ENTITLEMENT );
5648 $ this ->releaseForwardedEntitlement = $ configuration ->getBoolean (self ::RELEASE_FORWARDED_ENTITLEMENT , true );
49+ $ this ->forwardedEduPersonEntitlement = $ configuration ->getString (
50+ self ::FORWARDED_EDU_PERSON_ENTITLEMENT ,
51+ $ this ->releaseForwardedEntitlement ? Configuration::REQUIRED_OPTION : ''
52+ );
5753
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 = $ conf ->getString (self ::ENTITLEMENTPREFIX_ATTR , '' );
67- $ this ->entitlementAuthority = $ conf ->getString (self ::ENTITLEMENTAUTHORITY_ATTR , '' );
68- $ this ->groupNameAARC = $ conf ->getBoolean (self ::GROUPNAMEAARC_ATTR , false );
69-
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- }
54+ $ this ->groupNameAARC = $ modulePerunConfiguration ->getBoolean (self ::GROUPNAMEAARC_ATTR , false );
55+ $ this ->entitlementPrefix = $ modulePerunConfiguration ->getString (
56+ self ::ENTITLEMENTPREFIX_ATTR ,
57+ $ this ->groupNameAARC ? Configuration::REQUIRED_OPTION : ''
58+ );
59+ $ this ->entitlementAuthority = $ modulePerunConfiguration ->getString (
60+ self ::ENTITLEMENTAUTHORITY_ATTR ,
61+ $ this ->groupNameAARC ? Configuration::REQUIRED_OPTION : ''
62+ );
8063
81- $ this ->interface = (string )$ config [self ::INTERFACE_PROPNAME ];
82- $ this ->adapter = Adapter::getInstance ($ this ->interface );
64+ $ interface = $ configuration ->getValueValidate (
65+ self ::INTERFACE_PROPNAME ,
66+ [Adapter::RPC , Adapter::LDAP ],
67+ Adapter::RPC
68+ );
69+ $ this ->adapter = Adapter::getInstance ($ interface );
8370 }
8471
8572 public function process (&$ request )
0 commit comments