From 3d2b3a56834fb6b506be0cd0d415b84fbd35e2a7 Mon Sep 17 00:00:00 2001 From: Olav Morken <olav.morken@uninett.no> Date: Tue, 29 Jun 2010 10:35:21 +0000 Subject: [PATCH] saml: Move Error-class to saml module. git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2374 44740490-163a-0410-bde0-09ae8108e29a --- docs/simplesamlphp-errorhandling.txt | 6 +++--- modules/{saml2 => saml}/lib/Error.php | 8 ++++---- modules/saml/lib/IdP/SAML2.php | 2 +- modules/saml/lib/Message.php | 8 ++++---- modules/saml/www/sp/saml2-acs.php | 2 +- www/saml2/sp/AssertionConsumerService.php | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) rename modules/{saml2 => saml}/lib/Error.php (95%) diff --git a/docs/simplesamlphp-errorhandling.txt b/docs/simplesamlphp-errorhandling.txt index 6d705f69e..dce9b70ba 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 1c9e11ccc..6a4989d01 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 611a4d88e..a260a8e10 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 af0f171d6..130b7a485 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 d95c7eb49..fcbe7eda9 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 2446a26e8..e4b6a6bd6 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(); -- GitLab