From 3aea3623ee640db54a0e5383e25d352d43aa7c5c Mon Sep 17 00:00:00 2001 From: Olav Morken <olav.morken@uninett.no> Date: Fri, 14 Aug 2009 11:07:44 +0000 Subject: [PATCH] Give default values for all configuration options from config.php git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1665 44740490-163a-0410-bde0-09ae8108e29a --- lib/SimpleSAML/Auth/TimeLimitedToken.php | 3 +- lib/SimpleSAML/Bindings/Shib13/HTTPPost.php | 2 +- lib/SimpleSAML/Configuration.php | 7 ++-- lib/SimpleSAML/Logger.php | 2 +- .../Logger/LoggingHandlerErrorLog.php | 2 +- lib/SimpleSAML/Logger/LoggingHandlerFile.php | 4 +-- .../Logger/LoggingHandlerSyslog.php | 4 +-- .../Metadata/MetaDataStorageHandler.php | 11 ++---- .../MetaDataStorageHandlerFlatFile.php | 2 +- .../MetaDataStorageHandlerSAML2Meta.php | 2 +- lib/SimpleSAML/Metadata/Signer.php | 16 ++++----- lib/SimpleSAML/Session.php | 10 +++--- lib/SimpleSAML/SessionHandlerPHP.php | 6 ++-- lib/SimpleSAML/Utilities.php | 21 +++++------- lib/SimpleSAML/XHTML/IdPDisco.php | 4 +-- lib/SimpleSAML/XHTML/Template.php | 20 +++++------ lib/SimpleSAML/XML/Shib13/AuthnResponse.php | 2 +- lib/SimpleSAML/XML/Signer.php | 2 +- modules/adfs/www/idp/prp.php | 2 +- modules/consentAdmin/www/consentAdmin.php | 2 +- modules/core/hooks/hook_sanitycheck.php | 4 +-- .../core/lib/Auth/Process/AttributeMap.php | 2 +- modules/cron/www/cron.php | 2 +- modules/discopower/lib/PowerIdPDisco.php | 4 +-- modules/saml2/lib/Message.php | 6 ++-- modules/saml2/www/sp/metadata.php | 4 +-- www/admin/metadata.php | 10 +++--- www/auth/login-admin.php | 2 +- www/authmemcookie.php | 2 +- www/errorreport.php | 2 +- www/index.php | 34 +++++++++---------- www/saml2/idp/SSOService.php | 2 +- www/saml2/idp/SingleLogoutService.php | 8 ++--- www/saml2/idp/SingleLogoutServiceiFrame.php | 6 ++-- .../SingleLogoutServiceiFrameNoJavascript.php | 2 +- .../idp/SingleLogoutServiceiFrameResponse.php | 2 +- .../idp/idpInitSingleLogoutServiceiFrame.php | 6 ++-- www/saml2/idp/initSLO.php | 2 +- www/saml2/idp/metadata.php | 10 +++--- www/saml2/sp/AssertionConsumerService.php | 2 +- www/saml2/sp/SingleLogoutService.php | 2 +- www/saml2/sp/initSLO.php | 2 +- www/saml2/sp/initSSO.php | 12 +++---- www/saml2/sp/metadata.php | 14 ++++---- www/shib13/idp/SSOService.php | 2 +- www/shib13/idp/metadata.php | 10 +++--- www/shib13/sp/AssertionConsumerService.php | 2 +- www/shib13/sp/initSSO.php | 8 ++--- www/shib13/sp/metadata.php | 14 ++++---- www/wsfed/sp/initSLO.php | 2 +- www/wsfed/sp/initSSO.php | 2 +- www/wsfed/sp/prp.php | 2 +- 52 files changed, 146 insertions(+), 162 deletions(-) diff --git a/lib/SimpleSAML/Auth/TimeLimitedToken.php b/lib/SimpleSAML/Auth/TimeLimitedToken.php index 95d4a22d6..3c991ce94 100644 --- a/lib/SimpleSAML/Auth/TimeLimitedToken.php +++ b/lib/SimpleSAML/Auth/TimeLimitedToken.php @@ -14,8 +14,7 @@ class SimpleSAML_Auth_TimeLimitedToken { */ public function __construct( $lifetime = 900, $secretSalt = NULL, $skew = 1) { if ($secretSalt === NULL) { - $config = SimpleSAML_Configuration::getInstance(); - $secretSalt = $config->getValue('secretsalt'); + $secretSalt = SimpleSAML_Utilities::getSecretSalt(); } $this->secretSalt = $secretSalt; diff --git a/lib/SimpleSAML/Bindings/Shib13/HTTPPost.php b/lib/SimpleSAML/Bindings/Shib13/HTTPPost.php index 68a0051eb..c4554749c 100644 --- a/lib/SimpleSAML/Bindings/Shib13/HTTPPost.php +++ b/lib/SimpleSAML/Bindings/Shib13/HTTPPost.php @@ -83,7 +83,7 @@ class SimpleSAML_Bindings_Shib13_HTTPPost { $response = $responsedom->saveXML(); - if ($this->configuration->getValue('debug')) { + if ($this->configuration->getBoolean('debug', FALSE)) { $p = new SimpleSAML_XHTML_Template($this->configuration, 'post-debug.php'); $p->data['header'] = 'SAML (Shibboleth 1.3) Response Debug-mode'; $p->data['RelayStateName'] = 'TARGET'; diff --git a/lib/SimpleSAML/Configuration.php b/lib/SimpleSAML/Configuration.php index 487905ec9..c812e0e25 100644 --- a/lib/SimpleSAML/Configuration.php +++ b/lib/SimpleSAML/Configuration.php @@ -296,10 +296,11 @@ class SimpleSAML_Configuration { public function getBaseURL() { - if (preg_match('/^\*(.*)$/', $this->getValue('baseurlpath', ''), $matches)) { + if (preg_match('/^\*(.*)$/', $this->getString('baseurlpath', 'simplesaml/'), $matches)) { return SimpleSAML_Utilities::getFirstPathElement(false) . $matches[1]; } - return $this->getValue('baseurlpath', ''); + + return $this->getString('baseurlpath', 'simplesaml/'); } @@ -375,7 +376,7 @@ class SimpleSAML_Configuration { /* Check if a directory is configured in the configuration * file. */ - $dir = $this->getValue('basedir'); + $dir = $this->getString('basedir', NULL); if($dir !== NULL) { /* Add trailing slash if it is missing. */ if(substr($dir, -1) !== '/') { diff --git a/lib/SimpleSAML/Logger.php b/lib/SimpleSAML/Logger.php index 6b1ff431c..4a66f47f5 100644 --- a/lib/SimpleSAML/Logger.php +++ b/lib/SimpleSAML/Logger.php @@ -119,7 +119,7 @@ class SimpleSAML_Logger { /* * setting minimum log_level */ - self::$logLevel = $config->getValue('logging.level',LOG_INFO); + self::$logLevel = $config->getInteger('logging.level',LOG_INFO); $handler = strtolower($handler); diff --git a/lib/SimpleSAML/Logger/LoggingHandlerErrorLog.php b/lib/SimpleSAML/Logger/LoggingHandlerErrorLog.php index 0a9bddbff..7b50c488b 100644 --- a/lib/SimpleSAML/Logger/LoggingHandlerErrorLog.php +++ b/lib/SimpleSAML/Logger/LoggingHandlerErrorLog.php @@ -29,7 +29,7 @@ class SimpleSAML_Logger_LoggingHandlerErrorLog implements SimpleSAML_Logger_Logg function log_internal($level, $string) { $config = SimpleSAML_Configuration::getInstance(); assert($config instanceof SimpleSAML_Configuration); - $processname = $config->getValue('logging.processname','simpleSAMLphp'); + $processname = $config->getString('logging.processname','simpleSAMLphp'); if(array_key_exists($level, self::$levelNames)) { $levelName = self::$levelNames[$level]; diff --git a/lib/SimpleSAML/Logger/LoggingHandlerFile.php b/lib/SimpleSAML/Logger/LoggingHandlerFile.php index f84d62811..41198a063 100644 --- a/lib/SimpleSAML/Logger/LoggingHandlerFile.php +++ b/lib/SimpleSAML/Logger/LoggingHandlerFile.php @@ -34,8 +34,8 @@ class SimpleSAML_Logger_LoggingHandlerFile implements SimpleSAML_Logger_LoggingH assert($config instanceof SimpleSAML_Configuration); /* Get the metadata handler option from the configuration. */ - $this->logFile = $config->getPathValue('loggingdir').$config->getValue('logging.logfile'); - $this->processname = $config->getValue('logging.processname','simpleSAMLphp'); + $this->logFile = $config->getPathValue('loggingdir', 'log/').$config->getString('logging.logfile', 'simplesamlphp.log'); + $this->processname = $config->getString('logging.processname','simpleSAMLphp'); if (@file_exists($this->logFile)) { if (!@is_writeable($this->logFile)) throw new Exception("Could not write to logfile: ".$this->logFile); diff --git a/lib/SimpleSAML/Logger/LoggingHandlerSyslog.php b/lib/SimpleSAML/Logger/LoggingHandlerSyslog.php index 2e8dcbb5e..562ca1213 100644 --- a/lib/SimpleSAML/Logger/LoggingHandlerSyslog.php +++ b/lib/SimpleSAML/Logger/LoggingHandlerSyslog.php @@ -16,9 +16,9 @@ class SimpleSAML_Logger_LoggingHandlerSyslog implements SimpleSAML_Logger_Loggin function __construct() { $config = SimpleSAML_Configuration::getInstance(); assert($config instanceof SimpleSAML_Configuration); - $facility = $config->getValue('logging.facility'); + $facility = $config->getInteger('logging.facility', defined('LOG_LOCAL5') ? constant('LOG_LOCAL5') : LOG_USER); - $processname = $config->getValue('logging.processname','simpleSAMLphp'); + $processname = $config->getString('logging.processname','simpleSAMLphp'); /* * OS Check * Setting facility to LOG_USER (only valid in Windows), enable log level rewrite on windows systems. diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php b/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php index eb088b28d..7d39cc810 100644 --- a/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php +++ b/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php @@ -49,21 +49,14 @@ class SimpleSAML_Metadata_MetaDataStorageHandler { $config = SimpleSAML_Configuration::getInstance(); - $sourcesConfig = $config->getValue('metadata.sources', NULL); + $sourcesConfig = $config->getArray('metadata.sources', NULL); /* For backwards compatibility, and to provide a default configuration. */ if($sourcesConfig === NULL) { - $type = $config->getValue('metadata.handler', 'flatfile'); + $type = $config->getString('metadata.handler', 'flatfile'); $sourcesConfig = array(array('type' => $type)); } - if(!is_array($sourcesConfig)) { - throw new Exception( - 'Invalid configuration of the \'metadata.sources\' configuration option.' . - ' This option should be an array.' - ); - } - try { $this->sources = SimpleSAML_Metadata_MetaDataStorageSource::parseSources($sourcesConfig); } catch (Exception $e) { diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerFlatFile.php b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerFlatFile.php index a220043b8..6c33ec42f 100644 --- a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerFlatFile.php +++ b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerFlatFile.php @@ -55,7 +55,7 @@ class SimpleSAML_Metadata_MetaDataStorageHandlerFlatFile extends SimpleSAML_Meta if(array_key_exists('directory', $config)) { $this->directory = $config['directory']; } else { - $this->directory = $globalConfig->getValue('metadatadir', 'metadata/'); + $this->directory = $globalConfig->getString('metadatadir', 'metadata/'); } /* Resolve this directory relative to the simpleSAMLphp directory (unless it is diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerSAML2Meta.php b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerSAML2Meta.php index 6b6f03218..fe352e72e 100644 --- a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerSAML2Meta.php +++ b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerSAML2Meta.php @@ -58,7 +58,7 @@ class SimpleSAML_Metadata_MetaDataStorageHandlerSAML2Meta extends SimpleSAML_Met // The metadata location is an URL $metadatasetfile = $metadatalocation; } else { - $metadatasetfile = $config->getPathValue('metadatadir') . $metadatalocation; + $metadatasetfile = $config->getPathValue('metadatadir', 'metadata/') . $metadatalocation; if (!file_exists($metadatasetfile)) throw new Exception('Could not find SAML 2.0 Metadata file :'. $metadatasetfile); if (preg_match('@\.php$@', $metadatalocation)) { $xml = false; diff --git a/lib/SimpleSAML/Metadata/Signer.php b/lib/SimpleSAML/Metadata/Signer.php index 8d433aea0..bd81709f2 100644 --- a/lib/SimpleSAML/Metadata/Signer.php +++ b/lib/SimpleSAML/Metadata/Signer.php @@ -46,8 +46,8 @@ class SimpleSAML_Metadata_Signer { } /* Then we look for default values in the global configuration. */ - $privatekey = $config->getValue('metadata.sign.privatekey', NULL); - $certificate = $config->getValue('metadata.sign.certificate', NULL); + $privatekey = $config->getString('metadata.sign.privatekey', NULL); + $certificate = $config->getString('metadata.sign.certificate', NULL); if($privatekey !== NULL || $certificate !== NULL) { if($privatekey === NULL || $certificate === NULL) { throw new Exception('Missing either the "metadata.sign.privatekey" or the' . @@ -57,7 +57,7 @@ class SimpleSAML_Metadata_Signer { } $ret = array('privatekey' => $privatekey, 'certificate' => $certificate); - $privatekey_pass = $config->getValue('metadata.sign.privatekey_pass', NULL); + $privatekey_pass = $config->getString('metadata.sign.privatekey_pass', NULL); if($privatekey_pass !== NULL) { $ret['privatekey_pass'] = $privatekey_pass; } @@ -115,11 +115,7 @@ class SimpleSAML_Metadata_Signer { return $entityMetadata['metadata.sign.enable']; } - $enabled = $config->getValue('metadata.sign.enable', FALSE); - if(!is_bool($enabled)) { - throw new Exception('Invalid value for the "metadata.sign.enable" configuration option.' . - ' This option should be a boolean.'); - } + $enabled = $config->getBoolean('metadata.sign.enable', FALSE); return $enabled; } @@ -147,13 +143,13 @@ class SimpleSAML_Metadata_Signer { $keyCertFiles = self::findKeyCert($config, $entityMetadata, $type); - $keyFile = $config->getPathValue('certdir') . $keyCertFiles['privatekey']; + $keyFile = $config->getPathValue('certdir', 'cert/') . $keyCertFiles['privatekey']; if (!file_exists($keyFile)) { throw new Exception('Could not find private key file [' . $keyFile . '], which is needed to sign the metadata'); } $keyData = file_get_contents($keyFile); - $certFile = $config->getPathValue('certdir') . $keyCertFiles['certificate']; + $certFile = $config->getPathValue('certdir', 'cert/') . $keyCertFiles['certificate']; if (!file_exists($certFile)) { throw new Exception('Could not find certificate file [' . $certFile . '], which is needed to sign the metadata'); } diff --git a/lib/SimpleSAML/Session.php b/lib/SimpleSAML/Session.php index 025a9d6ec..5d8c19af0 100644 --- a/lib/SimpleSAML/Session.php +++ b/lib/SimpleSAML/Session.php @@ -95,7 +95,7 @@ class SimpleSAML_Session { private function __construct() { $configuration = SimpleSAML_Configuration::getInstance(); - $this->sessionduration = $configuration->getValue('session.duration'); + $this->sessionduration = $configuration->getInteger('session.duration', 8*60*60); $this->trackid = SimpleSAML_Utilities::generateTrackID(); @@ -736,16 +736,16 @@ class SimpleSAML_Session { $configuration = SimpleSAML_Configuration::getInstance(); - $timeout = $configuration->getValue('session.datastore.timeout', NULL); + $timeout = $configuration->getInteger('session.datastore.timeout', NULL); if($timeout !== NULL) { - if(!is_int($timeout) || $timeout <= 0) { + if ($timeout <= 0) { throw new Exception('The value of the session.datastore.timeout' . ' configuration option should be a positive integer.'); } } else { /* For backwards compatibility. */ - $timeout = $configuration->getValue('session.requestcache', 4*(60*60)); - if(!is_int($timeout) || $timeout <= 0) { + $timeout = $configuration->getInteger('session.requestcache', 4*(60*60)); + if ($timeout <= 0) { throw new Exception('The value of the session.requestcache' . ' configuration option should be a positive integer.'); } diff --git a/lib/SimpleSAML/SessionHandlerPHP.php b/lib/SimpleSAML/SessionHandlerPHP.php index 6c4a102c7..6a2eae69b 100644 --- a/lib/SimpleSAML/SessionHandlerPHP.php +++ b/lib/SimpleSAML/SessionHandlerPHP.php @@ -33,13 +33,13 @@ class SimpleSAML_SessionHandlerPHP extends SimpleSAML_SessionHandler { if(session_id() === '') { $config = SimpleSAML_Configuration::getInstance(); - $cookiepath = ($config->getValue('session.phpsession.limitedpath', FALSE) ? '/' . $config->getValue('baseurlpath') : '/'); + $cookiepath = ($config->getBoolean('session.phpsession.limitedpath', FALSE) ? '/' . $config->getBaseURL() : '/'); session_set_cookie_params(0, $cookiepath, NULL, SimpleSAML_Utilities::isHTTPS()); - $cookiename = $config->getValue('session.phpsession.cookiename', NULL); + $cookiename = $config->getString('session.phpsession.cookiename', NULL); if (!empty($cookiename)) session_name($cookiename); - $savepath = $config->getValue('session.phpsession.savepath', NULL); + $savepath = $config->getString('session.phpsession.savepath', NULL); if(!empty($savepath)) { session_save_path($savepath); } diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php index 931faacd7..a38c1a289 100644 --- a/lib/SimpleSAML/Utilities.php +++ b/lib/SimpleSAML/Utilities.php @@ -556,10 +556,10 @@ class SimpleSAML_Utilities { $t->data['errorcode'] = $errorcode; $t->data['parameters'] = $parameters; - $t->data['showerrors'] = $config->getValue('showerrors', true); + $t->data['showerrors'] = $config->getBoolean('showerrors', true); /* Check if there is a valid technical contact email address. */ - if($config->getValue('technicalcontact_email', 'na@example.org') !== 'na@example.org') { + if($config->getString('technicalcontact_email', 'na@example.org') !== 'na@example.org') { /* Enable error reporting. */ $baseurl = SimpleSAML_Utilities::selfURLhost() . '/' . $config->getBaseURL(); $t->data['errorreportaddress'] = $baseurl . 'errorreport.php'; @@ -583,7 +583,7 @@ class SimpleSAML_Utilities { $t->data['trackid'] = $trackid; - $t->data['version'] = $config->getValue('version', 'na'); + $t->data['version'] = $config->getString('version', 'na'); $t->data['url'] = self::selfURLNoQuery(); $t->show(); @@ -1005,18 +1005,13 @@ class SimpleSAML_Utilities { throw new Exception('XML contained a doctype declaration.'); } - $enabled = SimpleSAML_Configuration::getInstance()->getValue('debug.validatexml', NULL); + $enabled = SimpleSAML_Configuration::getInstance()->getBoolean('debug.validatexml', NULL); if($enabled === NULL) { /* Fall back to old configuration option. */ - $enabled = SimpleSAML_Configuration::getInstance()->getValue('debug.validatesamlmessages', NULL); + $enabled = SimpleSAML_Configuration::getInstance()->getBoolean('debug.validatesamlmessages', NULL); if($enabled === NULL) { /* Fall back to even older configuration option. */ - $enabled = SimpleSAML_Configuration::getInstance()->getValue('debug.validatesaml2messages', FALSE); - if(!is_bool($enabled)) { - throw new Exception('Expected "debug.validatesaml2messages" to be set to a boolean value.'); - } - } elseif(!is_bool($enabled)) { - throw new Exception('Expected "debug.validatexml" to be set to a boolean value.'); + $enabled = SimpleSAML_Configuration::getInstance()->getBoolean('debug.validatesaml2messages', FALSE); } } @@ -1468,7 +1463,7 @@ class SimpleSAML_Utilities { } elseif (array_key_exists($prefix . 'certificate', $metadata)) { /* Reference to certificate file. */ $config = SimpleSAML_Configuration::getInstance(); - $file = $config->getPathValue('certdir') . $metadata[$prefix . 'certificate']; + $file = $config->getPathValue('certdir', 'cert/') . $metadata[$prefix . 'certificate']; $data = @file_get_contents($file); if ($data === FALSE) { throw new Exception('Unable to load certificate/public key from file "' . $file . '"'); @@ -1555,7 +1550,7 @@ class SimpleSAML_Utilities { } $config = SimpleSAML_Configuration::getInstance(); - $file = $config->getPathValue('certdir') . $metadata[$prefix . 'privatekey']; + $file = $config->getPathValue('certdir', 'cert/') . $metadata[$prefix . 'privatekey']; $data = @file_get_contents($file); if ($data === FALSE) { throw new Exception('Unable to load private key from file "' . $file . '"'); diff --git a/lib/SimpleSAML/XHTML/IdPDisco.php b/lib/SimpleSAML/XHTML/IdPDisco.php index ff76dae69..0bc2c3869 100644 --- a/lib/SimpleSAML/XHTML/IdPDisco.php +++ b/lib/SimpleSAML/XHTML/IdPDisco.php @@ -399,8 +399,8 @@ class SimpleSAML_XHTML_IdPDisco { $idp = $this->getTargetIdp(); if($idp !== NULL) { - if ($this->config->getValue('idpdisco.extDiscoveryStorage', NULL) != NULL) { - $extDiscoveryStorage = $this->config->getValue('idpdisco.extDiscoveryStorage'); + if ($this->config->getBoolean('idpdisco.extDiscoveryStorage', NULL) != NULL) { + $extDiscoveryStorage = $this->config->getBoolean('idpdisco.extDiscoveryStorage'); $this->log('Choice made [' . $idp . '] (Forwarding to external discovery storage)'); SimpleSAML_Utilities::redirect($extDiscoveryStorage, array( // $this->returnIdParam => $idp, diff --git a/lib/SimpleSAML/XHTML/Template.php b/lib/SimpleSAML/XHTML/Template.php index 2a948871b..58b98d40c 100644 --- a/lib/SimpleSAML/XHTML/Template.php +++ b/lib/SimpleSAML/XHTML/Template.php @@ -123,7 +123,7 @@ class SimpleSAML_XHTML_Template { * languages in the header were available. */ private function getHTTPLanguage() { - $availableLanguages = $this->configuration->getValue('language.available'); + $availableLanguages = $this->configuration->getArray('language.available', array('en')); $languageScore = SimpleSAML_Utilities::getAcceptLanguage(); /* For now we only use the default language map. We may use a configurable language map @@ -172,14 +172,14 @@ class SimpleSAML_XHTML_Template { * Returns the language default (from configuration) */ private function getDefaultLanguage() { - return $this->configuration->getValue('language.default', 'en'); + return $this->configuration->getString('language.default', 'en'); } /** * Returns a list of all available languages. */ private function getLanguageList() { - $availableLanguages = $this->configuration->getValue('language.available'); + $availableLanguages = $this->configuration->getArray('language.available', array('en')); $thisLang = $this->getLanguage(); $lang = array(); foreach ($availableLanguages AS $nl) { @@ -221,7 +221,7 @@ class SimpleSAML_XHTML_Template { $fileName = substr($name, $sepPos + 1); $dictDir = SimpleSAML_Module::getModuleDir($module) . '/dictionaries/'; } else { - $dictDir = $this->configuration->getPathValue('dictionarydir'); + $dictDir = $this->configuration->getPathValue('dictionarydir', 'dictionaries/'); $fileName = $name; } $this->dictionaries[$name] = $this->readDictionaryFile($dictDir . $fileName . '.php'); @@ -418,9 +418,9 @@ class SimpleSAML_XHTML_Template { $filebase = null; if (!empty($otherConfig)) { - $filebase = $otherConfig->getPathValue('dictionarydir'); + $filebase = $otherConfig->getPathValue('dictionarydir', 'dictionaries/'); } else { - $filebase = $this->configuration->getPathValue('dictionarydir'); + $filebase = $this->configuration->getPathValue('dictionarydir', 'dictionaries/'); } @@ -493,7 +493,7 @@ class SimpleSAML_XHTML_Template { $templateName = $tmp[0]; } - $tmp = explode(':', $this->configuration->getValue('theme.use'), 2); + $tmp = explode(':', $this->configuration->getString('theme.use', 'default'), 2); if (count($tmp) === 2) { $themeModule = $tmp[0]; $themeName = $tmp[1]; @@ -515,7 +515,7 @@ class SimpleSAML_XHTML_Template { } else { /* .../templates/<theme>/<templateName> */ - $filename = $this->configuration->getPathValue('templatedir') . $templateName; + $filename = $this->configuration->getPathValue('templatedir', 'templates/') . $templateName; } if (file_exists($filename)) { @@ -529,14 +529,14 @@ class SimpleSAML_XHTML_Template { /* Try default theme. */ - $baseTheme = $this->configuration->getValue('theme.base'); + $baseTheme = $this->configuration->getString('theme.base', 'default'); if ($templateModule !== 'default') { /* .../module/<templateModule>/templates/<baseTheme>/<templateName> */ $filename = SimpleSAML_Module::getModuleDir($templateModule) . '/templates/' . $templateName; } else { /* .../templates/<baseTheme>/<templateName> */ - $filename = $this->configuration->getPathValue('templatedir') . '/' . $templateName; + $filename = $this->configuration->getPathValue('templatedir', 'templates/') . '/' . $templateName; } if (file_exists($filename)) { diff --git a/lib/SimpleSAML/XML/Shib13/AuthnResponse.php b/lib/SimpleSAML/XML/Shib13/AuthnResponse.php index bac77ac1e..e1b7c564f 100644 --- a/lib/SimpleSAML/XML/Shib13/AuthnResponse.php +++ b/lib/SimpleSAML/XML/Shib13/AuthnResponse.php @@ -50,7 +50,7 @@ class SimpleSAML_XML_Shib13_AuthnResponse extends SimpleSAML_XML_AuthnResponse { $this->validator->validateFingerprint($issuerFingerprint); } elseif(array_key_exists('caFile', $md)) { /* Validate against CA. */ - $this->validator->validateCA($this->configuration->getPathValue('certdir') . $md['caFile']); + $this->validator->validateCA($this->configuration->getPathValue('certdir', 'cert/') . $md['caFile']); } else { throw new Exception('Required field [certFingerprint] or [caFile] in Shibboleth 1.3 IdP Remote metadata was not found for identity provider [' . $issuer . ']. Please add a fingerprint and try again. You can add a dummy fingerprint first, and then an error message will be printed with the real fingerprint.'); } diff --git a/lib/SimpleSAML/XML/Signer.php b/lib/SimpleSAML/XML/Signer.php index efbf0d8ef..f07f48b02 100644 --- a/lib/SimpleSAML/XML/Signer.php +++ b/lib/SimpleSAML/XML/Signer.php @@ -60,7 +60,7 @@ class SimpleSAML_XML_Signer { if(self::$certDir === FALSE) { $config = SimpleSAML_Configuration::getInstance(); - self::$certDir = $config->getPathValue('certdir'); + self::$certDir = $config->getPathValue('certdir', 'cert/'); } $this->idAttrName = FALSE; diff --git a/modules/adfs/www/idp/prp.php b/modules/adfs/www/idp/prp.php index 4bdf238f2..9f0cbb101 100644 --- a/modules/adfs/www/idp/prp.php +++ b/modules/adfs/www/idp/prp.php @@ -259,7 +259,7 @@ if (!$session->isValid($authority) ) { } $response = ADFS_GenerateResponse($idpentityid, $spentityid, $nameid, $attributes); - $wresult = ADFS_SignResponse($response, $config->getPathValue('certdir') . $adfsconfig->getValue('key'), $config->getPathValue('certdir') . $adfsconfig->getValue('cert')); + $wresult = ADFS_SignResponse($response, $config->getPathValue('certdir', 'cert/') . $adfsconfig->getValue('key'), $config->getPathValue('certdir', 'cert/') . $adfsconfig->getValue('cert')); ADFS_PostResponse($spmetadata->getValue('prp'), $wresult, $relayState); diff --git a/modules/consentAdmin/www/consentAdmin.php b/modules/consentAdmin/www/consentAdmin.php index 9204d15fb..a3457010e 100644 --- a/modules/consentAdmin/www/consentAdmin.php +++ b/modules/consentAdmin/www/consentAdmin.php @@ -239,7 +239,7 @@ foreach ($all_sp_metadata as $sp_entityid => $sp_values) { $relaystate = $cA_config->getValue('relaystate'); $et->data['header'] = 'Consent Administration'; -$et->data['logout'] = '<p>[ <a href="/' . $config->getValue('baseurlpath') . 'saml2/sp/initSLO.php?RelayState='. $relaystate .'">Logout</a> ]'; +$et->data['logout'] = '<p>[ <a href="/' . $config->getBaseURL() . 'saml2/sp/initSLO.php?RelayState='. $relaystate .'">Logout</a> ]'; $et->data['spList'] = $sp_list; $et->show(); ?> diff --git a/modules/core/hooks/hook_sanitycheck.php b/modules/core/hooks/hook_sanitycheck.php index 905580156..132e2ee26 100644 --- a/modules/core/hooks/hook_sanitycheck.php +++ b/modules/core/hooks/hook_sanitycheck.php @@ -11,13 +11,13 @@ function core_hook_sanitycheck(&$hookinfo) { $config = SimpleSAML_Configuration::getInstance(); - if($config->getValue('auth.adminpassword', '123') === '123') { + if($config->getString('auth.adminpassword', '123') === '123') { $hookinfo['errors'][] = '[core] Password in config.php is not set properly'; } else { $hookinfo['info'][] = '[core] Password in config.php is set properly'; } - if($config->getValue('technicalcontact_email', 'na@example.org') === 'na@example.org') { + if($config->getString('technicalcontact_email', 'na@example.org') === 'na@example.org') { $hookinfo['errors'][] = '[core] In config.php technicalcontact_email is not set properly'; } else { $hookinfo['info'][] = '[core] In config.php technicalcontact_email is set properly'; diff --git a/modules/core/lib/Auth/Process/AttributeMap.php b/modules/core/lib/Auth/Process/AttributeMap.php index b9a8f3170..a2d0ac26a 100644 --- a/modules/core/lib/Auth/Process/AttributeMap.php +++ b/modules/core/lib/Auth/Process/AttributeMap.php @@ -53,7 +53,7 @@ class sspmod_core_Auth_Process_AttributeMap extends SimpleSAML_Auth_ProcessingFi */ private function loadMapFile($fileName) { $config = SimpleSAML_Configuration::getInstance(); - $filePath = $config->getPathValue('attributenamemapdir') . $fileName . '.php'; + $filePath = $config->getPathValue('attributenamemapdir', 'attributemap/') . $fileName . '.php'; if(!file_exists($filePath)) { throw new Exception('Could not find attributemap file: ' . $filePath); diff --git a/modules/cron/www/cron.php b/modules/cron/www/cron.php index 38076c58e..052757a13 100644 --- a/modules/cron/www/cron.php +++ b/modules/cron/www/cron.php @@ -39,7 +39,7 @@ if ($cronconfig->getValue('sendemail', TRUE) && count($summary) > 0) { '<p>URL: <tt>' . SimpleSAML_Utilities::selfURL() . '</tt></p>' . '<p>Tag: ' . $_REQUEST['tag'] . "</p>\n\n" . $statustext; - $toaddress = $config->getValue('technicalcontact_email', 'na@example.org'); + $toaddress = $config->getString('technicalcontact_email', 'na@example.org'); if($toaddress == 'na@example.org') { SimpleSAML_Logger::error('Cron - Could not send email. [technicalcontact_email] not set in config.'); } else { diff --git a/modules/discopower/lib/PowerIdPDisco.php b/modules/discopower/lib/PowerIdPDisco.php index ceb465c48..e49b134f6 100644 --- a/modules/discopower/lib/PowerIdPDisco.php +++ b/modules/discopower/lib/PowerIdPDisco.php @@ -133,8 +133,8 @@ class sspmod_discopower_PowerIdPDisco extends SimpleSAML_XHTML_IdPDisco { $idp = $this->getTargetIdp(); if($idp !== NULL) { - if ($this->config->getValue('idpdisco.extDiscoveryStorage', NULL) != NULL) { - $extDiscoveryStorage = $this->config->getValue('idpdisco.extDiscoveryStorage'); + if ($this->config->getBoolean('idpdisco.extDiscoveryStorage', NULL) != NULL) { + $extDiscoveryStorage = $this->config->getBoolean('idpdisco.extDiscoveryStorage'); $this->log('Choice made [' . $idp . '] (Forwarding to external discovery storage)'); SimpleSAML_Utilities::redirect($extDiscoveryStorage, array( 'entityID' => $this->spEntityId, diff --git a/modules/saml2/lib/Message.php b/modules/saml2/lib/Message.php index 68b65ca9c..369006286 100644 --- a/modules/saml2/lib/Message.php +++ b/modules/saml2/lib/Message.php @@ -22,7 +22,7 @@ class sspmod_saml2_Message { public static function getDebugDestination() { $globalConfig = SimpleSAML_Configuration::getInstance(); - if (!$globalConfig->getValue('debug')) { + if (!$globalConfig->getBoolean('debug', FALSE)) { return NULL; } @@ -165,7 +165,7 @@ class sspmod_saml2_Message { var_export($srcMetadata->getString('entityid'), TRUE)); } $globalConfig = SimpleSAML_Configuration::getInstance(); - $caFile = $globalConfig->getPathValue('certdir') . $caFile; + $caFile = $globalConfig->getPathValue('certdir', 'cert/') . $caFile; if (count($certificates) === 0) { /* We need the full certificate in order to check it against the CA file. */ @@ -528,7 +528,7 @@ class sspmod_saml2_Message { $a->setAuthnContext(SAML2_Const::AC_PASSWORD); - $sessionLifetime = $config->getInteger('session.duration', 3600); + $sessionLifetime = $config->getInteger('session.duration', 8*60*60); $a->setSessionNotOnOrAfter(time() + $sessionLifetime); $session = SimpleSAML_Session::getInstance(); diff --git a/modules/saml2/www/sp/metadata.php b/modules/saml2/www/sp/metadata.php index 77f542c93..b3462d630 100644 --- a/modules/saml2/www/sp/metadata.php +++ b/modules/saml2/www/sp/metadata.php @@ -28,8 +28,8 @@ $metaBuilder->addMetadataSP20($metaArray); $config = SimpleSAML_Configuration::getInstance(); $metaBuilder->addContact('technical', array( - 'emailAddress' => $config->getValue('technicalcontact_email'), - 'name' => $config->getValue('technicalcontact_name'), + 'emailAddress' => $config->getString('technicalcontact_email', NULL), + 'name' => $config->getString('technicalcontact_name', NULL), )); $xml = $metaBuilder->getEntityDescriptorText(); diff --git a/www/admin/metadata.php b/www/admin/metadata.php index ec8aa9cc0..91e1d22fd 100644 --- a/www/admin/metadata.php +++ b/www/admin/metadata.php @@ -18,7 +18,7 @@ try { $et = new SimpleSAML_XHTML_Template($config, 'admin-metadatalist.php', 'admin'); - if ($config->getValue('enable.saml20-sp') === true) { + if ($config->getBoolean('enable.saml20-sp', TRUE) === true) { $results = array(); $metalist = $metadata->getList('saml20-sp-hosted'); @@ -48,7 +48,7 @@ try { } - if ($config->getValue('enable.saml20-idp') === true) { + if ($config->getBoolean('enable.saml20-idp', FALSE) === true) { $results = array(); $metalist = $metadata->getList('saml20-idp-hosted'); foreach ($metalist AS $entityid => $mentry) { @@ -74,7 +74,7 @@ try { - if ($config->getValue('enable.shib13-sp') === true) { + if ($config->getBoolean('enable.shib13-sp', FALSE) === true) { $results = array(); $metalist = $metadata->getList('shib13-sp-hosted'); @@ -98,7 +98,7 @@ try { } - if ($config->getValue('enable.shib13-idp') === true) { + if ($config->getBoolean('enable.shib13-idp', FALSE) === true) { $results = array(); $metalist = $metadata->getList('shib13-idp-hosted'); foreach ($metalist AS $entityid => $mentry) { @@ -121,7 +121,7 @@ try { } - if ($config->getValue('enable.wsfed-sp') === true) { + if ($config->getBoolean('enable.wsfed-sp', FALSE) === true) { $results = array(); $metalist = $metadata->getList('wsfed-sp-hosted'); foreach ($metalist AS $entityid => $mentry) { diff --git a/www/auth/login-admin.php b/www/auth/login-admin.php index 2e9fc1eaa..b68c265d1 100644 --- a/www/auth/login-admin.php +++ b/www/auth/login-admin.php @@ -28,7 +28,7 @@ if (!array_key_exists('RelayState', $_REQUEST)) { $relaystate = $_REQUEST['RelayState']; -$correctpassword = $config->getValue('auth.adminpassword', '123'); +$correctpassword = $config->getString('auth.adminpassword', '123'); if (empty($correctpassword) or $correctpassword === '123') { SimpleSAML_Utilities::fatalError( diff --git a/www/authmemcookie.php b/www/authmemcookie.php index db8ab9a00..fde955233 100644 --- a/www/authmemcookie.php +++ b/www/authmemcookie.php @@ -18,7 +18,7 @@ try { $session = SimpleSAML_Session::getInstance(); /* Check if this module is enabled. */ - if(!$globalConfig->getValue('enable.authmemcookie', FALSE)) { + if(!$globalConfig->getBoolean('enable.authmemcookie', FALSE)) { SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NOACCESS'); } diff --git a/www/errorreport.php b/www/errorreport.php index 28ab5d168..2661dcc3c 100644 --- a/www/errorreport.php +++ b/www/errorreport.php @@ -94,7 +94,7 @@ if(array_key_exists('email', $_POST)) { } /* Send the email. */ -$toaddress = $config->getValue('technicalcontact_email', 'na@example.org'); +$toaddress = $config->getString('technicalcontact_email', 'na@example.org'); if($email !== 'na@example.org') { $email = new SimpleSAML_XHTML_EMail($email, 'simpleSAMLphp error report', $from); diff --git a/www/index.php b/www/index.php index fd5a8010e..510d43e18 100644 --- a/www/index.php +++ b/www/index.php @@ -7,7 +7,7 @@ $config = SimpleSAML_Configuration::getInstance(); $session = SimpleSAML_Session::getInstance(); /* Check if valid local session exists.. */ -if ($config->getValue('admin.protectindexpage', false)) { +if ($config->getBoolean('admin.protectindexpage', false)) { SimpleSAML_Utilities::requireAdmin(); } $loginurl = SimpleSAML_Utilities::getAdminLoginURL(); @@ -24,12 +24,12 @@ if (SimpleSAML_Utilities::getSelfProtocol() != 'https') { $links = array(); -if ($config->getValue('enable.saml20-sp') === true) +if ($config->getBoolean('enable.saml20-sp', TRUE) === true) $links[] = array( 'href' => 'example-simple/saml2-example.php', 'text' => 'link_saml2example'); -if ($config->getValue('enable.shib13-sp') === true) +if ($config->getBoolean('enable.shib13-sp', FALSE) === true) $links[] = array( 'href' => 'example-simple/shib13-example.php', 'text' => 'link_shib13example' @@ -122,7 +122,7 @@ $linksmeta[] = array( $metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler(); $metaentries = array('hosted' => array(), 'remote' => array() ); -if ($config->getValue('enable.saml20-sp') === true) { +if ($config->getBoolean('enable.saml20-sp', TRUE) === true) { try { $metaentries['hosted']['saml20-sp'] = $metadata->getMetaDataCurrent('saml20-sp-hosted'); $metaentries['hosted']['saml20-sp']['metadata-url'] = '/' . $config->getBaseURL() . 'saml2/sp/metadata.php?output=xhtml'; @@ -130,7 +130,7 @@ if ($config->getValue('enable.saml20-sp') === true) { $metaentries['remote']['saml20-idp-remote'] = $metadata->getList('saml20-idp-remote'); } catch(Exception $e) {} } -if ($config->getValue('enable.saml20-idp') === true) { +if ($config->getBoolean('enable.saml20-idp', FALSE) === true) { try { $metaentries['hosted']['saml20-idp'] = $metadata->getMetaDataCurrent('saml20-idp-hosted'); $metaentries['hosted']['saml20-idp']['metadata-url'] = '/' . $config->getBaseURL() . 'saml2/idp/metadata.php?output=xhtml'; @@ -138,7 +138,7 @@ if ($config->getValue('enable.saml20-idp') === true) { $metaentries['remote']['saml20-sp-remote'] = $metadata->getList('saml20-sp-remote'); } catch(Exception $e) {} } -if ($config->getValue('enable.shib13-sp') === true) { +if ($config->getBoolean('enable.shib13-sp', FALSE) === true) { try { $metaentries['hosted']['shib13-sp'] = $metadata->getMetaDataCurrent('shib13-sp-hosted'); $metaentries['hosted']['shib13-sp']['metadata-url'] = '/' . $config->getBaseURL() . 'shib13/sp/metadata.php?output=xhtml'; @@ -146,7 +146,7 @@ if ($config->getValue('enable.shib13-sp') === true) { $metaentries['remote']['shib13-idp-remote'] = $metadata->getList('shib13-idp-remote'); } catch(Exception $e) {} } -if ($config->getValue('enable.shib13-idp') === true) { +if ($config->getBoolean('enable.shib13-idp', FALSE) === true) { try { $metaentries['hosted']['shib13-idp'] = $metadata->getMetaDataCurrent('shib13-idp-hosted'); $metaentries['hosted']['shib13-idp']['metadata-url'] = '/' . $config->getBaseURL() . 'shib13/idp/metadata.php?output=xhtml'; @@ -166,22 +166,22 @@ $linksdoc[] = array( 'href' => 'http://rnd.feide.no/content/installing-simplesamlphp', 'text' => 'link_doc_install'); -if ($config->getValue('enable.saml20-sp', false ) || $config->getValue('enable.shib13-sp', false)) +if ($config->getBoolean('enable.saml20-sp', TRUE) || $config->getBoolean('enable.shib13-sp', false)) $linksdoc[] = array( 'href' => 'http://rnd.feide.no/content/using-simplesamlphp-service-provider', 'text' => 'link_doc_sp'); -if ($config->getValue('enable.saml20-idp', false ) || $config->getValue('enable.shib13-idp', false)) +if ($config->getBoolean('enable.saml20-idp', false ) || $config->getBoolean('enable.shib13-idp', false)) $linksdoc[] = array( 'href' => 'http://rnd.feide.no/content/using-simplesamlphp-identity-provider', 'text' => 'link_doc_idp'); -if ($config->getValue('enable.shib13-idp', false)) +if ($config->getBoolean('enable.shib13-idp', false)) $linksdoc[] = array( 'href' => 'http://rnd.feide.no/content/configure-shibboleth-13-sp-work-simplesamlphp-idp', 'text' => 'link_doc_shibsp'); -if ($config->getValue('enable.saml20-idp', false )) +if ($config->getBoolean('enable.saml20-idp', false )) $linksdoc[] = array( 'href' => 'http://rnd.feide.no/content/simplesamlphp-idp-google-apps-education', 'text' => 'link_doc_googleapps'); @@ -207,10 +207,10 @@ $allLinks = array( SimpleSAML_Module::callHooks('frontpage', $allLinks); $enablematrix = array( - 'saml20-sp' => $config->getValue('enable.saml20-sp', false), - 'saml20-idp' => $config->getValue('enable.saml20-idp', false), - 'shib13-sp' => $config->getValue('enable.shib13-sp', false), - 'shib13-idp' => $config->getValue('enable.shib13-idp', false), + 'saml20-sp' => $config->getBoolean('enable.saml20-sp', TRUE), + 'saml20-idp' => $config->getBoolean('enable.saml20-idp', false), + 'shib13-sp' => $config->getBoolean('enable.shib13-sp', false), + 'shib13-idp' => $config->getBoolean('enable.shib13-idp', false), ); @@ -242,7 +242,7 @@ foreach ($functionchecks AS $func => $descr) { /* Some basic configuration checks */ -if($config->getValue('technicalcontact_email', 'na@example.org') === 'na@example.org') { +if($config->getString('technicalcontact_email', 'na@example.org') === 'na@example.org') { $mail_ok = FALSE; } else { $mail_ok = TRUE; @@ -252,7 +252,7 @@ $funcmatrix[] = array( 'descr' => 'technicalcontact_email option set', 'enabled' => $mail_ok ); -if($config->getValue('auth.adminpassword', '123') === '123') { +if($config->getString('auth.adminpassword', '123') === '123') { $password_ok = FALSE; } else { $password_ok = TRUE; diff --git a/www/saml2/idp/SSOService.php b/www/saml2/idp/SSOService.php index 3560c3a27..d9d78884c 100644 --- a/www/saml2/idp/SSOService.php +++ b/www/saml2/idp/SSOService.php @@ -30,7 +30,7 @@ try { SimpleSAML_Logger::info('SAML2.0 - IdP.SSOService: Accessing SAML 2.0 IdP endpoint SSOService'); -if (!$config->getValue('enable.saml20-idp', false)) +if (!$config->getBoolean('enable.saml20-idp', false)) SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NOACCESS'); diff --git a/www/saml2/idp/SingleLogoutService.php b/www/saml2/idp/SingleLogoutService.php index 764f8b063..a0aa2a5ce 100644 --- a/www/saml2/idp/SingleLogoutService.php +++ b/www/saml2/idp/SingleLogoutService.php @@ -19,7 +19,7 @@ $session = SimpleSAML_Session::getInstance(); SimpleSAML_Logger::info('SAML2.0 - IdP.SingleLogoutService: Accessing SAML 2.0 IdP endpoint SingleLogoutService'); -if (!$config->getValue('enable.saml20-idp', false)) +if (!$config->getBoolean('enable.saml20-idp', false)) SimpleSAML_Utilities::fatalError(isset($session) ? $session->getTrackID() : null, 'NOACCESS'); try { @@ -250,7 +250,7 @@ if ($spEntityId) { } } -if ($config->getValue('debug', false)) +if ($config->getBoolean('debug', false)) SimpleSAML_Logger::info('SAML2.0 - IdP.SingleLogoutService: LogoutService: All SPs done '); @@ -297,12 +297,12 @@ try { /** * Clean up session object to save storage. */ - if ($config->getValue('debug', false)) + if ($config->getBoolean('debug', false)) SimpleSAML_Logger::info('SAML2.0 - IdP.SingleLogoutService: Session Size before cleaning: ' . $session->getSize()); $session->clean(); - if ($config->getValue('debug', false)) + if ($config->getBoolean('debug', false)) SimpleSAML_Logger::info('SAML2.0 - IdP.SingleLogoutService: Session Size after cleaning: ' . $session->getSize()); diff --git a/www/saml2/idp/SingleLogoutServiceiFrame.php b/www/saml2/idp/SingleLogoutServiceiFrame.php index 144bf4329..4202c1a56 100644 --- a/www/saml2/idp/SingleLogoutServiceiFrame.php +++ b/www/saml2/idp/SingleLogoutServiceiFrame.php @@ -19,7 +19,7 @@ SimpleSAML_Logger::info('SAML2.0 - IdP.SingleLogoutServiceiFrame: Accessing SAML SimpleSAML_Logger::debug('Initially; ' . join(',', $session->get_sp_list(SimpleSAML_Session::STATE_ONLINE))); -if (!$config->getValue('enable.saml20-idp', false)) +if (!$config->getBoolean('enable.saml20-idp', false)) SimpleSAML_Utilities::fatalError(isset($session) ? $session->getTrackID() : null, 'NOACCESS'); try { @@ -145,12 +145,12 @@ function updateslostatus() { /** * Clean up session object to save storage. */ - if ($config->getValue('debug', false)) + if ($config->getBoolean('debug', false)) SimpleSAML_Logger::info('SAML2.0 - IdP.SingleLogoutService: Session Size before cleaning: ' . $session->getSize()); $session->clean(); - if ($config->getValue('debug', false)) + if ($config->getBoolean('debug', false)) SimpleSAML_Logger::info('SAML2.0 - IdP.SingleLogoutService: Session Size after cleaning: ' . $session->getSize()); } else { diff --git a/www/saml2/idp/SingleLogoutServiceiFrameNoJavascript.php b/www/saml2/idp/SingleLogoutServiceiFrameNoJavascript.php index 73a7b0147..c5a96ea3a 100644 --- a/www/saml2/idp/SingleLogoutServiceiFrameNoJavascript.php +++ b/www/saml2/idp/SingleLogoutServiceiFrameNoJavascript.php @@ -17,7 +17,7 @@ $session = SimpleSAML_Session::getInstance(); SimpleSAML_Logger::info('SAML2.0 - IdP.SingleLogoutServiceiFrame: Accessing SAML 2.0 IdP endpoint SingleLogoutService (iFrame version)'); -if (!$config->getValue('enable.saml20-idp', false)) +if (!$config->getBoolean('enable.saml20-idp', false)) SimpleSAML_Utilities::fatalError(isset($session) ? $session->getTrackID() : null, 'NOACCESS'); try { diff --git a/www/saml2/idp/SingleLogoutServiceiFrameResponse.php b/www/saml2/idp/SingleLogoutServiceiFrameResponse.php index 1012d3af7..ec72fb2e0 100644 --- a/www/saml2/idp/SingleLogoutServiceiFrameResponse.php +++ b/www/saml2/idp/SingleLogoutServiceiFrameResponse.php @@ -17,7 +17,7 @@ $session = SimpleSAML_Session::getInstance(); SimpleSAML_Logger::info('SAML2.0 - IdP.SingleLogoutServiceiFrameResponse: Accessing SAML 2.0 IdP endpoint SingleLogoutServiceResponse (iFrame version)'); -if (!$config->getValue('enable.saml20-idp', false)) +if (!$config->getBoolean('enable.saml20-idp', false)) SimpleSAML_Utilities::fatalError(isset($session) ? $session->getTrackID() : null, 'NOACCESS'); try { diff --git a/www/saml2/idp/idpInitSingleLogoutServiceiFrame.php b/www/saml2/idp/idpInitSingleLogoutServiceiFrame.php index b57d11d1d..c75dcdcf0 100644 --- a/www/saml2/idp/idpInitSingleLogoutServiceiFrame.php +++ b/www/saml2/idp/idpInitSingleLogoutServiceiFrame.php @@ -18,7 +18,7 @@ SimpleSAML_Logger::info('SAML2.0 - IdP.idpInitSingleLogoutServiceiFrame: Accessi SimpleSAML_Logger::debug('Initially; ' . join(',', $session->get_sp_list(SimpleSAML_Session::STATE_ONLINE))); -if (!$config->getValue('enable.saml20-idp', false)) +if (!$config->getBoolean('enable.saml20-idp', false)) SimpleSAML_Utilities::fatalError(isset($session) ? $session->getTrackID() : null, 'NOACCESS'); try { @@ -138,12 +138,12 @@ function updateslostatus() { /** * Clean up session object to save storage. */ - if ($config->getValue('debug', false)) + if ($config->getBoolean('debug', false)) SimpleSAML_Logger::info('SAML2.0 - IdP.SingleLogoutService: Session Size before cleaning: ' . $session->getSize()); $session->clean(); - if ($config->getValue('debug', false)) + if ($config->getBoolean('debug', false)) SimpleSAML_Logger::info('SAML2.0 - IdP.SingleLogoutService: Session Size after cleaning: ' . $session->getSize()); } else { diff --git a/www/saml2/idp/initSLO.php b/www/saml2/idp/initSLO.php index 118fcb308..a1e12f4bd 100644 --- a/www/saml2/idp/initSLO.php +++ b/www/saml2/idp/initSLO.php @@ -8,7 +8,7 @@ $session = SimpleSAML_Session::getInstance(); SimpleSAML_Logger::info('SAML2.0 - IdP.initSLO: Accessing SAML 2.0 IdP endpoint init Single Logout'); -if (!$config->getValue('enable.saml20-idp', false)) { +if (!$config->getBoolean('enable.saml20-idp', false)) { SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NOACCESS'); } diff --git a/www/saml2/idp/metadata.php b/www/saml2/idp/metadata.php index d24c73c80..3dbf323b0 100644 --- a/www/saml2/idp/metadata.php +++ b/www/saml2/idp/metadata.php @@ -7,11 +7,11 @@ $config = SimpleSAML_Configuration::getInstance(); $metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler(); $session = SimpleSAML_Session::getInstance(); -if (!$config->getValue('enable.saml20-idp', false)) +if (!$config->getBoolean('enable.saml20-idp', false)) SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NOACCESS'); /* Check if valid local session exists.. */ -if ($config->getValue('admin.protectmetadata', false)) { +if ($config->getBoolean('admin.protectmetadata', false)) { SimpleSAML_Utilities::requireAdmin(); } @@ -70,8 +70,8 @@ try { $metaBuilder = new SimpleSAML_Metadata_SAMLBuilder($idpentityid); $metaBuilder->addMetadataIdP20($metaArray); $metaBuilder->addContact('technical', array( - 'emailAddress' => $config->getValue('technicalcontact_email'), - 'name' => $config->getValue('technicalcontact_name'), + 'emailAddress' => $config->getString('technicalcontact_email', NULL), + 'name' => $config->getString('technicalcontact_name', NULL), )); $metaxml = $metaBuilder->getEntityDescriptorText(); @@ -79,7 +79,7 @@ try { $metaxml = SimpleSAML_Metadata_Signer::sign($metaxml, $idpmeta, 'SAML 2 IdP'); if (array_key_exists('output', $_GET) && $_GET['output'] == 'xhtml') { - $defaultidp = $config->getValue('default-saml20-idp'); + $defaultidp = $config->getString('default-saml20-idp', NULL); $t = new SimpleSAML_XHTML_Template($config, 'metadata.php', 'admin'); diff --git a/www/saml2/sp/AssertionConsumerService.php b/www/saml2/sp/AssertionConsumerService.php index f23b23139..f03dfbe3e 100644 --- a/www/saml2/sp/AssertionConsumerService.php +++ b/www/saml2/sp/AssertionConsumerService.php @@ -51,7 +51,7 @@ function finishLogin($authProcState) { SimpleSAML_Logger::info('SAML2.0 - SP.AssertionConsumerService: Accessing SAML 2.0 SP endpoint AssertionConsumerService'); -if (!$config->getValue('enable.saml20-sp', false)) +if (!$config->getBoolean('enable.saml20-sp', TRUE)) SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NOACCESS'); if (array_key_exists(SimpleSAML_Auth_ProcessingChain::AUTHPARAM, $_REQUEST)) { diff --git a/www/saml2/sp/SingleLogoutService.php b/www/saml2/sp/SingleLogoutService.php index fa382950e..bd870327b 100644 --- a/www/saml2/sp/SingleLogoutService.php +++ b/www/saml2/sp/SingleLogoutService.php @@ -11,7 +11,7 @@ $session = SimpleSAML_Session::getInstance(); SimpleSAML_Logger::info('SAML2.0 - SP.SingleLogoutService: Accessing SAML 2.0 SP endpoint SingleLogoutService'); -if (!$config->getValue('enable.saml20-sp', false)) +if (!$config->getBoolean('enable.saml20-sp', TRUE)) SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NOACCESS'); diff --git a/www/saml2/sp/initSLO.php b/www/saml2/sp/initSLO.php index b7256406e..410fa2411 100644 --- a/www/saml2/sp/initSLO.php +++ b/www/saml2/sp/initSLO.php @@ -8,7 +8,7 @@ $session = SimpleSAML_Session::getInstance(); SimpleSAML_Logger::info('SAML2.0 - SP.initSLO: Accessing SAML 2.0 SP initSLO script'); -if (!$config->getValue('enable.saml20-sp', false)) +if (!$config->getBoolean('enable.saml20-sp', TRUE)) SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NOACCESS'); diff --git a/www/saml2/sp/initSSO.php b/www/saml2/sp/initSSO.php index 2ad1bb53b..fecc8f4f4 100644 --- a/www/saml2/sp/initSSO.php +++ b/www/saml2/sp/initSSO.php @@ -9,7 +9,7 @@ $session = SimpleSAML_Session::getInstance(); SimpleSAML_Logger::info('SAML2.0 - SP.initSSO: Accessing SAML 2.0 SP initSSO script'); -if (!$config->getValue('enable.saml20-sp', false)) +if (!$config->getBoolean('enable.saml20-sp', TRUE)) SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NOACCESS'); /* @@ -26,7 +26,7 @@ if (empty($_GET['RelayState'])) { try { - $idpentityid = isset($_GET['idpentityid']) ? $_GET['idpentityid'] : $config->getValue('default-saml20-idp') ; + $idpentityid = isset($_GET['idpentityid']) ? $_GET['idpentityid'] : $config->getString('default-saml20-idp', NULL) ; $spentityid = isset($_GET['spentityid']) ? $_GET['spentityid'] : $metadata->getMetaDataCurrentEntityID(); if($idpentityid === NULL) { @@ -51,15 +51,15 @@ if ($idpentityid === NULL) { */ if(array_key_exists('idpdisco.url', $spmetadata)) { $discourl = $spmetadata['idpdisco.url']; - } elseif($config->getValue('idpdisco.url.saml20', NULL) !== NULL) { - $discourl = $config->getValue('idpdisco.url.saml20', NULL); + } elseif($config->getString('idpdisco.url.saml20', NULL) !== NULL) { + $discourl = $config->getString('idpdisco.url.saml20'); } else { $discourl = SimpleSAML_Utilities::selfURLhost() . '/' . $config->getBaseURL() . 'saml2/sp/idpdisco.php'; } - if ($config->getValue('idpdisco.extDiscoveryStorage', NULL) != NULL) { + if ($config->getBoolean('idpdisco.extDiscoveryStorage', NULL) != NULL) { - $extDiscoveryStorage = $config->getValue('idpdisco.extDiscoveryStorage'); + $extDiscoveryStorage = $config->getBoolean('idpdisco.extDiscoveryStorage'); SimpleSAML_Utilities::redirect($extDiscoveryStorage, array( 'entityID' => $spentityid, diff --git a/www/saml2/sp/metadata.php b/www/saml2/sp/metadata.php index 8c73dd208..90d017392 100644 --- a/www/saml2/sp/metadata.php +++ b/www/saml2/sp/metadata.php @@ -8,11 +8,11 @@ $metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler(); $session = SimpleSAML_Session::getInstance(); -if (!$config->getValue('enable.saml20-sp', false)) +if (!$config->getValue('enable.saml20-sp', TRUE)) SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NOACCESS'); /* Check if valid local session exists.. */ -if ($config->getValue('admin.protectmetadata', false)) { +if ($config->getBoolean('admin.protectmetadata', false)) { SimpleSAML_Utilities::requireAdmin(); } @@ -52,8 +52,8 @@ try { $metaBuilder = new SimpleSAML_Metadata_SAMLBuilder($spentityid); $metaBuilder->addMetadataSP20($metaArray); $metaBuilder->addContact('technical', array( - 'emailAddress' => $config->getValue('technicalcontact_email'), - 'name' => $config->getValue('technicalcontact_name'), + 'emailAddress' => $config->getString('technicalcontact_email', NULL), + 'name' => $config->getString('technicalcontact_name', NULL), )); $metaxml = $metaBuilder->getEntityDescriptorText(); @@ -142,7 +142,7 @@ try { if (array_key_exists('output', $_REQUEST) && $_REQUEST['output'] == 'xhtml') { - $defaultidp = $config->getValue('default-saml20-idp'); + $defaultidp = $config->getString('default-saml20-idp', NULL); $t = new SimpleSAML_XHTML_Template($config, 'metadata.php', 'admin'); @@ -156,9 +156,9 @@ try { $t->data['adminok'] = $adminok; $t->data['adminlogin'] = $adminlogin; - $t->data['techemail'] = $config->getValue('technicalcontact_email', NULL); + $t->data['techemail'] = $config->getString('technicalcontact_email', NULL); -// $t->data['version'] = $config->getValue('version', 'na'); +// $t->data['version'] = $config->getString('version', 'na'); // $t->data['defaultidp'] = $defaultidp; $t->show(); diff --git a/www/shib13/idp/SSOService.php b/www/shib13/idp/SSOService.php index bfb6c3d41..ce2b6bba4 100644 --- a/www/shib13/idp/SSOService.php +++ b/www/shib13/idp/SSOService.php @@ -18,7 +18,7 @@ $session = SimpleSAML_Session::getInstance(); SimpleSAML_Logger::info('Shib1.3 - IdP.SSOService: Accessing Shibboleth 1.3 IdP endpoint SSOService'); -if (!$config->getValue('enable.shib13-idp', false)) +if (!$config->getBoolean('enable.shib13-idp', false)) SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NOACCESS'); try { diff --git a/www/shib13/idp/metadata.php b/www/shib13/idp/metadata.php index 071ac2413..0ac1e2575 100644 --- a/www/shib13/idp/metadata.php +++ b/www/shib13/idp/metadata.php @@ -7,11 +7,11 @@ $config = SimpleSAML_Configuration::getInstance(); $metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler(); $session = SimpleSAML_Session::getInstance(); -if (!$config->getValue('enable.shib13-idp', false)) +if (!$config->getBoolean('enable.shib13-idp', false)) SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NOACCESS'); /* Check if valid local session exists.. */ -if ($config->getValue('admin.protectmetadata', false)) { +if ($config->getBoolean('admin.protectmetadata', false)) { SimpleSAML_Utilities::requireAdmin(); } @@ -55,8 +55,8 @@ try { $metaBuilder = new SimpleSAML_Metadata_SAMLBuilder($idpentityid); $metaBuilder->addMetadataIdP11($metaArray); $metaBuilder->addContact('technical', array( - 'emailAddress' => $config->getValue('technicalcontact_email'), - 'name' => $config->getValue('technicalcontact_name'), + 'emailAddress' => $config->getString('technicalcontact_email', NULL), + 'name' => $config->getString('technicalcontact_name', NULL), )); $metaxml = $metaBuilder->getEntityDescriptorText(); @@ -65,7 +65,7 @@ try { if (array_key_exists('output', $_GET) && $_GET['output'] == 'xhtml') { - $defaultidp = $config->getValue('default-shib13-idp'); + $defaultidp = $config->getString('default-shib13-idp', NULL); $t = new SimpleSAML_XHTML_Template($config, 'metadata.php', 'admin'); diff --git a/www/shib13/sp/AssertionConsumerService.php b/www/shib13/sp/AssertionConsumerService.php index c4948e459..3b4df64ef 100644 --- a/www/shib13/sp/AssertionConsumerService.php +++ b/www/shib13/sp/AssertionConsumerService.php @@ -39,7 +39,7 @@ function finishLogin($authProcState) { SimpleSAML_Logger::info('Shib1.3 - SP.AssertionConsumerService: Accessing Shibboleth 1.3 SP endpoint AssertionConsumerService'); -if (!$config->getValue('enable.shib13-sp', false)) +if (!$config->getBoolean('enable.shib13-sp', false)) SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NOACCESS'); if (array_key_exists(SimpleSAML_Auth_ProcessingChain::AUTHPARAM, $_REQUEST)) { diff --git a/www/shib13/sp/initSSO.php b/www/shib13/sp/initSSO.php index 00bc56846..3a3b185ec 100644 --- a/www/shib13/sp/initSSO.php +++ b/www/shib13/sp/initSSO.php @@ -20,13 +20,13 @@ $session = SimpleSAML_Session::getInstance(); SimpleSAML_Logger::info('Shib1.3 - SP.initSSO: Accessing Shib 1.3 SP initSSO script'); -if (!$config->getValue('enable.shib13-sp', false)) +if (!$config->getBoolean('enable.shib13-sp', false)) SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NOACCESS'); try { - $idpentityid = isset($_GET['idpentityid']) ? $_GET['idpentityid'] : $config->getValue('default-shib13-idp') ; + $idpentityid = isset($_GET['idpentityid']) ? $_GET['idpentityid'] : $config->getString('default-shib13-idp', NULL) ; $spentityid = isset($_GET['spentityid']) ? $_GET['spentityid'] : $metadata->getMetaDataCurrentEntityID('shib13-sp-hosted'); if($idpentityid === NULL) { @@ -52,8 +52,8 @@ if (!isset($session) || !$session->isValid('shib13') ) { */ if(array_key_exists('idpdisco.url', $spmetadata)) { $discservice = $spmetadata['idpdisco.url']; - } elseif($config->getValue('idpdisco.url.shib13', NULL) !== NULL) { - $discservice = $config->getValue('idpdisco.url.shib13', NULL); + } elseif($config->getString('idpdisco.url.shib13', NULL) !== NULL) { + $discservice = $config->getString('idpdisco.url.shib13'); } else { $discservice = '/' . $config->getBaseURL() . 'shib13/sp/idpdisco.php'; } diff --git a/www/shib13/sp/metadata.php b/www/shib13/sp/metadata.php index 39c92d540..489de92da 100644 --- a/www/shib13/sp/metadata.php +++ b/www/shib13/sp/metadata.php @@ -8,11 +8,11 @@ $metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler(); $session = SimpleSAML_Session::getInstance(); -if (!$config->getValue('enable.shib13-sp', false)) +if (!$config->getBoolean('enable.shib13-sp', false)) SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NOACCESS'); /* Check if valid local session exists.. */ -if ($config->getValue('admin.protectmetadata', false)) { +if ($config->getBoolean('admin.protectmetadata', false)) { SimpleSAML_Utilities::requireAdmin(); } @@ -56,8 +56,8 @@ try { $metaBuilder = new SimpleSAML_Metadata_SAMLBuilder($spentityid); $metaBuilder->addMetadataSP11($metaArray); $metaBuilder->addContact('technical', array( - 'emailAddress' => $config->getValue('technicalcontact_email'), - 'name' => $config->getValue('technicalcontact_name'), + 'emailAddress' => $config->getString('technicalcontact_email', NULL), + 'name' => $config->getString('technicalcontact_name', NULL), )); $metaxml = $metaBuilder->getEntityDescriptorText(); @@ -65,7 +65,7 @@ try { $metaxml = SimpleSAML_Metadata_Signer::sign($metaxml, $spmeta, 'Shib 1.3 SP'); if (array_key_exists('output', $_GET) && $_GET['output'] == 'xhtml') { - $defaultidp = $config->getValue('default-shib13-idp'); + $defaultidp = $config->getString('default-shib13-idp', NULL); $t = new SimpleSAML_XHTML_Template($config, 'metadata.php', 'admin'); @@ -82,8 +82,8 @@ try { } */ - $t->data['techemail'] = $config->getValue('technicalcontact_email', 'na'); - $t->data['version'] = $config->getValue('version', 'na'); + $t->data['techemail'] = $config->getString('technicalcontact_email', 'na'); + $t->data['version'] = $config->getString('version', 'na'); $t->data['defaultidp'] = $defaultidp; $t->show(); diff --git a/www/wsfed/sp/initSLO.php b/www/wsfed/sp/initSLO.php index 02b9e2f10..0132f9284 100644 --- a/www/wsfed/sp/initSLO.php +++ b/www/wsfed/sp/initSLO.php @@ -8,7 +8,7 @@ $session = SimpleSAML_Session::getInstance(); SimpleSAML_Logger::info('WS-Fed - SP.initSLO: Accessing WS-Fed SP initSLO script'); -if (!$config->getValue('enable.wsfed-sp', false)) +if (!$config->getBoolean('enable.wsfed-sp', false)) SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NOACCESS'); diff --git a/www/wsfed/sp/initSSO.php b/www/wsfed/sp/initSSO.php index 0e27ff448..9be61bf97 100644 --- a/www/wsfed/sp/initSSO.php +++ b/www/wsfed/sp/initSSO.php @@ -19,7 +19,7 @@ $session = SimpleSAML_Session::getInstance(); SimpleSAML_Logger::info('WS-Fed - SP.initSSO: Accessing WS-Fed SP initSSO script'); -if (!$config->getValue('enable.wsfed-sp', false)) +if (!$config->getBoolean('enable.wsfed-sp', false)) SimpleSAML_Utilities::fatalError($session->getTrackID(), 'NOACCESS'); if (empty($_GET['RelayState'])) { diff --git a/www/wsfed/sp/prp.php b/www/wsfed/sp/prp.php index 396656f43..d5c3becc7 100644 --- a/www/wsfed/sp/prp.php +++ b/www/wsfed/sp/prp.php @@ -78,7 +78,7 @@ try { /* Find the certificate used by the IdP. */ if(array_key_exists('certificate', $idpMetadata)) { - $certFile = $config->getPathvalue('certdir') . $idpMetadata['certificate']; + $certFile = $config->getPathvalue('certdir', 'cert/') . $idpMetadata['certificate']; } else { throw new Exception('Missing \'certificate\' metadata option in the \'wsfed-idp-remote\' metadata' . ' for the IdP \'' . $idpEntityId . '\'.'); -- GitLab