@@ -109,11 +109,18 @@ class OneLogin_Saml2_Auth
109109 private $ _errors = array ();
110110
111111 /**
112- * Reason of the last error .
112+ * Last error exception object .
113113 *
114- * @var string |null
114+ * @var Exception |null
115115 */
116- private $ _errorReason ;
116+ private $ _lastErrorException ;
117+
118+ /**
119+ * Last error.
120+ *
121+ * @var String|null
122+ */
123+ private $ _lastError ;
117124
118125 /**
119126 * Last AuthNRequest ID or LogoutRequest ID generated by this Service Provider
@@ -188,7 +195,7 @@ public function setStrict($value)
188195 public function processResponse ($ requestId = null )
189196 {
190197 $ this ->_errors = array ();
191- $ this ->_errorReason = null ;
198+ $ this ->_lastError = $ this -> _lastErrorException = null ;
192199 if (isset ($ _POST ) && isset ($ _POST ['SAMLResponse ' ])) {
193200 // AuthnResponse -- HTTP_POST Binding
194201 $ response = new OneLogin_Saml2_Response ($ this ->_settings , $ _POST ['SAMLResponse ' ]);
@@ -207,7 +214,8 @@ public function processResponse($requestId = null)
207214 $ this ->_lastAssertionNotOnOrAfter = $ response ->getAssertionNotOnOrAfter ();
208215 } else {
209216 $ this ->_errors [] = 'invalid_response ' ;
210- $ this ->_errorReason = $ response ->getError ();
217+ $ this ->_lastErrorException = $ response ->getErrorException ();
218+ $ this ->_lastError = $ response ->getError ();
211219 }
212220 } else {
213221 $ this ->_errors [] = 'invalid_binding ' ;
@@ -234,13 +242,15 @@ public function processResponse($requestId = null)
234242 public function processSLO ($ keepLocalSession = false , $ requestId = null , $ retrieveParametersFromServer = false , $ cbDeleteSession = null , $ stay = false )
235243 {
236244 $ this ->_errors = array ();
237- $ this ->_errorReason = null ;
245+ $ this ->_lastError = $ this -> _lastErrorException = null ;
238246 if (isset ($ _GET ) && isset ($ _GET ['SAMLResponse ' ])) {
239247 $ logoutResponse = new OneLogin_Saml2_LogoutResponse ($ this ->_settings , $ _GET ['SAMLResponse ' ]);
240248 $ this ->_lastResponse = $ logoutResponse ->getXML ();
241249 if (!$ logoutResponse ->isValid ($ requestId , $ retrieveParametersFromServer )) {
242250 $ this ->_errors [] = 'invalid_logout_response ' ;
243- $ this ->_errorReason = $ logoutResponse ->getError ();
251+ $ this ->_lastErrorException = $ logoutResponse ->getErrorException ();
252+ $ this ->_lastError = $ logoutResponse ->getError ();
253+
244254 } else if ($ logoutResponse ->getStatus () !== OneLogin_Saml2_Constants::STATUS_SUCCESS ) {
245255 $ this ->_errors [] = 'logout_not_success ' ;
246256 } else {
@@ -258,7 +268,8 @@ public function processSLO($keepLocalSession = false, $requestId = null, $retrie
258268 $ this ->_lastRequest = $ logoutRequest ->getXML ();
259269 if (!$ logoutRequest ->isValid ($ retrieveParametersFromServer )) {
260270 $ this ->_errors [] = 'invalid_logout_request ' ;
261- $ this ->_errorReason = $ logoutRequest ->getError ();
271+ $ this ->_lastErrorException = $ logoutRequest ->getErrorException ();
272+ $ this ->_lastError = $ logoutRequest ->getError ();
262273 } else {
263274 if (!$ keepLocalSession ) {
264275 if ($ cbDeleteSession === null ) {
@@ -407,7 +418,18 @@ public function getErrors()
407418 */
408419 public function getLastErrorReason ()
409420 {
410- return $ this ->_errorReason ;
421+ return $ this ->_lastError ;
422+ }
423+
424+
425+ /**
426+ * Returns the last error
427+ *
428+ * @return Exception Error
429+ */
430+ public function getLastErrorException ()
431+ {
432+ return $ this ->_lastErrorException ;
411433 }
412434
413435 /**
0 commit comments