From d01fee11cb9ec1de1bbbd01dd5cc66723bb935ef Mon Sep 17 00:00:00 2001 From: Olav Morken <olav.morken@uninett.no> Date: Fri, 6 Aug 2010 07:21:22 +0000 Subject: [PATCH] Replace calls to SimpleSAML_Utilities::fatalError with throwing an exception. Also remove those instances of the $session variable that became unused. git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2479 44740490-163a-0410-bde0-09ae8108e29a --- modules/adfs/lib/IdP/ADFS.php | 2 +- modules/discopower/www/disco.php | 6 ++---- modules/openid/www/initopenid.php | 2 +- www/auth/login-admin.php | 10 ++-------- www/auth/login-cas-ldap.php | 6 +++--- www/auth/login-ldapmulti.php | 2 +- www/auth/login-radius.php | 2 +- www/auth/login-tlsclient.php | 6 +++--- www/auth/login-wayf-ldap.php | 6 +++--- www/auth/login.php | 2 +- www/authmemcookie.php | 4 ++-- www/saml2/idp/initSLO.php | 5 ++--- www/saml2/idp/metadata.php | 5 ++--- www/saml2/sp/AssertionConsumerService.php | 8 ++++---- www/saml2/sp/SingleLogoutService.php | 8 ++++---- www/saml2/sp/idpdisco.php | 6 ++---- www/saml2/sp/initSLO.php | 6 +++--- www/saml2/sp/initSSO.php | 8 ++++---- www/saml2/sp/metadata.php | 5 ++--- www/shib13/idp/metadata.php | 5 ++--- www/shib13/sp/AssertionConsumerService.php | 8 ++++---- www/shib13/sp/idpdisco.php | 6 ++---- www/shib13/sp/initSSO.php | 8 ++++---- www/shib13/sp/metadata.php | 5 ++--- www/wsfed/sp/idpdisco.php | 6 ++---- www/wsfed/sp/initSLO.php | 6 +++--- www/wsfed/sp/initSSO.php | 9 ++++----- www/wsfed/sp/prp.php | 6 +++--- 28 files changed, 69 insertions(+), 89 deletions(-) diff --git a/modules/adfs/lib/IdP/ADFS.php b/modules/adfs/lib/IdP/ADFS.php index 144a7a2a1..1353d01bc 100644 --- a/modules/adfs/lib/IdP/ADFS.php +++ b/modules/adfs/lib/IdP/ADFS.php @@ -25,7 +25,7 @@ class sspmod_adfs_IdP_ADFS { SimpleSAML_Logger::info('ADFS - IdP.prp: Incoming Authentication request: '.$issuer.' id '.$requestid); } catch(Exception $exception) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'PROCESSAUTHNREQUEST', $exception); + throw new SimpleSAML_Error_Error('PROCESSAUTHNREQUEST', $exception); } $sessionLostURL = NULL; // TODO? diff --git a/modules/discopower/www/disco.php b/modules/discopower/www/disco.php index daf51ea78..4241002a9 100644 --- a/modules/discopower/www/disco.php +++ b/modules/discopower/www/disco.php @@ -2,20 +2,18 @@ require_once('../www/_include.php'); -$session = SimpleSAML_Session::getInstance(); - try { $discoHandler = new sspmod_discopower_PowerIdPDisco(array('saml20-idp-remote', 'shib13-idp-remote'), 'poweridpdisco'); } catch (Exception $exception) { /* An error here should be caused by invalid query parameters. */ - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'DISCOPARAMS', $exception); + throw new SimpleSAML_Error_Error('DISCOPARAMS', $exception); } try { $discoHandler->handleRequest(); } catch(Exception $exception) { /* An error here should be caused by metadata. */ - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'METADATA', $exception); + throw new SimpleSAML_Error_Error('METADATA', $exception); } ?> \ No newline at end of file diff --git a/modules/openid/www/initopenid.php b/modules/openid/www/initopenid.php index 9db74fa60..704c2c8fa 100644 --- a/modules/openid/www/initopenid.php +++ b/modules/openid/www/initopenid.php @@ -12,7 +12,7 @@ $config = SimpleSAML_Configuration::getInstance(); $session = SimpleSAML_Session::getInstance(); if (empty($_REQUEST['RelayState'])) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NORELAYSTATE'); + throw new SimpleSAML_Error_Error('NORELAYSTATE'); } if (! $session->isValid('openid') ) { diff --git a/www/auth/login-admin.php b/www/auth/login-admin.php index 347b19969..f20dfc28c 100644 --- a/www/auth/login-admin.php +++ b/www/auth/login-admin.php @@ -17,10 +17,7 @@ $username = null; * we should redirect the user to after a successful authentication. */ if (!array_key_exists('RelayState', $_REQUEST)) { - SimpleSAML_Utilities::fatalError( - $session->getTrackID(), - 'NORELAYSTATE' - ); + throw new SimpleSAML_Error_Error('NORELAYSTATE'); } $relaystate = $_REQUEST['RelayState']; @@ -28,10 +25,7 @@ $relaystate = $_REQUEST['RelayState']; $correctpassword = $config->getString('auth.adminpassword', '123'); if (empty($correctpassword) or $correctpassword === '123') { - SimpleSAML_Utilities::fatalError( - $session->getTrackID(), - 'NOTSET' - ); + throw new SimpleSAML_Error_Error('NOTSET'); } diff --git a/www/auth/login-cas-ldap.php b/www/auth/login-cas-ldap.php index 727a44870..9a5419e64 100755 --- a/www/auth/login-cas-ldap.php +++ b/www/auth/login-cas-ldap.php @@ -33,7 +33,7 @@ try { } catch (Exception $exception) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'METADATA', $exception); + throw new SimpleSAML_Error_Error('METADATA', $exception); } /* @@ -41,7 +41,7 @@ try { * we should redirect the user to after a successful authentication. */ if (!array_key_exists('RelayState', $_REQUEST)) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NORELAYSTATE'); + throw new SimpleSAML_Error_Error('NORELAYSTATE'); } @@ -135,7 +135,7 @@ try { SimpleSAML_Utilities::redirect($relaystate); } catch(Exception $exception) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'CASERROR', $exception); + throw new SimpleSAML_Error_Error('CASERROR', $exception); } diff --git a/www/auth/login-ldapmulti.php b/www/auth/login-ldapmulti.php index 4242990ae..8d36b67f0 100644 --- a/www/auth/login-ldapmulti.php +++ b/www/auth/login-ldapmulti.php @@ -20,7 +20,7 @@ $attributes = array(); * we should redirect the user to after a successful authentication. */ if (!array_key_exists('RelayState', $_REQUEST)) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NORELAYSTATE'); + throw new SimpleSAML_Error_Error('NORELAYSTATE'); } if (isset($_POST['username'])) { diff --git a/www/auth/login-radius.php b/www/auth/login-radius.php index 073b90e84..c9096ac1f 100644 --- a/www/auth/login-radius.php +++ b/www/auth/login-radius.php @@ -16,7 +16,7 @@ $attributes = array(); * we should redirect the user to after a successful authentication. */ if (!array_key_exists('RelayState', $_REQUEST)) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NORELAYSTATE'); + throw new SimpleSAML_Error_Error('NORELAYSTATE'); } if (isset($_POST['username'])) { diff --git a/www/auth/login-tlsclient.php b/www/auth/login-tlsclient.php index af8f164c6..e63059c74 100644 --- a/www/auth/login-tlsclient.php +++ b/www/auth/login-tlsclient.php @@ -20,7 +20,7 @@ $username = null; * we should redirect the user to after a successful authentication. */ if (!array_key_exists('RelayState', $_REQUEST)) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NORELAYSTATE'); + throw new SimpleSAML_Error_Error('NORELAYSTATE'); } $relaystate = $_REQUEST['RelayState']; @@ -35,7 +35,7 @@ try { throw new Exception('Apache header variable SSL_CLIENT_VERIFY was not available. Recheck your apache configuration.'); if (strcmp($_SERVER['SSL_CLIENT_VERIFY'], "SUCCESS") != 0) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NOTVALIDCERT', $e); + throw new SimpleSAML_Error_Error('NOTVALIDCERT', $e); } $userid = $_SERVER['SSL_CLIENT_S_DN']; @@ -73,7 +73,7 @@ try { } catch (Exception $e) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'CONFIG', $e); + throw new SimpleSAML_Error_Error('CONFIG', $e); } diff --git a/www/auth/login-wayf-ldap.php b/www/auth/login-wayf-ldap.php index 4fac5c4d7..f8eef7513 100755 --- a/www/auth/login-wayf-ldap.php +++ b/www/auth/login-wayf-ldap.php @@ -31,7 +31,7 @@ try { $ldapconfig = $casldapconfig[$idpentityid]['ldap']; } catch (Exception $exception) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'METADATA', $exception); + throw new SimpleSAML_Error_Error('METADATA', $exception); } /* @@ -39,7 +39,7 @@ try { * we should redirect the user to after a successful authentication. */ if (!array_key_exists('RelayState', $_REQUEST)) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NORELAYSTATE'); + throw new SimpleSAML_Error_Error('NORELAYSTATE'); } $relaystate = $_REQUEST['RelayState']; @@ -62,7 +62,7 @@ if ($username = $_POST['username']) { SimpleSAML_Utilities::redirect($relaystate); } } catch(Exception $e) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'LDAPERROR', $e); + throw new SimpleSAML_Error_Error('LDAPERROR', $e); } } diff --git a/www/auth/login.php b/www/auth/login.php index e92564b0d..093a82b3f 100644 --- a/www/auth/login.php +++ b/www/auth/login.php @@ -21,7 +21,7 @@ $username = null; * we should redirect the user to after a successful authentication. */ if (!array_key_exists('RelayState', $_REQUEST)) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NORELAYSTATE'); + throw new SimpleSAML_Error_Error('NORELAYSTATE'); } $relaystate = $_REQUEST['RelayState']; diff --git a/www/authmemcookie.php b/www/authmemcookie.php index 5cb5b1e27..3b2729d92 100644 --- a/www/authmemcookie.php +++ b/www/authmemcookie.php @@ -19,7 +19,7 @@ try { /* Check if this module is enabled. */ if(!$globalConfig->getBoolean('enable.authmemcookie', FALSE)) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NOACCESS'); + throw new SimpleSAML_Error_Error('NOACCESS'); } /* Load Auth MemCookie configuration. */ @@ -120,5 +120,5 @@ try { /* Redirect the user back to this page to signal that the login is completed. */ SimpleSAML_Utilities::redirect(SimpleSAML_Utilities::selfURL()); } catch(Exception $e) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'CONFIG', $e); + throw new SimpleSAML_Error_Error('CONFIG', $e); } diff --git a/www/saml2/idp/initSLO.php b/www/saml2/idp/initSLO.php index a1e12f4bd..47de1b57b 100644 --- a/www/saml2/idp/initSLO.php +++ b/www/saml2/idp/initSLO.php @@ -4,17 +4,16 @@ require_once('../../../www/_include.php'); $config = SimpleSAML_Configuration::getInstance(); $metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler(); -$session = SimpleSAML_Session::getInstance(); SimpleSAML_Logger::info('SAML2.0 - IdP.initSLO: Accessing SAML 2.0 IdP endpoint init Single Logout'); if (!$config->getBoolean('enable.saml20-idp', false)) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NOACCESS'); + throw new SimpleSAML_Error_Error('NOACCESS'); } if (!isset($_GET['RelayState'])) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NORELAYSTATE'); + throw new SimpleSAML_Error_Error('NORELAYSTATE'); } $returnTo = $_GET['RelayState']; diff --git a/www/saml2/idp/metadata.php b/www/saml2/idp/metadata.php index 9cd1f9601..216b3e7a3 100644 --- a/www/saml2/idp/metadata.php +++ b/www/saml2/idp/metadata.php @@ -5,10 +5,9 @@ require_once('../../_include.php'); /* Load simpleSAMLphp, configuration and metadata */ $config = SimpleSAML_Configuration::getInstance(); $metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler(); -$session = SimpleSAML_Session::getInstance(); if (!$config->getBoolean('enable.saml20-idp', false)) - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NOACCESS'); + throw new SimpleSAML_Error_Error('NOACCESS'); /* Check if valid local session exists.. */ if ($config->getBoolean('admin.protectmetadata', false)) { @@ -108,7 +107,7 @@ try { } catch(Exception $exception) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'METADATA', $exception); + throw new SimpleSAML_Error_Error('METADATA', $exception); } diff --git a/www/saml2/sp/AssertionConsumerService.php b/www/saml2/sp/AssertionConsumerService.php index e4b6a6bd6..7065f049c 100644 --- a/www/saml2/sp/AssertionConsumerService.php +++ b/www/saml2/sp/AssertionConsumerService.php @@ -52,7 +52,7 @@ function finishLogin($authProcState) { SimpleSAML_Logger::info('SAML2.0 - SP.AssertionConsumerService: Accessing SAML 2.0 SP endpoint AssertionConsumerService'); if (!$config->getBoolean('enable.saml20-sp', TRUE)) - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NOACCESS'); + throw new SimpleSAML_Error_Error('NOACCESS'); if (array_key_exists(SimpleSAML_Auth_ProcessingChain::AUTHPARAM, $_REQUEST)) { /* We have returned from the authentication processing filters. */ @@ -98,7 +98,7 @@ try { } if(empty($info['RelayState'])) { /* RelayState missing. */ - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NORELAYSTATE'); + throw new SimpleSAML_Error_Error('NORELAYSTATE'); } } @@ -115,7 +115,7 @@ try { } /* We don't have an error handler. Show an error page. */ - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'RESPONSESTATUSNOSUCCESS', $e); + throw new SimpleSAML_Error_Error('RESPONSESTATUSNOSUCCESS', $e); } @@ -156,7 +156,7 @@ try { finishLogin($authProcState); } catch(Exception $exception) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'PROCESSASSERTION', $exception); + throw new SimpleSAML_Error_Error('PROCESSASSERTION', $exception); } diff --git a/www/saml2/sp/SingleLogoutService.php b/www/saml2/sp/SingleLogoutService.php index 9a07973e0..b04f850ae 100644 --- a/www/saml2/sp/SingleLogoutService.php +++ b/www/saml2/sp/SingleLogoutService.php @@ -12,7 +12,7 @@ $session = SimpleSAML_Session::getInstance(); SimpleSAML_Logger::info('SAML2.0 - SP.SingleLogoutService: Accessing SAML 2.0 SP endpoint SingleLogoutService'); if (!$config->getBoolean('enable.saml20-sp', TRUE)) - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NOACCESS'); + throw new SimpleSAML_Error_Error('NOACCESS'); @@ -58,7 +58,7 @@ if ($message instanceof SAML2_LogoutRequest) { $binding->setDestination(sspmod_saml_Message::getDebugDestination()); $binding->send($lr); } catch (Exception $exception) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'LOGOUTREQUEST', $exception); + throw new SimpleSAML_Error_Error('LOGOUTREQUEST', $exception); } } elseif ($message instanceof SAML2_LogoutResponse) { @@ -73,13 +73,13 @@ if ($message instanceof SAML2_LogoutRequest) { $returnTo = $session->getData('spLogoutReturnTo', $id); if (empty($returnTo)) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'LOGOUTINFOLOST'); + throw new SimpleSAML_Error_Error('LOGOUTINFOLOST'); } SimpleSAML_Utilities::redirect($returnTo); } else { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'SLOSERVICEPARAMS'); + throw new SimpleSAML_Error_Error('SLOSERVICEPARAMS'); } diff --git a/www/saml2/sp/idpdisco.php b/www/saml2/sp/idpdisco.php index 3cfdc17e3..6425cddf7 100644 --- a/www/saml2/sp/idpdisco.php +++ b/www/saml2/sp/idpdisco.php @@ -2,20 +2,18 @@ require_once('../../_include.php'); -$session = SimpleSAML_Session::getInstance(); - try { $discoHandler = new SimpleSAML_XHTML_IdPDisco(array('saml20-idp-remote'), 'saml20'); } catch (Exception $exception) { /* An error here should be caused by invalid query parameters. */ - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'DISCOPARAMS', $exception); + throw new SimpleSAML_Error_Error('DISCOPARAMS', $exception); } try { $discoHandler->handleRequest(); } catch(Exception $exception) { /* An error here should be caused by metadata. */ - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'METADATA', $exception); + throw new SimpleSAML_Error_Error('METADATA', $exception); } ?> \ No newline at end of file diff --git a/www/saml2/sp/initSLO.php b/www/saml2/sp/initSLO.php index 16b188ccd..dd19558d7 100644 --- a/www/saml2/sp/initSLO.php +++ b/www/saml2/sp/initSLO.php @@ -9,13 +9,13 @@ $session = SimpleSAML_Session::getInstance(); SimpleSAML_Logger::info('SAML2.0 - SP.initSLO: Accessing SAML 2.0 SP initSLO script'); if (!$config->getBoolean('enable.saml20-sp', TRUE)) - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NOACCESS'); + throw new SimpleSAML_Error_Error('NOACCESS'); if (isset($_REQUEST['RelayState'])) { $returnTo = $_REQUEST['RelayState']; } else { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NORELAYSTATE'); + throw new SimpleSAML_Error_Error('NORELAYSTATE'); } @@ -57,7 +57,7 @@ try { } catch(Exception $exception) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'CREATEREQUEST', $exception); + throw new SimpleSAML_Error_Error('CREATEREQUEST', $exception); } diff --git a/www/saml2/sp/initSSO.php b/www/saml2/sp/initSSO.php index 05e7cb40f..d38ce8a73 100644 --- a/www/saml2/sp/initSSO.php +++ b/www/saml2/sp/initSSO.php @@ -10,7 +10,7 @@ $session = SimpleSAML_Session::getInstance(); SimpleSAML_Logger::info('SAML2.0 - SP.initSSO: Accessing SAML 2.0 SP initSSO script'); if (!$config->getBoolean('enable.saml20-sp', TRUE)) - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NOACCESS'); + throw new SimpleSAML_Error_Error('NOACCESS'); /* * Incomming URL parameters @@ -21,7 +21,7 @@ if (!$config->getBoolean('enable.saml20-sp', TRUE)) */ if (empty($_GET['RelayState'])) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NORELAYSTATE'); + throw new SimpleSAML_Error_Error('NORELAYSTATE'); } $reachableIDPs = array(); @@ -70,7 +70,7 @@ try { } catch (Exception $exception) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'METADATA', $exception); + throw new SimpleSAML_Error_Error('METADATA', $exception); } /* @@ -169,7 +169,7 @@ try { $b->send($ar); } catch(Exception $exception) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'CREATEREQUEST', $exception); + throw new SimpleSAML_Error_Error('CREATEREQUEST', $exception); } ?> \ No newline at end of file diff --git a/www/saml2/sp/metadata.php b/www/saml2/sp/metadata.php index 63fb36614..03331212c 100644 --- a/www/saml2/sp/metadata.php +++ b/www/saml2/sp/metadata.php @@ -5,11 +5,10 @@ require_once('../../_include.php'); /* Load simpleSAMLphp, configuration and metadata */ $config = SimpleSAML_Configuration::getInstance(); $metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler(); -$session = SimpleSAML_Session::getInstance(); if (!$config->getValue('enable.saml20-sp', TRUE)) - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NOACCESS'); + throw new SimpleSAML_Error_Error('NOACCESS'); /* Check if valid local session exists.. */ if ($config->getBoolean('admin.protectmetadata', false)) { @@ -94,7 +93,7 @@ try { } catch(Exception $exception) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'METADATA', $exception); + throw new SimpleSAML_Error_Error('METADATA', $exception); } diff --git a/www/shib13/idp/metadata.php b/www/shib13/idp/metadata.php index c386966a0..27a97b427 100644 --- a/www/shib13/idp/metadata.php +++ b/www/shib13/idp/metadata.php @@ -5,10 +5,9 @@ require_once('../../_include.php'); /* Load simpleSAMLphp, configuration and metadata */ $config = SimpleSAML_Configuration::getInstance(); $metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler(); -$session = SimpleSAML_Session::getInstance(); if (!$config->getBoolean('enable.shib13-idp', false)) - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NOACCESS'); + throw new SimpleSAML_Error_Error('NOACCESS'); /* Check if valid local session exists.. */ if ($config->getBoolean('admin.protectmetadata', false)) { @@ -91,7 +90,7 @@ try { } catch(Exception $exception) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'METADATA', $exception); + throw new SimpleSAML_Error_Error('METADATA', $exception); } diff --git a/www/shib13/sp/AssertionConsumerService.php b/www/shib13/sp/AssertionConsumerService.php index 5f368efb5..90ef7618e 100644 --- a/www/shib13/sp/AssertionConsumerService.php +++ b/www/shib13/sp/AssertionConsumerService.php @@ -40,7 +40,7 @@ function finishLogin($authProcState) { SimpleSAML_Logger::info('Shib1.3 - SP.AssertionConsumerService: Accessing Shibboleth 1.3 SP endpoint AssertionConsumerService'); if (!$config->getBoolean('enable.shib13-sp', false)) - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NOACCESS'); + throw new SimpleSAML_Error_Error('NOACCESS'); if (array_key_exists(SimpleSAML_Auth_ProcessingChain::AUTHPARAM, $_REQUEST)) { /* We have returned from the authentication processing filters. */ @@ -51,7 +51,7 @@ if (array_key_exists(SimpleSAML_Auth_ProcessingChain::AUTHPARAM, $_REQUEST)) { } if (empty($_POST['SAMLResponse'])) - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'ACSPARAMS', $exception); + throw new SimpleSAML_Error_Error('ACSPARAMS', $exception); try { @@ -74,7 +74,7 @@ try { $relayState = $authnResponse->getRelayState(); if (!isset($relayState)) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NORELAYSTATE'); + throw new SimpleSAML_Error_Error('NORELAYSTATE'); } $spmetadata = $metadata->getMetaData(NULL, 'shib13-sp-hosted'); @@ -100,7 +100,7 @@ try { finishLogin($authProcState); } catch(Exception $exception) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'GENERATEAUTHNRESPONSE', $exception); + throw new SimpleSAML_Error_Error('GENERATEAUTHNRESPONSE', $exception); } diff --git a/www/shib13/sp/idpdisco.php b/www/shib13/sp/idpdisco.php index dfaf3e86b..b9c563e08 100644 --- a/www/shib13/sp/idpdisco.php +++ b/www/shib13/sp/idpdisco.php @@ -2,20 +2,18 @@ require_once('../../_include.php'); -$session = SimpleSAML_Session::getInstance(); - try { $discoHandler = new SimpleSAML_XHTML_IdPDisco(array('shib13-idp-remote'), 'shib13'); } catch (Exception $exception) { /* An error here should be caused by invalid query parameters. */ - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'DISCOPARAMS', $exception); + throw new SimpleSAML_Error_Error('DISCOPARAMS', $exception); } try { $discoHandler->handleRequest(); } catch(Exception $exception) { /* An error here should be caused by metadata. */ - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'METADATA', $exception); + throw new SimpleSAML_Error_Error('METADATA', $exception); } ?> \ No newline at end of file diff --git a/www/shib13/sp/initSSO.php b/www/shib13/sp/initSSO.php index e538e28fb..4af706c76 100644 --- a/www/shib13/sp/initSSO.php +++ b/www/shib13/sp/initSSO.php @@ -21,7 +21,7 @@ $session = SimpleSAML_Session::getInstance(); SimpleSAML_Logger::info('Shib1.3 - SP.initSSO: Accessing Shib 1.3 SP initSSO script'); if (!$config->getBoolean('enable.shib13-sp', false)) - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NOACCESS'); + throw new SimpleSAML_Error_Error('NOACCESS'); try { @@ -36,7 +36,7 @@ try { } catch (Exception $exception) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'METADATA', $exception); + throw new SimpleSAML_Error_Error('METADATA', $exception); } @@ -78,7 +78,7 @@ if (!isset($session) || !$session->isValid('shib13') ) { SimpleSAML_Utilities::redirect($url); } catch(Exception $exception) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'CREATEREQUEST', $exception); + throw new SimpleSAML_Error_Error('CREATEREQUEST', $exception); } } else { @@ -90,7 +90,7 @@ if (!isset($session) || !$session->isValid('shib13') ) { SimpleSAML_Logger::info('Shib1.3 - SP.initSSO: Already Authenticated, Go back to RelayState'); SimpleSAML_Utilities::redirect($relaystate); } else { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NORELAYSTATE'); + throw new SimpleSAML_Error_Error('NORELAYSTATE'); } } diff --git a/www/shib13/sp/metadata.php b/www/shib13/sp/metadata.php index ab0e93d4d..2bc4f8733 100644 --- a/www/shib13/sp/metadata.php +++ b/www/shib13/sp/metadata.php @@ -5,11 +5,10 @@ require_once('../../_include.php'); /* Load simpleSAMLphp, configuration and metadata */ $config = SimpleSAML_Configuration::getInstance(); $metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler(); -$session = SimpleSAML_Session::getInstance(); if (!$config->getBoolean('enable.shib13-sp', false)) - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NOACCESS'); + throw new SimpleSAML_Error_Error('NOACCESS'); /* Check if valid local session exists.. */ if ($config->getBoolean('admin.protectmetadata', false)) { @@ -96,7 +95,7 @@ try { } catch(Exception $exception) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'METADATA', $exception); + throw new SimpleSAML_Error_Error('METADATA', $exception); } diff --git a/www/wsfed/sp/idpdisco.php b/www/wsfed/sp/idpdisco.php index 1a9e58473..fe6f0b6a9 100644 --- a/www/wsfed/sp/idpdisco.php +++ b/www/wsfed/sp/idpdisco.php @@ -2,20 +2,18 @@ require_once('../../_include.php'); -$session = SimpleSAML_Session::getInstance(); - try { $discoHandler = new SimpleSAML_XHTML_IdPDisco(array('wsfed-idp-remote'), 'wsfed'); } catch (Exception $exception) { /* An error here should be caused by invalid query parameters. */ - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'DISCOPARAMS', $exception); + throw new SimpleSAML_Error_Error('DISCOPARAMS', $exception); } try { $discoHandler->handleRequest(); } catch(Exception $exception) { /* An error here should be caused by metadata. */ - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'METADATA', $exception); + throw new SimpleSAML_Error_Error('METADATA', $exception); } ?> \ No newline at end of file diff --git a/www/wsfed/sp/initSLO.php b/www/wsfed/sp/initSLO.php index 0132f9284..13b39d1a7 100644 --- a/www/wsfed/sp/initSLO.php +++ b/www/wsfed/sp/initSLO.php @@ -9,13 +9,13 @@ $session = SimpleSAML_Session::getInstance(); SimpleSAML_Logger::info('WS-Fed - SP.initSLO: Accessing WS-Fed SP initSLO script'); if (!$config->getBoolean('enable.wsfed-sp', false)) - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NOACCESS'); + throw new SimpleSAML_Error_Error('NOACCESS'); if (isset($_REQUEST['RelayState'])) { $returnTo = $_REQUEST['RelayState']; } else { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NORELAYSTATE'); + throw new SimpleSAML_Error_Error('NORELAYSTATE'); } @@ -47,7 +47,7 @@ if (isset($session) ) { } catch(Exception $exception) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'CREATEREQUEST', $exception); + throw new SimpleSAML_Error_Error('CREATEREQUEST', $exception); } } else { diff --git a/www/wsfed/sp/initSSO.php b/www/wsfed/sp/initSSO.php index 9be61bf97..fd038b5d9 100644 --- a/www/wsfed/sp/initSSO.php +++ b/www/wsfed/sp/initSSO.php @@ -15,15 +15,14 @@ require_once('../../_include.php'); $config = SimpleSAML_Configuration::getInstance(); $metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler(); -$session = SimpleSAML_Session::getInstance(); SimpleSAML_Logger::info('WS-Fed - SP.initSSO: Accessing WS-Fed SP initSSO script'); if (!$config->getBoolean('enable.wsfed-sp', false)) - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NOACCESS'); + throw new SimpleSAML_Error_Error('NOACCESS'); if (empty($_GET['RelayState'])) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NORELAYSTATE'); + throw new SimpleSAML_Error_Error('NORELAYSTATE'); } try { @@ -32,7 +31,7 @@ try { $spentityid = isset($_GET['spentityid']) ? $_GET['spentityid'] : $metadata->getMetaDataCurrentEntityID('wsfed-sp-hosted'); } catch (Exception $exception) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'METADATA', $exception); + throw new SimpleSAML_Error_Error('METADATA', $exception); } if ($idpentityid == null) { @@ -60,7 +59,7 @@ try { )); } catch (Exception $exception) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'CREATEREQUEST', $exception); + throw new SimpleSAML_Error_Error('CREATEREQUEST', $exception); } ?> \ No newline at end of file diff --git a/www/wsfed/sp/prp.php b/www/wsfed/sp/prp.php index be7f77280..37acae025 100644 --- a/www/wsfed/sp/prp.php +++ b/www/wsfed/sp/prp.php @@ -21,7 +21,7 @@ $metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler(); SimpleSAML_Logger::info('WS-Fed - SP.AssertionConsumerService: Accessing WS-Fed SP endpoint AssertionConsumerService'); if (!$config->getBoolean('enable.wsfed-sp', false)) - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NOACCESS'); + throw new SimpleSAML_Error_Error('NOACCESS'); if (!empty($_GET['wa']) and ($_GET['wa'] == 'wsignoutcleanup1.0')) { print 'Logged Out'; @@ -40,7 +40,7 @@ try { throw new Exception('Missing wctx parameter'); } } catch(Exception $exception) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'ACSPARAMS', $exception); + throw new SimpleSAML_Error_Error('ACSPARAMS', $exception); } @@ -143,7 +143,7 @@ try { SimpleSAML_Utilities::redirect($wctx); } catch(Exception $exception) { - SimpleSAML_Utilities::fatalError($session->getTrackID(), 'PROCESSASSERTION', $exception); + throw new SimpleSAML_Error_Error('PROCESSASSERTION', $exception); } ?> \ No newline at end of file -- GitLab