@@ -23,11 +23,11 @@ class IsCesnetEligible extends ProcessingFilter
23
23
const CONFIG_FILE_NAME = 'module_cesnet_IsCesnetEligible.php ' ;
24
24
const ORGANIZATION_LDAP_BASE = 'ou=Organizations,o=eduID.cz,o=apps,dc=cesnet,dc=cz ' ;
25
25
26
- const HOSTEL_ENTITY_ID = " https://idp.hostel.eduid.cz/idp/shibboleth " ;
26
+ const HOSTEL_ENTITY_ID = ' https://idp.hostel.eduid.cz/idp/shibboleth ' ;
27
27
28
- const INTERFACE_PROPNAME = " interface " ;
29
- const ATTR_NAME = " attrName " ;
30
- const RPC_ATTRIBUTE_NAME = " RPC.attributeName " ;
28
+ const INTERFACE_PROPNAME = ' interface ' ;
29
+ const ATTR_NAME = ' attrName ' ;
30
+ const RPC_ATTRIBUTE_NAME = ' RPC.attributeName ' ;
31
31
const LDAP_ATTRIBUTE_NAME = 'LDAP.attributeName ' ;
32
32
const DEFAULT_ATTR_NAME = 'isCesnetEligibleLastSeen ' ;
33
33
const LDAP = 'LDAP ' ;
@@ -65,8 +65,8 @@ public function __construct($config, $reserved)
65
65
66
66
if (!isset ($ config [self ::RPC_ATTRIBUTE_NAME ]) || empty ($ config [self ::RPC_ATTRIBUTE_NAME ])) {
67
67
throw new Exception (
68
- " cesnet:IsCesnetEligible - missing mandatory configuration option ' " .
69
- self ::RPC_ATTRIBUTE_NAME . " '. "
68
+ ' cesnet:IsCesnetEligible - missing mandatory configuration option \'' .
69
+ self ::RPC_ATTRIBUTE_NAME . '\' . '
70
70
);
71
71
}
72
72
@@ -86,8 +86,8 @@ public function __construct($config, $reserved)
86
86
$ this ->ldapAdapter = new AdapterLdap ();
87
87
} else {
88
88
Logger::warning (
89
- " cesnet:IsCesnetEligible - One of " . self ::INTERFACE_PROPNAME . self ::LDAP_ATTRIBUTE_NAME .
90
- " is missing or empty. RPC interface will be used "
89
+ ' cesnet:IsCesnetEligible - One of ' . self ::INTERFACE_PROPNAME . self ::LDAP_ATTRIBUTE_NAME .
90
+ ' is missing or empty. RPC interface will be used '
91
91
);
92
92
}
93
93
}
@@ -100,8 +100,8 @@ public function process(&$request)
100
100
$ user = $ request ['perun ' ]['user ' ];
101
101
} else {
102
102
Logger::debug (
103
- " cesnet:IsCesnetEligible - " .
104
- " Request doesn't contain User, so attribute 'isCesnetEligible' won't be stored. "
103
+ ' cesnet:IsCesnetEligible - ' .
104
+ ' Request doesn \ 't contain User, so attribute \ 'isCesnetEligible \ ' won \ 't be stored. '
105
105
);
106
106
$ user = null ;
107
107
}
@@ -113,17 +113,18 @@ public function process(&$request)
113
113
= $ request ['Attributes ' ]['eduPersonScopedAffiliation ' ];
114
114
} else {
115
115
Logger::error (
116
- "cesnet:IsCesnetEligible - Attribute with name 'eduPersonScopedAffiliation' did not received from IdP! "
116
+ 'cesnet:IsCesnetEligible - ' .
117
+ 'Attribute with name \'eduPersonScopedAffiliation \' did not received from IdP! '
117
118
);
118
119
}
119
120
120
121
$ isHostelVerified = false ;
121
122
if ($ request ['saml:sp:IdP ' ] === self ::HOSTEL_ENTITY_ID &&
122
123
isset ($ request ['Attributes ' ]['loa ' ])
123
- && $ request ['Attributes ' ]['loa ' ][0 ] == 2
124
+ && $ request ['Attributes ' ]['loa ' ][0 ] === 2
124
125
) {
125
126
$ isHostelVerified = true ;
126
- Logger::debug (" cesnet:IsCesnetEligible - The user was verified by Hostel. " );
127
+ Logger::debug (' cesnet:IsCesnetEligible - The user was verified by Hostel. ' );
127
128
}
128
129
129
130
try {
@@ -144,7 +145,7 @@ public function process(&$request)
144
145
}
145
146
146
147
if ($ isHostelVerified || (!empty ($ this ->eduPersonScopedAffiliation ) && $ this ->isCesnetEligible ())) {
147
- $ this ->cesnetEligibleLastSeenValue = date (" Y-m-d H:i:s " );
148
+ $ this ->cesnetEligibleLastSeenValue = date (' Y-m-d H:i:s ' );
148
149
149
150
if (!empty ($ user )) {
150
151
if ($ this ->cesnetEligibleLastSeenAttribute === null ) {
@@ -163,19 +164,19 @@ public function process(&$request)
163
164
);
164
165
165
166
Logger::debug (
166
- " cesnet:IsCesnetEligible - Value of attribute isCesnetEligibleLastSeen was updated to " .
167
- $ this ->cesnetEligibleLastSeenValue . " in Perun system. "
167
+ ' cesnet:IsCesnetEligible - Value of attribute isCesnetEligibleLastSeen was updated to ' .
168
+ $ this ->cesnetEligibleLastSeenValue . ' in Perun system. '
168
169
);
169
170
}
170
171
}
171
172
} catch (Exception $ ex ) {
172
- Logger::warning (" cesnet:IsCesnetEligible - " . $ ex ->getMessage ());
173
+ Logger::warning (' cesnet:IsCesnetEligible - ' . $ ex ->getMessage ());
173
174
}
174
175
175
176
if ($ this ->cesnetEligibleLastSeenValue !== null ) {
176
177
$ request ['Attributes ' ][$ this ->returnAttrName ] = [$ this ->cesnetEligibleLastSeenValue ];
177
178
Logger::debug (
178
- " cesnet:IsCesnetEligible - Attribute " . $ this ->returnAttrName . " was set to value " .
179
+ ' cesnet:IsCesnetEligible - Attribute ' . $ this ->returnAttrName . ' was set to value ' .
179
180
$ this ->cesnetEligibleLastSeenValue
180
181
);
181
182
}
@@ -190,8 +191,8 @@ private function isCesnetEligible()
190
191
$ allowedAffiliations
191
192
= $ this ->getAllowedAffiliations ($ this ->idpEntityId );
192
193
foreach ($ this ->eduPersonScopedAffiliation as $ userAffiliation ) {
193
- $ userAffiliationWithoutScope = explode (" @ " , $ userAffiliation )[0 ];
194
- if (! is_null ( $ userAffiliationWithoutScope) &&
194
+ $ userAffiliationWithoutScope = explode (' @ ' , $ userAffiliation )[0 ];
195
+ if ($ userAffiliationWithoutScope !== null &&
195
196
!empty ($ userAffiliationWithoutScope ) &&
196
197
in_array ($ userAffiliationWithoutScope , $ allowedAffiliations )
197
198
) {
@@ -218,15 +219,15 @@ private function getAllowedAffiliations($idpEntityId)
218
219
)['cesnetcustomeraffiliation ' ];
219
220
220
221
if (empty ($ affiliations )) {
221
- Logger::debug (" cesnet:IsCesnetEligible - Received empty response from LDAP, entityId "
222
- . $ idpEntityId . " was probably not found. " );
222
+ Logger::debug (' cesnet:IsCesnetEligible - Received empty response from LDAP, entityId '
223
+ . $ idpEntityId . ' was probably not found. ' );
223
224
} else {
224
225
foreach ($ affiliations as $ affiliation ) {
225
226
array_push ($ allowedAffiliations , $ affiliation );
226
227
}
227
228
}
228
229
} catch (Exception $ ex ) {
229
- Logger::warning (" cesnet:IsCesnetEligible - Unable to connect to LDAP! " );
230
+ Logger::warning (' cesnet:IsCesnetEligible - Unable to connect to LDAP! ' );
230
231
}
231
232
232
233
return $ allowedAffiliations ;
0 commit comments