@@ -129,14 +129,16 @@ class OneLogin_Saml2_Auth
129
129
* (SAMLResponse, LogoutResponse). If the SAMLResponse was
130
130
* encrypted, by default tries to return the decrypted XML
131
131
*
132
- * @var string
132
+ * @var string|\DomDocument|null
133
133
*/
134
134
private $ _lastResponse ;
135
135
136
136
/**
137
137
* Initializes the SP SAML instance.
138
138
*
139
139
* @param array|object|null $oldSettings Setting data (You can provide a OneLogin_Saml_Settings, the settings object of the Saml folder implementation)
140
+ *
141
+ * @throws OneLogin_Saml2_Error
140
142
*/
141
143
public function __construct ($ oldSettings = null )
142
144
{
@@ -157,11 +159,12 @@ public function getSettings()
157
159
* Set the strict mode active/disable
158
160
*
159
161
* @param bool $value Strict parameter
162
+ *
160
163
* @throws OneLogin_Saml2_Error
161
164
*/
162
165
public function setStrict ($ value )
163
166
{
164
- if (! ( is_bool ($ value) )) {
167
+ if (!is_bool ($ value )) {
165
168
throw new OneLogin_Saml2_Error (
166
169
'Invalid value passed to setStrict() ' ,
167
170
OneLogin_Saml2_Error::SETTINGS_INVALID_SYNTAX
@@ -177,12 +180,13 @@ public function setStrict($value)
177
180
* @param string|null $requestId The ID of the AuthNRequest sent by this SP to the IdP
178
181
*
179
182
* @throws OneLogin_Saml2_Error
183
+ * @throws OneLogin_Saml2_ValidationError
180
184
*/
181
185
public function processResponse ($ requestId = null )
182
186
{
183
187
$ this ->_errors = array ();
184
188
$ this ->_errorReason = null ;
185
- if (isset ($ _POST ) && isset ( $ _POST ['SAMLResponse ' ])) {
189
+ if (isset ($ _POST ['SAMLResponse ' ])) {
186
190
// AuthnResponse -- HTTP_POST Binding
187
191
$ response = new OneLogin_Saml2_Response ($ this ->_settings , $ _POST ['SAMLResponse ' ]);
188
192
$ this ->_lastResponse = $ response ->getXMLDocument ();
@@ -215,21 +219,21 @@ public function processResponse($requestId = null)
215
219
/**
216
220
* Process the SAML Logout Response / Logout Request sent by the IdP.
217
221
*
218
- * @param bool $keepLocalSession When false will destroy the local session, otherwise will keep it
219
- * @param string|null $requestId The ID of the LogoutRequest sent by this SP to the IdP
220
- * @param bool $retrieveParametersFromServer
221
- * @param callable $cbDeleteSession
222
- * @param bool $stay True if we want to stay (returns the url string) False to redirect
222
+ * @param bool $keepLocalSession When false will destroy the local session, otherwise will keep it
223
+ * @param string|null $requestId The ID of the LogoutRequest sent by this SP to the IdP
224
+ * @param bool $retrieveParametersFromServer True if we want to use parameters from $_SERVER to validate the signature
225
+ * @param callable $cbDeleteSession Callback to be executed to delete session
226
+ * @param bool $stay True if we want to stay (returns the url string) False to redirect
223
227
*
224
- * @return string|void
228
+ * @return string|null
225
229
*
226
230
* @throws OneLogin_Saml2_Error
227
231
*/
228
232
public function processSLO ($ keepLocalSession = false , $ requestId = null , $ retrieveParametersFromServer = false , $ cbDeleteSession = null , $ stay = false )
229
233
{
230
234
$ this ->_errors = array ();
231
235
$ this ->_errorReason = null ;
232
- if (isset ($ _GET ) && isset ( $ _GET ['SAMLResponse ' ])) {
236
+ if (isset ($ _GET ['SAMLResponse ' ])) {
233
237
$ logoutResponse = new OneLogin_Saml2_LogoutResponse ($ this ->_settings , $ _GET ['SAMLResponse ' ]);
234
238
$ this ->_lastResponse = $ logoutResponse ->getXML ();
235
239
if (!$ logoutResponse ->isValid ($ requestId , $ retrieveParametersFromServer )) {
@@ -247,7 +251,7 @@ public function processSLO($keepLocalSession = false, $requestId = null, $retrie
247
251
}
248
252
}
249
253
}
250
- } else if (isset ($ _GET ) && isset ( $ _GET ['SAMLRequest ' ])) {
254
+ } else if (isset ($ _GET ['SAMLRequest ' ])) {
251
255
$ logoutRequest = new OneLogin_Saml2_LogoutRequest ($ this ->_settings , $ _GET ['SAMLRequest ' ]);
252
256
$ this ->_lastRequest = $ logoutRequest ->getXML ();
253
257
if (!$ logoutRequest ->isValid ($ retrieveParametersFromServer )) {
@@ -296,10 +300,13 @@ public function processSLO($keepLocalSession = false, $requestId = null, $retrie
296
300
* Redirects the user to the url past by parameter
297
301
* or to the url that we defined in our SSO Request.
298
302
*
299
- * @param string $url The target URL to redirect the user.
300
- * @param array $parameters Extra parameters to be passed as part of the url
301
- * @param bool $stay True if we want to stay (returns the url string) False to redirect
303
+ * @param string $url The target URL to redirect the user.
304
+ * @param array $parameters Extra parameters to be passed as part of the url
305
+ * @param bool $stay True if we want to stay (returns the url string) False to redirect
306
+ *
302
307
* @return string|null
308
+ *
309
+ * @throws OneLogin_Saml2_Error
303
310
*/
304
311
public function redirectTo ($ url = '' , $ parameters = array (), $ stay = false )
305
312
{
@@ -386,7 +393,7 @@ public function getSessionIndex()
386
393
/**
387
394
* Returns the SessionNotOnOrAfter
388
395
*
389
- * @return DateTime |null The SessionNotOnOrAfter of the assertion
396
+ * @return int |null The SessionNotOnOrAfter of the assertion
390
397
*/
391
398
public function getSessionExpiration ()
392
399
{
@@ -452,14 +459,16 @@ public function getAttributeWithFriendlyName($friendlyName)
452
459
/**
453
460
* Initiates the SSO process.
454
461
*
455
- * @param string|null $returnTo The target URL the user should be returned to after login.
456
- * @param array $parameters Extra parameters to be added to the GET
457
- * @param bool $forceAuthn When true the AuthNReuqest will set the ForceAuthn='true'
458
- * @param bool $isPassive When true the AuthNReuqest will set the Ispassive='true'
459
- * @param bool $stay True if we want to stay (returns the url string) False to redirect
460
- * @param bool $setNameIdPolicy When true the AuthNReuqest will set a nameIdPolicy element
462
+ * @param string|null $returnTo The target URL the user should be returned to after login.
463
+ * @param array $parameters Extra parameters to be added to the GET
464
+ * @param bool $forceAuthn When true the AuthNRequest will set the ForceAuthn='true'
465
+ * @param bool $isPassive When true the AuthNRequest will set the Ispassive='true'
466
+ * @param bool $stay True if we want to stay (returns the url string) False to redirect
467
+ * @param bool $setNameIdPolicy When true the AuthNRueqest will set a nameIdPolicy element
461
468
*
462
469
* @return string|null If $stay is True, it return a string with the SLO URL + LogoutRequest + parameters
470
+ *
471
+ * @throws OneLogin_Saml2_Error
463
472
*/
464
473
public function login ($ returnTo = null , $ parameters = array (), $ forceAuthn = false , $ isPassive = false , $ stay = false , $ setNameIdPolicy = true )
465
474
{
@@ -560,7 +569,7 @@ public function getSSOurl()
560
569
/**
561
570
* Gets the SLO url.
562
571
*
563
- * @return string The url of the Single Logout Service
572
+ * @return string|null The url of the Single Logout Service
564
573
*/
565
574
public function getSLOurl ()
566
575
{
@@ -591,7 +600,6 @@ public function getLastRequestID()
591
600
*
592
601
* @return string A base64 encoded signature
593
602
*
594
- * @throws Exception
595
603
* @throws OneLogin_Saml2_Error
596
604
*/
597
605
public function buildRequestSignature ($ samlRequest , $ relayState , $ signAlgorithm = XMLSecurityKey::RSA_SHA1 )
@@ -634,7 +642,6 @@ public function buildRequestSignature($samlRequest, $relayState, $signAlgorithm
634
642
*
635
643
* @return string A base64 encoded signature
636
644
*
637
- * @throws Exception
638
645
* @throws OneLogin_Saml2_Error
639
646
*/
640
647
public function buildResponseSignature ($ samlResponse , $ relayState , $ signAlgorithm = XMLSecurityKey::RSA_SHA1 )
0 commit comments