function SimpleSAML_exception_handler(Exception $exception) { if ($exception instanceof SimpleSAML_Error_Error) { $exception->show(); } else { $e = new SimpleSAML_Error_Error('UNHANDLEDEXCEPTION', $exception); $e->show(); } }
/** * Create a new BadRequest error. * * @param string $reason Description of why the request was unacceptable. */ public function __construct($reason) { assert('is_string($reason)'); $this->reason = $reason; parent::__construct(array('BADREQUEST', '%REASON%' => $this->reason)); $this->httpCode = 400; }
/** * Create a new AuthSource error. * * @param string $authsource Authsource module name from where this error was thrown. * @param string $reason Description of the error. */ public function __construct($authsource, $reason, $cause = NULL) { assert('is_string($authsource)'); assert('is_string($reason)'); $this->authsource = $authsource; $this->reason = $reason; parent::__construct(array('AUTHSOURCEERROR', '%AUTHSOURCE%' => htmlspecialchars(var_export($this->authsource, TRUE)), '%REASON%' => htmlspecialchars(var_export($this->reason, TRUE))), $cause); }
function SimpleSAML_exception_handler($exception) { SimpleSAML\Module::callHooks('exception_handler', $exception); if ($exception instanceof SimpleSAML_Error_Error) { $exception->show(); } elseif ($exception instanceof Exception) { $e = new SimpleSAML_Error_Error('UNHANDLEDEXCEPTION', $exception); $e->show(); } else { if (class_exists('Error') && $exception instanceof Error) { $code = $exception->getCode(); $errno = $code > 0 ? $code : E_ERROR; $errstr = $exception->getMessage(); $errfile = $exception->getFile(); $errline = $exception->getLine(); SimpleSAML_error_handler($errno, $errstr, $errfile, $errline); } } }
/** * Create a new NotFound error * * @param string $reason Optional description of why the given page could not be found. */ public function __construct($reason = NULL) { assert('is_null($reason) || is_string($reason)'); $url = SimpleSAML_Utilities::selfURL(); if ($reason === NULL) { parent::__construct(array('NOTFOUND', '%URL%' => $url)); } else { parent::__construct(array('NOTFOUNDREASON', '%URL%' => $url, '%REASON%' => $reason)); } $this->reason = $reason; }
/** * Create a new NotFound error * * @param string $reason Optional description of why the given page could not be found. */ public function __construct($reason = NULL) { assert('is_null($reason) || is_string($reason)'); $url = \SimpleSAML\Utils\HTTP::getSelfURL(); if ($reason === NULL) { parent::__construct(array('NOTFOUND', '%URL%' => $url)); } else { parent::__construct(array('NOTFOUNDREASON', '%URL%' => $url, '%REASON%' => $reason)); } $this->reason = $reason; $this->httpCode = 404; }
/** * Create a new NotFound error * * @param string $reason Optional description of why the given page could not be found. */ public function __construct($reason = NULL) { assert('is_null($reason) || is_string($reason)'); $url = \SimpleSAML\Utils\HTTP::getSelfURL(); if ($reason === NULL) { parent::__construct(array('NOTFOUND', '%URL%' => $url)); $this->message = "The requested page '{$url}' could not be found."; } else { parent::__construct(array('NOTFOUNDREASON', '%URL%' => $url, '%REASON%' => $reason)); $this->message = "The requested page '{$url}' could not be found. " . $reason; } $this->reason = $reason; $this->httpCode = 404; }
/** * ConfigurationError constructor. * * @param string|null $reason The reason for this exception. * @param string|null $file The configuration file that originated this error. * @param array|null $config The configuration array that led to this problem. */ public function __construct($reason = null, $file = null, array $config = null) { $file_str = ''; $reason_str = '.'; $params = array('CONFIG'); if ($file !== null) { $params['%FILE%'] = $file; $basepath = dirname(dirname(dirname(dirname(__FILE__)))) . '/'; $file_str = '(' . str_replace($basepath, '', $file) . ') '; } if ($reason !== null) { $params['%REASON%'] = $reason; $reason_str = ': ' . $reason; } $this->reason = $reason; $this->config_file = $file; parent::__construct($params); $this->message = 'The configuration ' . $file_str . 'is invalid' . $reason_str; }
/** * Create the error */ public function __construct() { parent::__construct('NOSTATE'); }
if (array_key_exists($type, $mimeTypes)) { $contentType = $mimeTypes[$type]; } } if ($contentType === null) { /* We were unable to determine the MIME type from the file extension. Fall back to mime_content_type (if it * exists). */ if (function_exists('mime_content_type')) { $contentType = mime_content_type($path); } else { // mime_content_type doesn't exist. Return a default MIME type SimpleSAML_Logger::warning('Unable to determine mime content type of file: ' . $path); $contentType = 'application/octet-stream'; } } $contentLength = sprintf('%u', filesize($path)); // force filesize to an unsigned number header('Content-Type: ' . $contentType); header('Content-Length: ' . $contentLength); header('Cache-Control: public,max-age=86400'); header('Expires: ' . gmdate('D, j M Y H:i:s \\G\\M\\T', time() + 10 * 60)); header('Last-Modified: ' . gmdate('D, j M Y H:i:s \\G\\M\\T', filemtime($path))); readfile($path); exit; } catch (SimpleSAML_Error_Error $e) { $e->show(); } catch (Exception $e) { $e = new SimpleSAML_Error_Error('UNHANDLEDEXCEPTION', $e); $e->show(); }
/** * Create the error * * @param string $entityId The entityID we were unable to locate. */ public function __construct($entityId) { assert('is_string($entityId)'); parent::__construct(array('METADATANOTFOUND', 'ENTITYID' => htmlspecialchars(var_export($entityId, TRUE)))); $this->entityId = $entityId; }
/** * Error handler for SAML-related errors * @param string $errorcode * @param string $errormsg * @throws Exception */ protected function _samlErrorHandler(\SimpleSAML_Error_Error $e) { switch ($e->getCode) { case 'WRONGUSERPASS': throw new \Exception("Your username or password is incorrect. Please try again, making sure that CAPS LOCK key is off"); break; case 'CREATEREQUEST': throw new \Exception("An error occurred when trying to create the authentication request"); break; case 'LOGOUTREQUEST': throw new \Exception("An error occurred when trying to process the Logout Request"); break; case 'METADATA': throw new \Exception("There is some misconfiguration of your SSO metadata"); break; case 'PROCESSASSERTION': throw new \Exception("We did not accept the response sent from the Identity Provider"); break; case 'LOGOUTINFOLOST': throw new \Exception("Logout information lost"); break; case 'RESPONSESTATUSNOSUCCESS': throw new \Exception("The Identity Provider responded with an error"); break; case 'NOTVALIDCERT': throw new \Exception("You did not present a valid certificate"); break; case 'NOCERT': throw new \Exception("Authentication failed: your browser did not send any certificate"); break; case 'UNKNOWNCERT': throw new \Exception("Authentication failed: the certificate your browser sent is unknown"); break; case 'USERABORTED': throw new \Exception("The authentication was aborted by the user"); break; case 'NOSTATE': throw new \Exception("State information lost, and no way to restart the request"); break; default: throw new \Exception($e->getMessage()); break; } }
/** * Create the error */ public function __construct() { $this->includeTemplate = 'core:no_state.tpl.php'; parent::__construct('NOSTATE'); }
function SimpleSAML_exception_handler(Exception $exception) { $e = new SimpleSAML_Error_Error('UNHANDLEDEXCEPTION', $exception); $e->show(); }
/** * Create the error * * @param string $reason Optional description of why the given page could not be found. */ public function __construct() { parent::__construct('State information lost, and no way to restart the request.'); }
/** * Create the error * * @param string $entityId The entityID we were unable to locate. */ public function __construct($entityId) { assert('is_string($entityId)'); $this->includeTemplate = 'core:no_metadata.tpl.php'; parent::__construct(array('METADATANOTFOUND', '%ENTITYID%' => htmlspecialchars(var_export($entityId, TRUE)))); }
/** * Create the error * * @param Exception|NULL $cause The exception that caused this error. */ public function __construct(Exception $cause = NULL) { parent::__construct('USERABORTED', $cause); }
/** * Create the error * * @param string $entityId The entityID we were unable to locate. */ public function __construct($entityId) { assert('is_string($entityId)'); parent::__construct('Unable to locate metadata for ' . var_export($entityId, TRUE) . '.'); $this->entityId = $entityId; }