diff --git a/docs/simplesamlphp-errorhandling.txt b/docs/simplesamlphp-errorhandling.txt index 6d705f69eda93c5a86a450ccfb3e9b0e6ba2981b..dce9b70ba0296d6ffe608611ae6be9caee3feb80 100644 --- a/docs/simplesamlphp-errorhandling.txt +++ b/docs/simplesamlphp-errorhandling.txt @@ -68,11 +68,11 @@ For example, the `SimpleSAML_Error_NoPassive` exception should be converted to a * The second-level status code should be `urn:oasis:names:tc:SAML:2.0:status:NoPassive`. * The status message should contain the cause of the exception. -The `sspmod_saml2_Error` class represents SAML 2 errors. +The `sspmod_saml_Error` class represents SAML 2 errors. It represents a SAML 2 status code with three elements: the top-level status code, the second-level status code and the status message. The second-level status code and the status message is optional, and can be `NULL`. -The `sspmod_saml2_Error` class contains a helper function named `fromException`. +The `sspmod_saml_Error` class contains a helper function named `fromException`. The `fromException()` function is used by `www/saml2/idp/SSOService.php` to return SAML 2 errors to the SP. The function contains a list which maps various exceptions to specific SAML 2 errors. If it is unable to convert the exception, it will return a generic SAML 2 error describing the original exception in its status message. @@ -94,7 +94,7 @@ Converting SAML 2 errors to normal exceptions --------------------------------------------- On the SP side, we want to convert SAML 2 errors to simpleSAMLphp exceptions again. -This is handled by the `toException()` method in `sspmod_saml2_Error`. +This is handled by the `toException()` method in `sspmod_saml_Error`. The assertion consumer script of the SAML 2 authentication source (`modules/saml2/sp/acs.php`) uses this method. The result is that generic exceptions are thrown from that authentication source. diff --git a/modules/saml2/lib/Error.php b/modules/saml/lib/Error.php similarity index 95% rename from modules/saml2/lib/Error.php rename to modules/saml/lib/Error.php index 1c9e11ccc05b8e7d57c76a4420cb350d94289c63..6a4989d011ed976ab9ccdf5e0032e124f5b3cf7e 100644 --- a/modules/saml2/lib/Error.php +++ b/modules/saml/lib/Error.php @@ -6,7 +6,7 @@ * @package simpleSAMLphp * @version $Id$ */ -class sspmod_saml2_Error extends SimpleSAML_Error_Exception { +class sspmod_saml_Error extends SimpleSAML_Error_Exception { /** * The top-level status code. @@ -97,11 +97,11 @@ class sspmod_saml2_Error extends SimpleSAML_Error_Exception { * status codes from an arbitrary exception. * * @param Exception $exception The original exception. - * @return sspmod_saml2_Error The new exception. + * @return sspmod_saml_Error The new exception. */ public static function fromException(Exception $exception) { - if ($exception instanceof sspmod_saml2_Error) { + if ($exception instanceof sspmod_saml_Error) { /* Return the original exception unchanged. */ return $exception; @@ -140,7 +140,7 @@ class sspmod_saml2_Error extends SimpleSAML_Error_Exception { * If it is unable to create a more specific exception, it will return the current * object. * - * @see sspmod_saml2_Error::fromException() + * @see sspmod_saml_Error::fromException() * * @return SimpleSAML_Error_Exception An exception representing this error. */ diff --git a/modules/saml/lib/IdP/SAML2.php b/modules/saml/lib/IdP/SAML2.php index 611a4d88e6efa36be6f27ae4ff346482f551e629..a260a8e10fe44f96b3a33ae5d8bd19a7058dd9d2 100644 --- a/modules/saml/lib/IdP/SAML2.php +++ b/modules/saml/lib/IdP/SAML2.php @@ -116,7 +116,7 @@ class sspmod_saml_IdP_SAML2 { $idpMetadata = $idp->getConfig(); - $error = sspmod_saml2_Error::fromException($exception); + $error = sspmod_saml_Error::fromException($exception); SimpleSAML_Logger::warning('Returning error to sp: ' . var_export($spEntityId, TRUE)); $error->logWarning(); diff --git a/modules/saml/lib/Message.php b/modules/saml/lib/Message.php index af0f171d6cce08564ef2797c7b0938ae943fc9f0..130b7a4852306ad8e9f45a64dd1a56a0843dbd0e 100644 --- a/modules/saml/lib/Message.php +++ b/modules/saml/lib/Message.php @@ -341,15 +341,15 @@ class sspmod_saml_Message { /** - * Retrieve the status code of a response as a sspmod_saml2_error. + * Retrieve the status code of a response as a sspmod_saml_Error. * * @param SAML2_StatusResponse $response The response. - * @return sspmod_saml2_Error The error. + * @return sspmod_saml_Error The error. */ public static function getResponseError(SAML2_StatusResponse $response) { $status = $response->getStatus(); - return new sspmod_saml2_Error($status['Code'], $status['SubCode'], $status['Message']); + return new sspmod_saml_Error($status['Code'], $status['SubCode'], $status['Message']); } @@ -699,7 +699,7 @@ class sspmod_saml_Message { /** * Process a response message. * - * If the response is an error response, we will throw a sspmod_saml2_Error + * If the response is an error response, we will throw a sspmod_saml_Error * exception with the error. * * @param SimpleSAML_Configuration $spMetadata The metadata of the service provider. diff --git a/modules/saml/www/sp/saml2-acs.php b/modules/saml/www/sp/saml2-acs.php index d95c7eb49b365242cf1cd532aa9210a206313f99..fcbe7eda9b6118b74367084ef03ee0e8be9aabae 100644 --- a/modules/saml/www/sp/saml2-acs.php +++ b/modules/saml/www/sp/saml2-acs.php @@ -48,7 +48,7 @@ $idpMetadata = $source->getIdPmetadata($idp); try { $assertion = sspmod_saml_Message::processResponse($spMetadata, $idpMetadata, $response); -} catch (sspmod_saml2_Error $e) { +} catch (sspmod_saml_Error $e) { /* The status of the response wasn't "success". */ $e = $e->toException(); SimpleSAML_Auth_State::throwException($state, $e); diff --git a/www/saml2/sp/AssertionConsumerService.php b/www/saml2/sp/AssertionConsumerService.php index 2446a26e8201e1e3f6d8ad622ef844c32c4b0a2b..e4b6a6bd6b60d554f211d071bfafd4a03192edef 100644 --- a/www/saml2/sp/AssertionConsumerService.php +++ b/www/saml2/sp/AssertionConsumerService.php @@ -105,7 +105,7 @@ try { try { $assertion = sspmod_saml_Message::processResponse($spMetadata, $idpMetadata, $response); - } catch (sspmod_saml2_Error $e) { + } catch (sspmod_saml_Error $e) { /* The status of the response wasn't "success". */ $status = $response->getStatus();