ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
SimpleSAML_Configuration Class Reference
+ Inheritance diagram for SimpleSAML_Configuration:
+ Collaboration diagram for SimpleSAML_Configuration:

Public Member Functions

 __construct ($config, $location)
 Initializes a configuration from the given array. More...
 
 copyFromBase ($instancename, $filename)
 Load a configuration file which is located in the same directory as this configuration file. More...
 
 getVersion ()
 Retrieve the current version of SimpleSAMLphp. More...
 
 getValue ($name, $default=null)
 Retrieve a configuration option set in config.php. More...
 
 hasValue ($name)
 Check whether a key in the configuration exists or not. More...
 
 hasValueOneOf ($names)
 Check whether any key of the set given exists in the configuration. More...
 
 getBaseURL ()
 Retrieve the absolute path of the SimpleSAMLphp installation, relative to the root of the website. More...
 
 getBasePath ()
 Retrieve the absolute path pointing to the SimpleSAMLphp installation. More...
 
 resolvePath ($path)
 This function resolves a path which may be relative to the SimpleSAMLphp base directory. More...
 
 getPathValue ($name, $default=null)
 Retrieve a path configuration option set in config.php. More...
 
 getBaseDir ()
 Retrieve the base directory for this SimpleSAMLphp installation. More...
 
 getBoolean ($name, $default=self::REQUIRED_OPTION)
 This function retrieves a boolean configuration option. More...
 
 getString ($name, $default=self::REQUIRED_OPTION)
 This function retrieves a string configuration option. More...
 
 getInteger ($name, $default=self::REQUIRED_OPTION)
 This function retrieves an integer configuration option. More...
 
 getIntegerRange ($name, $minimum, $maximum, $default=self::REQUIRED_OPTION)
 This function retrieves an integer configuration option where the value must be in the specified range. More...
 
 getValueValidate ($name, $allowedValues, $default=self::REQUIRED_OPTION)
 Retrieve a configuration option with one of the given values. More...
 
 getArray ($name, $default=self::REQUIRED_OPTION)
 This function retrieves an array configuration option. More...
 
 getArrayize ($name, $default=self::REQUIRED_OPTION)
 This function retrieves an array configuration option. More...
 
 getArrayizeString ($name, $default=self::REQUIRED_OPTION)
 This function retrieves a configuration option with a string or an array of strings. More...
 
 getConfigItem ($name, $default=self::REQUIRED_OPTION)
 Retrieve an array as a SimpleSAML_Configuration object. More...
 
 getConfigList ($name, $default=self::REQUIRED_OPTION)
 Retrieve an array of arrays as an array of SimpleSAML_Configuration objects. More...
 
 getOptions ()
 Retrieve list of options. More...
 
 toArray ()
 Convert this configuration object back to an array. More...
 
 getEndpoints ($endpointType)
 Helper function for dealing with metadata endpoints. More...
 
 getEndpointPrioritizedByBinding ($endpointType, array $bindings, $default=self::REQUIRED_OPTION)
 Find an endpoint of the given type, using a list of supported bindings as a way to prioritize. More...
 
 getDefaultEndpoint ($endpointType, array $bindings=null, $default=self::REQUIRED_OPTION)
 Find the default endpoint of the given type. More...
 
 getLocalizedString ($name, $default=self::REQUIRED_OPTION)
 Retrieve a string which may be localized into many languages. More...
 
 getPublicKeys ($use=null, $required=false, $prefix='')
 Get public key from metadata. More...
 

Static Public Member Functions

static setConfigDir ($path, $configSet='simplesaml')
 Set the directory for configuration files for the given configuration set. More...
 
static getConfig ($filename='config.php', $configSet='simplesaml')
 Load a configuration file from a configuration set. More...
 
static getOptionalConfig ($filename='config.php', $configSet='simplesaml')
 Load a configuration file from a configuration set. More...
 
static loadFromArray ($config, $location='[ARRAY]', $instance=null)
 Loads a configuration from the given array. More...
 
static getInstance ($instancename='simplesaml')
 Get a configuration file by its instance name. More...
 
static init ($path, $instancename='simplesaml', $configfilename='config.php')
 Initialize a instance name with the given configuration file. More...
 
static clearInternalState ()
 Clear any configuration information cached. More...
 
static clearInternalState ()
 Clear any cached internal state. More...
 

Data Fields

const REQUIRED_OPTION = '___REQUIRED_OPTION___'
 

Private Member Functions

 getDefaultBinding ($endpointType)
 Retrieve the default binding for the given endpoint type. More...
 

Static Private Member Functions

static loadFromFile ($filename, $required)
 Load the given configuration file. More...
 

Private Attributes

 $configuration
 
 $location
 
 $filename = null
 
 $deprecated_base_url_used = false
 

Static Private Attributes

static $instance = array()
 
static $configDirs = array()
 
static $loadedConfigs = array()
 

Detailed Description

Definition at line 10 of file Configuration.php.

Constructor & Destructor Documentation

◆ __construct()

SimpleSAML_Configuration::__construct (   $config,
  $location 
)

Initializes a configuration from the given array.

Parameters
array$configThe configuration array.
string$locationThe location which will be given when an error occurs.

Definition at line 88 of file Configuration.php.

89 {
90 assert('is_array($config)');
91 assert('is_string($location)');
92
93 $this->configuration = $config;
94 $this->location = $location;
95 }

References $config, and $location.

Member Function Documentation

◆ clearInternalState()

static SimpleSAML_Configuration::clearInternalState ( )
static

Clear any configuration information cached.

Allows for configuration files to be changed and reloaded during a given request. Most useful when running phpunit tests and needing to alter config.php between test cases

Implements SimpleSAML\Utils\ClearableState.

Definition at line 1374 of file Configuration.php.

1375 {
1376 self::$configDirs = array();
1377 self::$instance = array();
1378 self::$loadedConfigs = array();
1379 }

◆ copyFromBase()

SimpleSAML_Configuration::copyFromBase (   $instancename,
  $filename 
)

Load a configuration file which is located in the same directory as this configuration file.

TODO: remove.

Parameters
string$instancename
string$filename
See also
getConfig()
Deprecated:
This function is superseeded by the getConfig() function.

Definition at line 364 of file Configuration.php.

365 {
366 assert('is_string($instancename)');
367 assert('is_string($filename)');
368 assert('$this->filename !== NULL');
369
370 // check if we already have loaded the given config - return the existing instance if we have
371 if (array_key_exists($instancename, self::$instance)) {
372 return self::$instance[$instancename];
373 }
374
375 $dir = dirname($this->filename);
376
377 self::$instance[$instancename] = self::loadFromFile($dir.'/'.$filename, true);
378 return self::$instance[$instancename];
379 }
static loadFromFile($filename, $required)
Load the given configuration file.

◆ getArray()

SimpleSAML_Configuration::getArray (   $name,
  $default = self::REQUIRED_OPTION 
)

This function retrieves an array configuration option.

An exception will be thrown if this option isn't an array, or if this option isn't found, and no default value is given.

Parameters
string$nameThe name of the option.
mixed$defaultA default value which will be returned if the option isn't found. The option will be required if this parameter isn't given. The default value can be any value, including null.
Returns
array|mixed The option with the given name, or $default if the option isn't found and $default is specified.
Exceptions
ExceptionIf the option is not an array.

Definition at line 857 of file Configuration.php.

858 {
859 assert('is_string($name)');
860
861 $ret = $this->getValue($name, $default);
862
863 if ($ret === $default) {
864 // the option wasn't found, or it matches the default value. In any case, return this value
865 return $ret;
866 }
867
868 if (!is_array($ret)) {
869 throw new Exception($this->location.': The option '.var_export($name, true).' is not an array.');
870 }
871
872 return $ret;
873 }
getValue($name, $default=null)
Retrieve a configuration option set in config.php.
if($format !==null) $name
Definition: metadata.php:146
$ret
Definition: parser.php:6

References $name, $ret, and getValue().

Referenced by SimpleSAML\XML\Shib13\AuthnResponse\generate(), sspmod_saml_Message\getBlacklistedAlgorithms(), getPublicKeys(), and SAML2\Configuration\SimpleSAMLConverter\pluckConfiguration().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getArrayize()

SimpleSAML_Configuration::getArrayize (   $name,
  $default = self::REQUIRED_OPTION 
)

This function retrieves an array configuration option.

If the configuration option isn't an array, it will be converted to an array.

Parameters
string$nameThe name of the option.
mixed$defaultA default value which will be returned if the option isn't found. The option will be required if this parameter isn't given. The default value can be any value, including null.
Returns
array The option with the given name, or $default if the option isn't found and $default is specified.

Definition at line 888 of file Configuration.php.

889 {
890 assert('is_string($name)');
891
892 $ret = $this->getValue($name, $default);
893
894 if ($ret === $default) {
895 // the option wasn't found, or it matches the default value. In any case, return this value
896 return $ret;
897 }
898
899 if (!is_array($ret)) {
900 $ret = array($ret);
901 }
902
903 return $ret;
904 }

References $name, $ret, and getValue().

Referenced by getArrayizeString().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getArrayizeString()

SimpleSAML_Configuration::getArrayizeString (   $name,
  $default = self::REQUIRED_OPTION 
)

This function retrieves a configuration option with a string or an array of strings.

If the configuration option is a string, it will be converted to an array with a single string

Parameters
string$nameThe name of the option.
mixed$defaultA default value which will be returned if the option isn't found. The option will be required if this parameter isn't given. The default value can be any value, including null.
Returns
array The option with the given name, or $default if the option isn't found and $default is specified.
Exceptions
ExceptionIf the option is not a string or an array of strings.

Definition at line 921 of file Configuration.php.

922 {
923 assert('is_string($name)');
924
925 $ret = $this->getArrayize($name, $default);
926
927 if ($ret === $default) {
928 // the option wasn't found, or it matches the default value. In any case, return this value
929 return $ret;
930 }
931
932 foreach ($ret as $value) {
933 if (!is_string($value)) {
934 throw new Exception(
935 $this->location.': The option '.var_export($name, true).
936 ' must be a string or an array of strings.'
937 );
938 }
939 }
940
941 return $ret;
942 }
getArrayize($name, $default=self::REQUIRED_OPTION)
This function retrieves an array configuration option.

References $name, $ret, and getArrayize().

Referenced by sspmod_saml_Message\checkSign(), and SAML2\Configuration\SimpleSAMLConverter\pluckConfiguration().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getBaseDir()

SimpleSAML_Configuration::getBaseDir ( )

Retrieve the base directory for this SimpleSAMLphp installation.

This function first checks the 'basedir' configuration option. If this option is undefined or null, then we fall back to looking at the current filename.

Returns
string The absolute path to the base directory for this SimpleSAMLphp installation. This path will always end with a slash.

Definition at line 600 of file Configuration.php.

601 {
602 // check if a directory is configured in the configuration file
603 $dir = $this->getString('basedir', null);
604 if ($dir !== null) {
605 // add trailing slash if it is missing
606 if (substr($dir, -1) !== DIRECTORY_SEPARATOR) {
607 $dir .= DIRECTORY_SEPARATOR;
608 }
609
610 return $dir;
611 }
612
613 // the directory wasn't set in the configuration file, path is <base directory>/lib/SimpleSAML/Configuration.php
614 $dir = __FILE__;
615 assert('basename($dir) === "Configuration.php"');
616
617 $dir = dirname($dir);
618 assert('basename($dir) === "SimpleSAML"');
619
620 $dir = dirname($dir);
621 assert('basename($dir) === "lib"');
622
623 $dir = dirname($dir);
624
625 // Add trailing directory separator
626 $dir .= DIRECTORY_SEPARATOR;
627
628 return $dir;
629 }
getString($name, $default=self::REQUIRED_OPTION)
This function retrieves a string configuration option.

References getString().

Referenced by resolvePath().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getBasePath()

SimpleSAML_Configuration::getBasePath ( )

Retrieve the absolute path pointing to the SimpleSAMLphp installation.

The path is guaranteed to start and end with a slash ('/'). E.g.: /simplesaml/

Returns
string The absolute path where SimpleSAMLphp can be reached in the web server.
Exceptions
SimpleSAML

Error\CriticalConfigurationError If the format of 'baseurlpath' is incorrect.

Definition at line 491 of file Configuration.php.

492 {
493 $baseURL = $this->getString('baseurlpath', 'simplesaml/');
494
495 if (preg_match('#^https?://[^/]*(?:/(.+/?)?)?$#', $baseURL, $matches)) {
496 // we have a full url, we need to strip the path
497 if (!array_key_exists(1, $matches)) {
498 // absolute URL without path
499 return '/';
500 }
501 return '/'.rtrim($matches[1], '/')."/";
502 } elseif ($baseURL === '' || $baseURL === '/') {
503 // root directory of site
504 return '/';
505 } elseif (preg_match('#^/?((?:[^/\s]+/?)+)#', $baseURL, $matches)) {
506 // local path only
507 return '/'.rtrim($matches[1], '/').'/';
508 } else {
509 /*
510 * Invalid 'baseurlpath'. We cannot recover from this, so throw a critical exception and try to be graceful
511 * with the configuration. Use a guessed base path instead of the one provided.
512 */
513 $c = $this->toArray();
514 $c['baseurlpath'] = SimpleSAML\Utils\HTTP::guessBasePath();
516 'Incorrect format for option \'baseurlpath\'. Value is: "'.
517 $this->getString('baseurlpath', 'simplesaml/').'". Valid format is in the form'.
518 ' [(http|https)://(hostname|fqdn)[:port]]/[path/to/simplesaml/].',
519 $this->filename,
520 $c
521 );
522 }
523 }
static guessBasePath()
Try to guess the base SimpleSAMLphp path from the current request.
Definition: HTTP.php:563
toArray()
Convert this configuration object back to an array.

◆ getBaseURL()

SimpleSAML_Configuration::getBaseURL ( )

Retrieve the absolute path of the SimpleSAMLphp installation, relative to the root of the website.

For example: simplesaml/

The path will always end with a '/' and never have a leading slash.

Returns
string The absolute path relative to the root of the website.
Exceptions
SimpleSAML

Error\CriticalConfigurationError If the format of 'baseurlpath' is incorrect.

Deprecated:
This method will be removed in SimpleSAMLphp 2.0. Please use getBasePath() instead.

Definition at line 466 of file Configuration.php.

467 {
468 if (!$this->deprecated_base_url_used) {
469 $this->deprecated_base_url_used = true;
471 "SimpleSAML_Configuration::getBaseURL() is deprecated, please use getBasePath() instead."
472 );
473 }
474 if (preg_match('/^\*(.*)$/D', $this->getString('baseurlpath', 'simplesaml/'), $matches)) {
475 // deprecated behaviour, will be removed in the future
476 return \SimpleSAML\Utils\HTTP::getFirstPathElement(false).$matches[1];
477 }
478 return ltrim($this->getBasePath(), '/');
479 }
static warning($string)
Definition: Logger.php:179
getBasePath()
Retrieve the absolute path pointing to the SimpleSAMLphp installation.

◆ getBoolean()

SimpleSAML_Configuration::getBoolean (   $name,
  $default = self::REQUIRED_OPTION 
)

This function retrieves a boolean configuration option.

An exception will be thrown if this option isn't a boolean, or if this option isn't found, and no default value is given.

Parameters
string$nameThe name of the option.
mixed$defaultA default value which will be returned if the option isn't found. The option will be required if this parameter isn't given. The default value can be any value, including null.
Returns
boolean|mixed The option with the given name, or $default if the option isn't found and $default is specified.
Exceptions
ExceptionIf the option is not boolean.

Definition at line 648 of file Configuration.php.

649 {
650 assert('is_string($name)');
651
652 $ret = $this->getValue($name, $default);
653
654 if ($ret === $default) {
655 // the option wasn't found, or it matches the default value. In any case, return this value
656 return $ret;
657 }
658
659 if (!is_bool($ret)) {
660 throw new Exception(
661 $this->location.': The option '.var_export($name, true).
662 ' is not a valid boolean value.'
663 );
664 }
665
666 return $ret;
667 }

References $name, $ret, and getValue().

Referenced by sspmod_saml_Message\addRedirectSign(), sspmod_saml_Message\decryptAssertion(), SAML2\Configuration\SimpleSAMLConverter\enrichForDecryptionProvider(), SAML2\Configuration\SimpleSAMLConverter\enrichForIdentityProvider(), SimpleSAML\XML\Shib13\AuthnResponse\generate(), SAML2\Configuration\SimpleSAMLConverter\pluckConfiguration(), and sspmod_saml_Message\validateMessage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getConfig()

static SimpleSAML_Configuration::getConfig (   $filename = 'config.php',
  $configSet = 'simplesaml' 
)
static

Load a configuration file from a configuration set.

Parameters
string$filenameThe name of the configuration file.
string$configSetThe configuration set. Optional, defaults to 'simplesaml'.
Returns
SimpleSAML_Configuration The SimpleSAML_Configuration object.
Exceptions
ExceptionIf the configuration set is not initialized.

Definition at line 209 of file Configuration.php.

210 {
211 assert('is_string($filename)');
212 assert('is_string($configSet)');
213
214 if (!array_key_exists($configSet, self::$configDirs)) {
215 if ($configSet !== 'simplesaml') {
216 throw new Exception('Configuration set \''.$configSet.'\' not initialized.');
217 } else {
218 self::$configDirs['simplesaml'] = SimpleSAML\Utils\Config::getConfigDir();
219 }
220 }
221
222 $dir = self::$configDirs[$configSet];
223 $filePath = $dir.'/'.$filename;
224 return self::loadFromFile($filePath, true);
225 }

Referenced by sspmod_cdc_Server\__construct(), sspmod_statistics_Aggregator\__construct(), sspmod_multiauth_Auth_Source_MultiAuth\__construct(), sspmod_statistics_LogCleaner\__construct(), sspmod_ldap_Auth_Process_BaseFilter\__construct(), SimpleSAML_AuthMemCookie\__construct(), sspmod_riak_Store_Store\__construct(), SimpleSAML\Module\cron\Cron\__construct(), sspmod_discopower_PowerIdPDisco\__construct(), cron_hook_cron(), SimpleSAML_Auth_Source\getById(), SimpleSAML_Auth_Source\getSourcesOfType(), statistics_hook_cron(), and statistics_hook_sanitycheck().

+ Here is the caller graph for this function:

◆ getConfigItem()

SimpleSAML_Configuration::getConfigItem (   $name,
  $default = self::REQUIRED_OPTION 
)

Retrieve an array as a SimpleSAML_Configuration object.

This function will load the value of an option into a SimpleSAML_Configuration object. The option must contain an array.

An exception will be thrown if this option isn't an array, or if this option isn't found, and no default value is given.

Parameters
string$nameThe name of the option.
mixed$defaultA default value which will be returned if the option isn't found. The option will be required if this parameter isn't given. The default value can be any value, including null.
Returns
mixed The option with the given name, or $default if the option isn't found and $default is specified.
Exceptions
ExceptionIf the option is not an array.

Definition at line 963 of file Configuration.php.

964 {
965 assert('is_string($name)');
966
967 $ret = $this->getValue($name, $default);
968
969 if ($ret === $default) {
970 // the option wasn't found, or it matches the default value. In any case, return this value
971 return $ret;
972 }
973
974 if (!is_array($ret)) {
975 throw new Exception(
976 $this->location.': The option '.var_export($name, true).
977 ' is not an array.'
978 );
979 }
980
981 return self::loadFromArray($ret, $this->location.'['.var_export($name, true).']');
982 }
static loadFromArray($config, $location='[ARRAY]', $instance=null)
Loads a configuration from the given array.

References $name, $ret, getValue(), and loadFromArray().

+ Here is the call graph for this function:

◆ getConfigList()

SimpleSAML_Configuration::getConfigList (   $name,
  $default = self::REQUIRED_OPTION 
)

Retrieve an array of arrays as an array of SimpleSAML_Configuration objects.

This function will retrieve an option containing an array of arrays, and create an array of SimpleSAML_Configuration objects from that array. The indexes in the new array will be the same as the original indexes, but the values will be SimpleSAML_Configuration objects.

An exception will be thrown if this option isn't an array of arrays, or if this option isn't found, and no default value is given.

Parameters
string$nameThe name of the option.
mixed$defaultA default value which will be returned if the option isn't found. The option will be required if this parameter isn't given. The default value can be any value, including null.
Returns
mixed The option with the given name, or $default if the option isn't found and $default is specified.
Exceptions
ExceptionIf the value of this element is not an array.

Definition at line 1004 of file Configuration.php.

1005 {
1006 assert('is_string($name)');
1007
1008 $ret = $this->getValue($name, $default);
1009
1010 if ($ret === $default) {
1011 // the option wasn't found, or it matches the default value. In any case, return this value
1012 return $ret;
1013 }
1014
1015 if (!is_array($ret)) {
1016 throw new Exception(
1017 $this->location.': The option '.var_export($name, true).
1018 ' is not an array.'
1019 );
1020 }
1021
1022 $out = array();
1023 foreach ($ret as $index => $config) {
1024 $newLoc = $this->location.'['.var_export($name, true).']['.
1025 var_export($index, true).']';
1026 if (!is_array($config)) {
1027 throw new Exception($newLoc.': The value of this element was expected to be an array.');
1028 }
1030 }
1031
1032 return $out;
1033 }
$index
Definition: metadata.php:60

References $config, $index, $name, $out, $ret, getValue(), and loadFromArray().

+ Here is the call graph for this function:

◆ getDefaultBinding()

SimpleSAML_Configuration::getDefaultBinding (   $endpointType)
private

Retrieve the default binding for the given endpoint type.

This function combines the current metadata type (SAML 2 / SAML 1.1) with the endpoint type to determine which binding is the default.

Parameters
string$endpointTypeThe endpoint type.
Returns
string The default binding.
Exceptions
ExceptionIf the default binding is missing for this endpoint type.

Definition at line 1073 of file Configuration.php.

1074 {
1075 assert('is_string($endpointType)');
1076
1077 $set = $this->getString('metadata-set');
1078 switch ($set.':'.$endpointType) {
1079 case 'saml20-idp-remote:SingleSignOnService':
1080 case 'saml20-idp-remote:SingleLogoutService':
1081 case 'saml20-sp-remote:SingleLogoutService':
1082 return \SAML2\Constants::BINDING_HTTP_REDIRECT;
1083 case 'saml20-sp-remote:AssertionConsumerService':
1084 return \SAML2\Constants::BINDING_HTTP_POST;
1085 case 'saml20-idp-remote:ArtifactResolutionService':
1086 return \SAML2\Constants::BINDING_SOAP;
1087 case 'shib13-idp-remote:SingleSignOnService':
1088 return 'urn:mace:shibboleth:1.0:profiles:AuthnRequest';
1089 case 'shib13-sp-remote:AssertionConsumerService':
1090 return 'urn:oasis:names:tc:SAML:1.0:profiles:browser-post';
1091 default:
1092 throw new Exception('Missing default binding for '.$endpointType.' in '.$set);
1093 }
1094 }

References getString().

Referenced by getEndpoints().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDefaultEndpoint()

SimpleSAML_Configuration::getDefaultEndpoint (   $endpointType,
array  $bindings = null,
  $default = self::REQUIRED_OPTION 
)

Find the default endpoint of the given type.

Parameters
string$endpointTypeThe endpoint type.
array$bindingsArray with acceptable bindings. Can be null if any binding is allowed.
mixed$defaultThe default value to return if no matching endpoint is found. If no default is provided, an exception will be thrown.
Returns
array|null The default endpoint, or null if no acceptable endpoints are used.
Exceptions
ExceptionIf no supported endpoint is found.

Definition at line 1222 of file Configuration.php.

1223 {
1224 assert('is_string($endpointType)');
1225
1226 $endpoints = $this->getEndpoints($endpointType);
1227
1229 if ($defaultEndpoint !== null) {
1230 return $defaultEndpoint;
1231 }
1232
1233 if ($default === self::REQUIRED_OPTION) {
1234 $loc = $this->location.'['.var_export($endpointType, true).']:';
1235 throw new Exception($loc.'Could not find a supported '.$endpointType.' endpoint.');
1236 }
1237
1238 return $default;
1239 }
static getDefaultEndpoint(array $endpoints, array $bindings=null)
Find the default endpoint in an endpoint array.
Definition: Metadata.php:221
getEndpoints($endpointType)
Helper function for dealing with metadata endpoints.
$bindings

References $bindings, SimpleSAML\Utils\Config\Metadata\getDefaultEndpoint(), and getEndpoints().

+ Here is the call graph for this function:

◆ getEndpointPrioritizedByBinding()

SimpleSAML_Configuration::getEndpointPrioritizedByBinding (   $endpointType,
array  $bindings,
  $default = self::REQUIRED_OPTION 
)

Find an endpoint of the given type, using a list of supported bindings as a way to prioritize.

Parameters
string$endpointTypeThe endpoint type.
array$bindingsSorted array of acceptable bindings.
mixed$defaultThe default value to return if no matching endpoint is found. If no default is provided, an exception will be thrown.
Returns
array|null The default endpoint, or null if no acceptable endpoints are used.
Exceptions
ExceptionIf no supported endpoint is found.

Definition at line 1187 of file Configuration.php.

1188 {
1189 assert('is_string($endpointType)');
1190
1191 $endpoints = $this->getEndpoints($endpointType);
1192
1193 foreach ($bindings as $binding) {
1194 foreach ($endpoints as $ep) {
1195 if ($ep['Binding'] === $binding) {
1196 return $ep;
1197 }
1198 }
1199 }
1200
1201 if ($default === self::REQUIRED_OPTION) {
1202 $loc = $this->location.'['.var_export($endpointType, true).']:';
1203 throw new Exception($loc.'Could not find a supported '.$endpointType.' endpoint.');
1204 }
1205
1206 return $default;
1207 }
$binding

References $binding, $bindings, and getEndpoints().

+ Here is the call graph for this function:

◆ getEndpoints()

SimpleSAML_Configuration::getEndpoints (   $endpointType)

Helper function for dealing with metadata endpoints.

Parameters
string$endpointTypeThe endpoint type.
Returns
array Array of endpoints of the given type.
Exceptions
ExceptionIf any element of the configuration options for this endpoint type is incorrect.

Definition at line 1106 of file Configuration.php.

1107 {
1108 assert('is_string($endpointType)');
1109
1110 $loc = $this->location.'['.var_export($endpointType, true).']:';
1111
1112 if (!array_key_exists($endpointType, $this->configuration)) {
1113 // no endpoints of the given type
1114 return array();
1115 }
1116
1117
1118 $eps = $this->configuration[$endpointType];
1119 if (is_string($eps)) {
1120 // for backwards-compatibility
1121 $eps = array($eps);
1122 } elseif (!is_array($eps)) {
1123 throw new Exception($loc.': Expected array or string.');
1124 }
1125
1126
1127 foreach ($eps as $i => &$ep) {
1128 $iloc = $loc.'['.var_export($i, true).']';
1129
1130 if (is_string($ep)) {
1131 // for backwards-compatibility
1132 $ep = array(
1133 'Location' => $ep,
1134 'Binding' => $this->getDefaultBinding($endpointType),
1135 );
1136 $responseLocation = $this->getString($endpointType.'Response', null);
1137 if ($responseLocation !== null) {
1138 $ep['ResponseLocation'] = $responseLocation;
1139 }
1140 } elseif (!is_array($ep)) {
1141 throw new Exception($iloc.': Expected a string or an array.');
1142 }
1143
1144 if (!array_key_exists('Location', $ep)) {
1145 throw new Exception($iloc.': Missing Location.');
1146 }
1147 if (!is_string($ep['Location'])) {
1148 throw new Exception($iloc.': Location must be a string.');
1149 }
1150
1151 if (!array_key_exists('Binding', $ep)) {
1152 throw new Exception($iloc.': Missing Binding.');
1153 }
1154 if (!is_string($ep['Binding'])) {
1155 throw new Exception($iloc.': Binding must be a string.');
1156 }
1157
1158 if (array_key_exists('ResponseLocation', $ep)) {
1159 if (!is_string($ep['ResponseLocation'])) {
1160 throw new Exception($iloc.': ResponseLocation must be a string.');
1161 }
1162 }
1163
1164 if (array_key_exists('index', $ep)) {
1165 if (!is_int($ep['index'])) {
1166 throw new Exception($iloc.': index must be an integer.');
1167 }
1168 }
1169 }
1170
1171 return $eps;
1172 }
getDefaultBinding($endpointType)
Retrieve the default binding for the given endpoint type.
$i
Definition: disco.tpl.php:19
$eps
Definition: metadata.php:61

References $eps, $i, getDefaultBinding(), and getString().

Referenced by getDefaultEndpoint(), and getEndpointPrioritizedByBinding().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInstance()

static SimpleSAML_Configuration::getInstance (   $instancename = 'simplesaml')
static

Get a configuration file by its instance name.

This function retrieves a configuration file by its instance name. The instance name is initialized by the init function, or by copyFromBase function.

If no configuration file with the given instance name is found, an exception will be thrown.

Parameters
string$instancenameThe instance name of the configuration file. Deprecated.
Returns
SimpleSAML_Configuration The configuration object.
Exceptions
ExceptionIf the configuration with $instancename name is not initialized.

Definition at line 297 of file Configuration.php.

298 {
299 assert('is_string($instancename)');
300
301 // check if the instance exists already
302 if (array_key_exists($instancename, self::$instance)) {
303 return self::$instance[$instancename];
304 }
305
306 if ($instancename === 'simplesaml') {
307 try {
308 return self::getConfig();
309 } catch (SimpleSAML\Error\ConfigurationError $e) {
310 throw \SimpleSAML\Error\CriticalConfigurationError::fromException($e);
311 }
312 }
313
314 throw new \SimpleSAML\Error\CriticalConfigurationError(
315 'Configuration with name '.$instancename.' is not initialized.'
316 );
317 }
static getConfig($filename='config.php', $configSet='simplesaml')
Load a configuration file from a configuration set.
Attribute-related utility methods.

Referenced by ilSimpleSAMLphpWrapper\__construct(), SimpleSAML_Metadata_MetaDataStorageHandlerFlatFile\__construct(), SimpleSAML_Metadata_MetaDataStorageHandlerSerialize\__construct(), SimpleSAML_Metadata_MetaDataStorageHandlerXML\__construct(), SimpleSAML\Metadata\Sources\MDQ\__construct(), SimpleSAML_IdP\__construct(), SimpleSAML_Auth_ProcessingChain\__construct(), sspmod_multiauth_Auth_Source_MultiAuth\__construct(), sspmod_core_Auth_UserPassBase\__construct(), sspmod_core_Storage_SQLPermanentStorage\__construct(), SimpleSAML_Session\__construct(), SimpleSAML_Metadata_MetaDataStorageHandler\__construct(), SimpleSAML\SessionHandlerCookie\__construct(), SimpleSAML\SessionHandlerPHP\__construct(), ilSimpleSAMLphplIdpDiscovery\__construct(), SimpleSAML_XHTML_IdPDisco\__construct(), sspmod_consent_Consent_Store_Cookie\_setConsentCookie(), sspmod_authX509_Auth_Source_X509userCert\authFailed(), sspmod_saml_IdP_SAML2\buildAssertion(), SimpleSAML\Utils\XML\checkSAMLMessage(), core_hook_sanitycheck(), sspmod_metarefresh_MetaLoader\createContext(), SimpleSAML\Logger\createLoggingHandler(), SimpleSAML\Utils\XML\debugSAMLMessage(), SimpleSAML_Session\doLogin(), SimpleSAML_Error_Exception\formatBacktrace(), SimpleSAML\Utils\Config\getCertPath(), SimpleSAML\SessionHandler\getCookieParams(), SimpleSAML\SessionHandlerPHP\getCookieParams(), sspmod_statistics_StatDataset\getDelimiterPresentation(), SimpleSAML_Memcache\getExpireTime(), SimpleSAML_Metadata_MetaDataStorageHandler\getGenerated(), SimpleSAML\Database\getInstance(), SimpleSAML\Store\getInstance(), SimpleSAML\Locale\Language\getLanguageCookie(), SimpleSAML_Memcache\getMemcacheServers(), sspmod_portal_Portal\getMenu(), SimpleSAML\Utils\Config\getSecretSalt(), SimpleSAML_Session\getSession(), SimpleSAML_Session\getSessionFromRequest(), SimpleSAML_Auth_State\getStateTimeout(), SimpleSAML\Utils\System\getTempDir(), SimpleSAML_Stats\initOutputs(), SimpleSAML\Utils\Time\initTimezone(), sspmod_metarefresh_ARP\loadAttributeMap(), sspmod_core_Auth_Process_AttributeMap\loadMapFile(), SimpleSAML_Error_Exception\logBacktrace(), sspmod_core_Auth_Source_AdminPassword\login(), metarefresh_hook_cron(), sspmod_core_Auth_Process_ExtendIdPSession\process(), sspmod_expirycheck_Auth_Process_ExpiryDate\process(), SimpleSAML\Utils\System\resolvePath(), SimpleSAML_Error_Error\saveError(), SimpleSAML\SessionHandlerStore\saveSession(), sspmod_saml_IdP_SAML1\sendResponse(), SimpleSAML_Session\setAuthorityExpire(), SimpleSAML_Session\setData(), SimpleSAML\Locale\Language\setLanguageCookie(), sspmod_multiauth_Auth_Source_MultiAuth\setPreviousSource(), SimpleSAML_Session\setRememberMeExpire(), SimpleSAML_Error_Error\show(), SimpleSAML_Metadata_Signer\sign(), sspmod_saml_Auth_Source_SP\startDisco(), and SimpleSAML_Session\updateSessionCookies().

+ Here is the caller graph for this function:

◆ getInteger()

SimpleSAML_Configuration::getInteger (   $name,
  $default = self::REQUIRED_OPTION 
)

This function retrieves an integer configuration option.

An exception will be thrown if this option isn't an integer, or if this option isn't found, and no default value is given.

Parameters
string$nameThe name of the option.
mixed$defaultA default value which will be returned if the option isn't found. The option will be required if this parameter isn't given. The default value can be any value, including null.
Returns
int|mixed The option with the given name, or $default if the option isn't found and $default is specified.
Exceptions
ExceptionIf the option is not an integer.

Definition at line 724 of file Configuration.php.

725 {
726 assert('is_string($name)');
727
728 $ret = $this->getValue($name, $default);
729
730 if ($ret === $default) {
731 // the option wasn't found, or it matches the default value. In any case, return this value
732 return $ret;
733 }
734
735 if (!is_int($ret)) {
736 throw new Exception(
737 $this->location.': The option '.var_export($name, true).
738 ' is not a valid integer value.'
739 );
740 }
741
742 return $ret;
743 }

References $name, $ret, and getValue().

Referenced by getIntegerRange().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getIntegerRange()

SimpleSAML_Configuration::getIntegerRange (   $name,
  $minimum,
  $maximum,
  $default = self::REQUIRED_OPTION 
)

This function retrieves an integer configuration option where the value must be in the specified range.

An exception will be thrown if:

  • the option isn't an integer
  • the option isn't found, and no default value is given
  • the value is outside of the allowed range
Parameters
string$nameThe name of the option.
int$minimumThe smallest value which is allowed.
int$maximumThe largest value which is allowed.
mixed$defaultA default value which will be returned if the option isn't found. The option will be required if this parameter isn't given. The default value can be any value, including null.
Returns
int|mixed The option with the given name, or $default if the option isn't found and $default is specified.
Exceptions
ExceptionIf the option is not in the range specified.

Definition at line 766 of file Configuration.php.

767 {
768 assert('is_string($name)');
769 assert('is_int($minimum)');
770 assert('is_int($maximum)');
771
772 $ret = $this->getInteger($name, $default);
773
774 if ($ret === $default) {
775 // the option wasn't found, or it matches the default value. In any case, return this value
776 return $ret;
777 }
778
779 if ($ret < $minimum || $ret > $maximum) {
780 throw new Exception(
781 $this->location.': Value of option '.var_export($name, true).
782 ' is out of range. Value is '.$ret.', allowed range is ['
783 .$minimum.' - '.$maximum.']'
784 );
785 }
786
787 return $ret;
788 }
getInteger($name, $default=self::REQUIRED_OPTION)
This function retrieves an integer configuration option.

References $name, $ret, and getInteger().

+ Here is the call graph for this function:

◆ getLocalizedString()

SimpleSAML_Configuration::getLocalizedString (   $name,
  $default = self::REQUIRED_OPTION 
)

Retrieve a string which may be localized into many languages.

The default language returned is always 'en'.

Parameters
string$nameThe name of the option.
mixed$defaultThe default value. If no default is given, and the option isn't found, an exception will be thrown.
Returns
array Associative array with language => string pairs.
Exceptions
ExceptionIf the translation is not an array or a string, or its index or value are not strings.

Definition at line 1255 of file Configuration.php.

1256 {
1257 assert('is_string($name)');
1258
1259 $ret = $this->getValue($name, $default);
1260 if ($ret === $default) {
1261 // the option wasn't found, or it matches the default value. In any case, return this value
1262 return $ret;
1263 }
1264
1265 $loc = $this->location.'['.var_export($name, true).']';
1266
1267 if (is_string($ret)) {
1268 $ret = array('en' => $ret,);
1269 }
1270
1271 if (!is_array($ret)) {
1272 throw new Exception($loc.': Must be an array or a string.');
1273 }
1274
1275 foreach ($ret as $k => $v) {
1276 if (!is_string($k)) {
1277 throw new Exception($loc.': Invalid language code: '.var_export($k, true));
1278 }
1279 if (!is_string($v)) {
1280 throw new Exception($loc.'['.var_export($v, true).']: Must be a string.');
1281 }
1282 }
1283
1284 return $ret;
1285 }

References $name, $ret, and getValue().

+ Here is the call graph for this function:

◆ getOptionalConfig()

static SimpleSAML_Configuration::getOptionalConfig (   $filename = 'config.php',
  $configSet = 'simplesaml' 
)
static

Load a configuration file from a configuration set.

This function will return a configuration object even if the file does not exist.

Parameters
string$filenameThe name of the configuration file.
string$configSetThe configuration set. Optional, defaults to 'simplesaml'.
Returns
SimpleSAML_Configuration A configuration object.
Exceptions
ExceptionIf the configuration set is not initialized.

Definition at line 239 of file Configuration.php.

240 {
241 assert('is_string($filename)');
242 assert('is_string($configSet)');
243
244 if (!array_key_exists($configSet, self::$configDirs)) {
245 if ($configSet !== 'simplesaml') {
246 throw new Exception('Configuration set \''.$configSet.'\' not initialized.');
247 } else {
248 self::$configDirs['simplesaml'] = SimpleSAML\Utils\Config::getConfigDir();
249 }
250 }
251
252 $dir = self::$configDirs[$configSet];
253 $filePath = $dir.'/'.$filename;
254 return self::loadFromFile($filePath, false);
255 }

Referenced by sspmod_oauth_OAuthStore\__construct(), sspmod_core_ACL\getById(), SimpleSAML_Auth_Source\getSources(), SimpleSAML\Module\isModuleEnabled(), metarefresh_hook_cron(), oauth_hook_cron(), portal_hook_htmlinject(), and sanitycheck_hook_cron().

+ Here is the caller graph for this function:

◆ getOptions()

SimpleSAML_Configuration::getOptions ( )

Retrieve list of options.

This function returns the name of all options which are defined in this configuration file, as an array of strings.

Returns
array Name of all options defined in this configuration file.

Definition at line 1044 of file Configuration.php.

1045 {
1046 return array_keys($this->configuration);
1047 }

◆ getPathValue()

SimpleSAML_Configuration::getPathValue (   $name,
  $default = null 
)

Retrieve a path configuration option set in config.php.

The function will always return an absolute path unless the option is not set. It will then return the default value.

It checks if the value starts with a slash, and prefixes it with the value from getBaseDir if it doesn't.

Parameters
string$nameName of the configuration option.
string | null$defaultDefault value of the configuration option. This parameter will default to null if not specified.
Returns
string|null The path configuration option with name $name, or $default if the option was not found.

Definition at line 574 of file Configuration.php.

575 {
576 // return the default value if the option is unset
577 if (!array_key_exists($name, $this->configuration)) {
578 $path = $default;
579 } else {
580 $path = $this->configuration[$name];
581 }
582
583 if ($path === null) {
584 return null;
585 }
586
587 return $this->resolvePath($path).'/';
588 }
resolvePath($path)
This function resolves a path which may be relative to the SimpleSAMLphp base directory.

References $name, $path, and resolvePath().

+ Here is the call graph for this function:

◆ getPublicKeys()

SimpleSAML_Configuration::getPublicKeys (   $use = null,
  $required = false,
  $prefix = '' 
)

Get public key from metadata.

Parameters
string | null$useThe purpose this key can be used for. (encryption or signing).
bool$requiredWhether the public key is required. If this is true, a missing key will cause an exception. Default is false.
string$prefixThe prefix which should be used when reading from the metadata array. Defaults to ''.
Returns
array|null Public key data, or null if no public key or was found.
Exceptions
ExceptionIf the certificate or public key cannot be loaded from a file.
SimpleSAML_Error_ExceptionIf the file does not contain a valid PEM-encoded certificate, or there is no certificate in the metadata.

Definition at line 1303 of file Configuration.php.

1304 {
1305 assert('is_bool($required)');
1306 assert('is_string($prefix)');
1307
1308 if ($this->hasValue($prefix.'keys')) {
1309 $ret = array();
1310 foreach ($this->getArray($prefix.'keys') as $key) {
1311 if ($use !== null && isset($key[$use]) && !$key[$use]) {
1312 continue;
1313 }
1314 if (isset($key['X509Certificate'])) {
1315 // Strip whitespace from key
1316 $key['X509Certificate'] = preg_replace('/\s+/', '', $key['X509Certificate']);
1317 }
1318 $ret[] = $key;
1319 }
1320 if (!empty($ret)) {
1321 return $ret;
1322 }
1323 } elseif ($this->hasValue($prefix.'certData')) {
1324 $certData = $this->getString($prefix.'certData');
1325 $certData = preg_replace('/\s+/', '', $certData);
1326 return array(
1327 array(
1328 'encryption' => true,
1329 'signing' => true,
1330 'type' => 'X509Certificate',
1331 'X509Certificate' => $certData,
1332 ),
1333 );
1334 } elseif ($this->hasValue($prefix.'certificate')) {
1335 $file = $this->getString($prefix.'certificate');
1337 $data = @file_get_contents($file);
1338
1339 if ($data === false) {
1340 throw new Exception($this->location.': Unable to load certificate/public key from file "'.$file.'".');
1341 }
1342
1343 // extract certificate data (if this is a certificate)
1344 $pattern = '/^-----BEGIN CERTIFICATE-----([^-]*)^-----END CERTIFICATE-----/m';
1345 if (!preg_match($pattern, $data, $matches)) {
1347 $this->location.': Could not find PEM encoded certificate in "'.$file.'".'
1348 );
1349 }
1350 $certData = preg_replace('/\s+/', '', $matches[1]);
1351
1352 return array(
1353 array(
1354 'encryption' => true,
1355 'signing' => true,
1356 'type' => 'X509Certificate',
1357 'X509Certificate' => $certData,
1358 ),
1359 );
1360 }
1361
1362 if ($required) {
1363 throw new SimpleSAML_Error_Exception($this->location.': Missing certificate in metadata.');
1364 } else {
1365 return null;
1366 }
1367 }
static getCertPath($path)
Resolves a path that may be relative to the cert-directory.
Definition: Config.php:22
getArray($name, $default=self::REQUIRED_OPTION)
This function retrieves an array configuration option.
hasValue($name)
Check whether a key in the configuration exists or not.
$key
Definition: croninfo.php:18
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file

References $data, $file, $key, $ret, getArray(), SimpleSAML\Utils\Config\getCertPath(), getString(), and hasValue().

Referenced by sspmod_saml_Message\checkSign().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getString()

SimpleSAML_Configuration::getString (   $name,
  $default = self::REQUIRED_OPTION 
)

This function retrieves a string configuration option.

An exception will be thrown if this option isn't a string, or if this option isn't found, and no default value is given.

Parameters
string$nameThe name of the option.
mixed$defaultA default value which will be returned if the option isn't found. The option will be required if this parameter isn't given. The default value can be any value, including null.
Returns
string|mixed The option with the given name, or $default if the option isn't found and $default is specified.
Exceptions
ExceptionIf the option is not a string.

Definition at line 686 of file Configuration.php.

687 {
688 assert('is_string($name)');
689
690 $ret = $this->getValue($name, $default);
691
692 if ($ret === $default) {
693 // the option wasn't found, or it matches the default value. In any case, return this value
694 return $ret;
695 }
696
697 if (!is_string($ret)) {
698 throw new Exception(
699 $this->location.': The option '.var_export($name, true).
700 ' is not a valid string value.'
701 );
702 }
703
704 return $ret;
705 }

References $name, $ret, and getValue().

Referenced by sspmod_saml_Message\addSign(), sspmod_saml_Message\buildLogoutRequest(), sspmod_saml_Message\buildLogoutResponse(), sspmod_saml_Message\checkSign(), SAML2\Configuration\SimpleSAMLConverter\enrichForDecryptionProvider(), SAML2\Configuration\SimpleSAMLConverter\enrichForIdentityProvider(), SAML2\Configuration\SimpleSAMLConverter\enrichForServiceProvider(), SimpleSAML\XML\Shib13\AuthnResponse\generate(), getBaseDir(), sspmod_saml_Message\getDecryptionKeys(), getDefaultBinding(), getEndpoints(), getPublicKeys(), SAML2\Configuration\SimpleSAMLConverter\pluckConfiguration(), and SAML2\SOAPClient\send().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getValue()

SimpleSAML_Configuration::getValue (   $name,
  $default = null 
)

Retrieve a configuration option set in config.php.

Parameters
string$nameName of the configuration option.
mixed$defaultDefault value of the configuration option. This parameter will default to null if not specified. This can be set to SimpleSAML_Configuration::REQUIRED_OPTION, which will cause an exception to be thrown if the option isn't found.
Returns
mixed The configuration option with name $name, or $default if the option was not found.
Exceptions
ExceptionIf the required option cannot be retrieved.

Definition at line 405 of file Configuration.php.

406 {
407 // return the default value if the option is unset
408 if (!array_key_exists($name, $this->configuration)) {
409 if ($default === self::REQUIRED_OPTION) {
410 throw new Exception(
411 $this->location.': Could not retrieve the required option '.
412 var_export($name, true)
413 );
414 }
415 return $default;
416 }
417
418 return $this->configuration[$name];
419 }

Referenced by getArray(), getArrayize(), getBoolean(), getConfigItem(), getConfigList(), getInteger(), getLocalizedString(), getString(), getValueValidate(), and SAML2\SOAPClient\send().

+ Here is the caller graph for this function:

◆ getValueValidate()

SimpleSAML_Configuration::getValueValidate (   $name,
  $allowedValues,
  $default = self::REQUIRED_OPTION 
)

Retrieve a configuration option with one of the given values.

This will check that the configuration option matches one of the given values. The match will use strict comparison. An exception will be thrown if it does not match.

The option can be mandatory or optional. If no default value is given, it will be considered to be mandatory, and an exception will be thrown if it isn't provided. If a default value is given, it is considered to be optional, and the default value is returned. The default value is automatically included in the list of allowed values.

Parameters
string$nameThe name of the option.
array$allowedValuesThe values the option is allowed to take, as an array.
mixed$defaultThe default value which will be returned if the option isn't found. If this parameter isn't given, the option will be considered to be mandatory. The default value can be any value, including null.
Returns
mixed The option with the given name, or $default if the option isn't found and $default is given.
Exceptions
ExceptionIf the option does not have any of the allowed values.

Definition at line 812 of file Configuration.php.

813 {
814 assert('is_string($name)');
815 assert('is_array($allowedValues)');
816
817 $ret = $this->getValue($name, $default);
818 if ($ret === $default) {
819 // the option wasn't found, or it matches the default value. In any case, return this value
820 return $ret;
821 }
822
823 if (!in_array($ret, $allowedValues, true)) {
824 $strValues = array();
825 foreach ($allowedValues as $av) {
826 $strValues[] = var_export($av, true);
827 }
828 $strValues = implode(', ', $strValues);
829
830 throw new Exception(
831 $this->location.': Invalid value given for the option '.
832 var_export($name, true).'. It should have one of the following values: '.
833 $strValues.'; but it had the following value: '.var_export($ret, true)
834 );
835 }
836
837 return $ret;
838 }

References $name, $ret, and getValue().

+ Here is the call graph for this function:

◆ getVersion()

SimpleSAML_Configuration::getVersion ( )

Retrieve the current version of SimpleSAMLphp.

Returns
string

Definition at line 387 of file Configuration.php.

388 {
389 return '1.15.3';
390 }

◆ hasValue()

SimpleSAML_Configuration::hasValue (   $name)

Check whether a key in the configuration exists or not.

Parameters
string$nameThe key in the configuration to look for.
Returns
boolean If the value is set in this configuration.

Definition at line 429 of file Configuration.php.

430 {
431 return array_key_exists($name, $this->configuration);
432 }

Referenced by sspmod_saml_Message\checkSign(), SimpleSAML\XML\Shib13\AuthnResponse\generate(), getPublicKeys(), SAML2\Configuration\SimpleSAMLConverter\pluckConfiguration(), and SAML2\SOAPClient\send().

+ Here is the caller graph for this function:

◆ hasValueOneOf()

SimpleSAML_Configuration::hasValueOneOf (   $names)

Check whether any key of the set given exists in the configuration.

Parameters
array$namesAn array of options to look for.
Returns
boolean If any of the keys in $names exist in the configuration

Definition at line 442 of file Configuration.php.

443 {
444 foreach ($names as $name) {
445 if ($this->hasValue($name)) {
446 return true;
447 }
448 }
449 return false;
450 }

◆ init()

static SimpleSAML_Configuration::init (   $path,
  $instancename = 'simplesaml',
  $configfilename = 'config.php' 
)
static

Initialize a instance name with the given configuration file.

TODO: remove.

Parameters
string$path
string$instancename
string$configfilename
See also
setConfigDir()
Deprecated:
This function is superseeded by the setConfigDir function.

Definition at line 332 of file Configuration.php.

333 {
334 assert('is_string($path)');
335 assert('is_string($instancename)');
336 assert('is_string($configfilename)');
337
338 if ($instancename === 'simplesaml') {
339 // for backwards compatibility
340 self::setConfigDir($path, 'simplesaml');
341 }
342
343 // check if we already have loaded the given config - return the existing instance if we have
344 if (array_key_exists($instancename, self::$instance)) {
345 return self::$instance[$instancename];
346 }
347
348 self::$instance[$instancename] = self::loadFromFile($path.'/'.$configfilename, true);
349 return self::$instance[$instancename];
350 }
static setConfigDir($path, $configSet='simplesaml')
Set the directory for configuration files for the given configuration set.

◆ loadFromArray()

static SimpleSAML_Configuration::loadFromArray (   $config,
  $location = '[ARRAY]',
  $instance = null 
)
static

Loads a configuration from the given array.

Parameters
array$configThe configuration array.
string$locationThe location which will be given when an error occurs. Optional.
string | null$instanceThe name of this instance. If specified, the configuration will be loaded and an instance with that name will be kept for it to be retrieved later with getInstance($instance). If null, the configuration will not be kept for later use. Defaults to null.
Returns
SimpleSAML_Configuration The configuration object.

Definition at line 269 of file Configuration.php.

270 {
271 assert('is_array($config)');
272 assert('is_string($location)');
273
275 if ($instance !== null) {
276 self::$instance[$instance] = $c;
277 }
278 return $c;
279 }

Referenced by SimpleSAML_Metadata_MetaDataStorageHandlerSerialize\__construct(), sspmod_ldap_ConfigHelper\__construct(), sspmod_core_Auth_Process_ScopeAttribute\__construct(), sspmod_core_Auth_Process_ScopeFromAttribute\__construct(), sspmod_authfacebook_Auth_Source_Facebook\__construct(), sspmod_authtwitter_Auth_Source_Twitter\__construct(), sspmod_ldap_Auth_Source_LDAPMulti\__construct(), sspmod_negotiate_Auth_Source_Negotiate\__construct(), sspmod_radius_Auth_Source_Radius\__construct(), sspmod_saml_Auth_Source_SP\__construct(), SimpleSAML\Error\CriticalConfigurationError\__construct(), sspmod_ldap_Auth_Process_BaseFilter\__construct(), SimpleSAML_Metadata_SAMLBuilder\addSecurityTokenServiceType(), sspmod_saml_Message\buildAuthnRequest(), sspmod_saml_IdP_SAML2\getAssociationConfig(), getConfigItem(), getConfigList(), SimpleSAML_Metadata_MetaDataStorageHandler\getMetaDataConfig(), SimpleSAML_Metadata_MetaDataStorageHandler\getMetaDataConfigForSha1(), sspmod_saml_IdP_SAML2\handleAuthError(), loadFromFile(), metarefresh_hook_cron(), sspmod_adfs_IdP_ADFS\sendResponse(), sspmod_saml_IdP_SAML1\sendResponse(), and sspmod_saml_IdP_SAML2\sendResponse().

+ Here is the caller graph for this function:

◆ loadFromFile()

static SimpleSAML_Configuration::loadFromFile (   $filename,
  $required 
)
staticprivate

Load the given configuration file.

Parameters
string$filenameThe full path of the configuration file.
bool$requiredWhether the file is required.
Returns
SimpleSAML_Configuration The configuration file. An exception will be thrown if the configuration file is missing.
Exceptions
ExceptionIf the configuration file is invalid or missing.

Definition at line 109 of file Configuration.php.

110 {
111 assert('is_string($filename)');
112 assert('is_bool($required)');
113
114 if (array_key_exists($filename, self::$loadedConfigs)) {
115 return self::$loadedConfigs[$filename];
116 }
117
118 if (file_exists($filename)) {
119 $config = 'UNINITIALIZED';
120
121 // the file initializes a variable named '$config'
122 ob_start();
123 if (interface_exists('Throwable')) {
124 try {
125 require($filename);
126 } catch (ParseError $e) {
127 self::$loadedConfigs[$filename] = self::loadFromArray(array(), '[ARRAY]', 'simplesaml');
128 throw new SimpleSAML\Error\ConfigurationError($e->getMessage(), $filename, array());
129 }
130 } else {
131 require($filename);
132 }
133
134 $spurious_output = ob_get_length() > 0;
135 ob_end_clean();
136
137 // check that $config exists
138 if (!isset($config)) {
139 throw new \SimpleSAML\Error\ConfigurationError(
140 '$config is not defined in the configuration file.',
142 );
143 }
144
145 // check that $config is initialized to an array
146 if (!is_array($config)) {
147 throw new \SimpleSAML\Error\ConfigurationError(
148 '$config is not an array.',
150 );
151 }
152
153 // check that $config is not empty
154 if (empty($config)) {
155 throw new \SimpleSAML\Error\ConfigurationError(
156 '$config is empty.',
158 );
159 }
160 } elseif ($required) {
161 // file does not exist, but is required
162 throw new \SimpleSAML\Error\ConfigurationError('Missing configuration file', $filename);
163 } else {
164 // file does not exist, but is optional, so return an empty configuration object without saving it
166 $cfg->filename = $filename;
167 return $cfg;
168 }
169
171 $cfg->filename = $filename;
172
173 self::$loadedConfigs[$filename] = $cfg;
174
175 if ($spurious_output) {
177 "The configuration file '$filename' generates output. Please review your configuration."
178 );
179 }
180
181 return $cfg;
182 }
catch(Exception $e) if(isset( $_POST[ 'cancel'])) if(isset($_POST['continue'])) $cfg

References $cfg, $config, $filename, loadFromArray(), and SimpleSAML\Logger\warning().

+ Here is the call graph for this function:

◆ resolvePath()

SimpleSAML_Configuration::resolvePath (   $path)

This function resolves a path which may be relative to the SimpleSAMLphp base directory.

The path will never end with a '/'.

Parameters
string | null$pathThe path we should resolve. This option may be null.
Returns
string|null $path if $path is an absolute path, or $path prepended with the base directory of this SimpleSAMLphp installation. We will return NULL if $path is null.

Definition at line 536 of file Configuration.php.

537 {
538 if ($path === null) {
539 return null;
540 }
541
542 assert('is_string($path)');
543
544 /* Prepend path with basedir if it doesn't start with a slash or a Windows drive letter (e.g. "C:\"). We assume
545 * getBaseDir ends with a slash.
546 */
547 if ($path[0] !== '/' &&
548 !(preg_match('@^[a-z]:[\\\\/]@i', $path, $matches) && is_dir($matches[0]))
549 ) {
550 $path = $this->getBaseDir().$path;
551 }
552
553 // remove trailing slashes
554 $path = rtrim($path, '/');
555
556 return $path;
557 }
getBaseDir()
Retrieve the base directory for this SimpleSAMLphp installation.

References $path, and getBaseDir().

Referenced by getPathValue().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setConfigDir()

static SimpleSAML_Configuration::setConfigDir (   $path,
  $configSet = 'simplesaml' 
)
static

Set the directory for configuration files for the given configuration set.

Parameters
string$pathThe directory which contains the configuration files.
string$configSetThe configuration set. Defaults to 'simplesaml'.

Definition at line 191 of file Configuration.php.

192 {
193 assert('is_string($path)');
194 assert('is_string($configSet)');
195
196 self::$configDirs[$configSet] = $path;
197 }

References $path.

Referenced by ilSimpleSAMLphpWrapper\__construct().

+ Here is the caller graph for this function:

◆ toArray()

SimpleSAML_Configuration::toArray ( )

Convert this configuration object back to an array.

Returns
array An associative array with all configuration options and values.

Definition at line 1055 of file Configuration.php.

1056 {
1057 return $this->configuration;
1058 }

References $configuration.

Field Documentation

◆ $configDirs

SimpleSAML_Configuration::$configDirs = array()
staticprivate

Definition at line 37 of file Configuration.php.

◆ $configuration

SimpleSAML_Configuration::$configuration
private

Definition at line 55 of file Configuration.php.

Referenced by toArray().

◆ $deprecated_base_url_used

SimpleSAML_Configuration::$deprecated_base_url_used = false
private

Definition at line 79 of file Configuration.php.

◆ $filename

SimpleSAML_Configuration::$filename = null
private

Definition at line 71 of file Configuration.php.

Referenced by loadFromFile().

◆ $instance

SimpleSAML_Configuration::$instance = array()
staticprivate

Definition at line 26 of file Configuration.php.

◆ $loadedConfigs

SimpleSAML_Configuration::$loadedConfigs = array()
staticprivate

Definition at line 47 of file Configuration.php.

◆ $location

SimpleSAML_Configuration::$location
private

Definition at line 63 of file Configuration.php.

Referenced by __construct().

◆ REQUIRED_OPTION

const SimpleSAML_Configuration::REQUIRED_OPTION = '___REQUIRED_OPTION___'

Definition at line 18 of file Configuration.php.


The documentation for this class was generated from the following file: