ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 setPreLoadedConfig (SimpleSAML_Configuration $config, $filename='config.php', $configSet='simplesaml')
 Store a pre-initialized configuration. 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 11 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 }
$config
Definition: bootstrap.php:15

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 1386 of file Configuration.php.

1387 {
1388 self::$configDirs = array();
1389 self::$instance = array();
1390 self::$loadedConfigs = array();
1391 }

◆ 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 392 of file Configuration.php.

393 {
394 assert(is_string($instancename));
395 assert(is_string($filename));
396 assert($this->filename !== null);
397
398 // check if we already have loaded the given config - return the existing instance if we have
399 if (array_key_exists($instancename, self::$instance)) {
400 return self::$instance[$instancename];
401 }
402
403 $dir = dirname($this->filename);
404
405 self::$instance[$instancename] = self::loadFromFile($dir.'/'.$filename, true);
406 return self::$instance[$instancename];
407 }
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 873 of file Configuration.php.

874 {
875 assert(is_string($name));
876
877 $ret = $this->getValue($name, $default);
878
879 if ($ret === $default) {
880 // the option wasn't found, or it matches the default value. In any case, return this value
881 return $ret;
882 }
883
884 if (!is_array($ret)) {
885 throw new Exception($this->location.': The option '.var_export($name, true).' is not an array.');
886 }
887
888 return $ret;
889 }
$default
Definition: build.php:20
getValue($name, $default=null)
Retrieve a configuration option set in config.php.
$ret
Definition: parser.php:6

References $default, $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 904 of file Configuration.php.

905 {
906 assert(is_string($name));
907
908 $ret = $this->getValue($name, $default);
909
910 if ($ret === $default) {
911 // the option wasn't found, or it matches the default value. In any case, return this value
912 return $ret;
913 }
914
915 if (!is_array($ret)) {
916 $ret = array($ret);
917 }
918
919 return $ret;
920 }

References $default, $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 937 of file Configuration.php.

938 {
939 assert(is_string($name));
940
941 $ret = $this->getArrayize($name, $default);
942
943 if ($ret === $default) {
944 // the option wasn't found, or it matches the default value. In any case, return this value
945 return $ret;
946 }
947
948 foreach ($ret as $value) {
949 if (!is_string($value)) {
950 throw new Exception(
951 $this->location.': The option '.var_export($name, true).
952 ' must be a string or an array of strings.'
953 );
954 }
955 }
956
957 return $ret;
958 }
getArrayize($name, $default=self::REQUIRED_OPTION)
This function retrieves an array configuration option.

References $default, $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 616 of file Configuration.php.

617 {
618 // check if a directory is configured in the configuration file
619 $dir = $this->getString('basedir', null);
620 if ($dir !== null) {
621 // add trailing slash if it is missing
622 if (substr($dir, -1) !== DIRECTORY_SEPARATOR) {
623 $dir .= DIRECTORY_SEPARATOR;
624 }
625
626 return $dir;
627 }
628
629 // the directory wasn't set in the configuration file, path is <base directory>/lib/SimpleSAML/Configuration.php
630 $dir = __FILE__;
631 assert(basename($dir) === 'Configuration.php');
632
633 $dir = dirname($dir);
634 assert(basename($dir) === 'SimpleSAML');
635
636 $dir = dirname($dir);
637 assert(basename($dir) === 'lib');
638
639 $dir = dirname($dir);
640
641 // Add trailing directory separator
642 $dir .= DIRECTORY_SEPARATOR;
643
644 return $dir;
645 }
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 519 of file Configuration.php.

520 {
521 $baseURL = $this->getString('baseurlpath', 'simplesaml/');
522
523 if (preg_match('#^https?://[^/]*(?:/(.+/?)?)?$#', $baseURL, $matches)) {
524 // we have a full url, we need to strip the path
525 if (!array_key_exists(1, $matches)) {
526 // absolute URL without path
527 return '/';
528 }
529 return '/'.rtrim($matches[1], '/')."/";
530 } elseif ($baseURL === '' || $baseURL === '/') {
531 // root directory of site
532 return '/';
533 } elseif (preg_match('#^/?((?:[^/\s]+/?)+)#', $baseURL, $matches)) {
534 // local path only
535 return '/'.rtrim($matches[1], '/').'/';
536 } else {
537 /*
538 * Invalid 'baseurlpath'. We cannot recover from this, so throw a critical exception and try to be graceful
539 * with the configuration. Use a guessed base path instead of the one provided.
540 */
541 $c = $this->toArray();
542 $c['baseurlpath'] = SimpleSAML\Utils\HTTP::guessBasePath();
544 'Incorrect format for option \'baseurlpath\'. Value is: "'.
545 $this->getString('baseurlpath', 'simplesaml/').'". Valid format is in the form'.
546 ' [(http|https)://(hostname|fqdn)[:port]]/[path/to/simplesaml/].',
547 $this->filename,
548 $c
549 );
550 }
551 }
static guessBasePath()
Try to guess the base SimpleSAMLphp path from the current request.
Definition: HTTP.php:562
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 494 of file Configuration.php.

495 {
496 if (!$this->deprecated_base_url_used) {
497 $this->deprecated_base_url_used = true;
499 "SimpleSAML_Configuration::getBaseURL() is deprecated, please use getBasePath() instead."
500 );
501 }
502 if (preg_match('/^\*(.*)$/D', $this->getString('baseurlpath', 'simplesaml/'), $matches)) {
503 // deprecated behaviour, will be removed in the future
504 return \SimpleSAML\Utils\HTTP::getFirstPathElement(false).$matches[1];
505 }
506 return ltrim($this->getBasePath(), '/');
507 }
static warning($string)
Definition: Logger.php:177
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 664 of file Configuration.php.

665 {
666 assert(is_string($name));
667
668 $ret = $this->getValue($name, $default);
669
670 if ($ret === $default) {
671 // the option wasn't found, or it matches the default value. In any case, return this value
672 return $ret;
673 }
674
675 if (!is_bool($ret)) {
676 throw new Exception(
677 $this->location.': The option '.var_export($name, true).
678 ' is not a valid boolean value.'
679 );
680 }
681
682 return $ret;
683 }

References $default, $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 237 of file Configuration.php.

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

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 979 of file Configuration.php.

980 {
981 assert(is_string($name));
982
983 $ret = $this->getValue($name, $default);
984
985 if ($ret === $default) {
986 // the option wasn't found, or it matches the default value. In any case, return this value
987 return $ret;
988 }
989
990 if (!is_array($ret)) {
991 throw new Exception(
992 $this->location.': The option '.var_export($name, true).
993 ' is not an array.'
994 );
995 }
996
997 return self::loadFromArray($ret, $this->location.'['.var_export($name, true).']');
998 }
static loadFromArray($config, $location='[ARRAY]', $instance=null)
Loads a configuration from the given array.

References $default, $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 1020 of file Configuration.php.

1021 {
1022 assert(is_string($name));
1023
1024 $ret = $this->getValue($name, $default);
1025
1026 if ($ret === $default) {
1027 // the option wasn't found, or it matches the default value. In any case, return this value
1028 return $ret;
1029 }
1030
1031 if (!is_array($ret)) {
1032 throw new Exception(
1033 $this->location.': The option '.var_export($name, true).
1034 ' is not an array.'
1035 );
1036 }
1037
1038 $out = array();
1039 foreach ($ret as $index => $config) {
1040 $newLoc = $this->location.'['.var_export($name, true).']['.
1041 var_export($index, true).']';
1042 if (!is_array($config)) {
1043 throw new Exception($newLoc.': The value of this element was expected to be an array.');
1044 }
1046 }
1047
1048 return $out;
1049 }
$index
Definition: metadata.php:60

References $config, $default, $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 1089 of file Configuration.php.

1090 {
1091 assert(is_string($endpointType));
1092
1093 $set = $this->getString('metadata-set');
1094 switch ($set.':'.$endpointType) {
1095 case 'saml20-idp-remote:SingleSignOnService':
1096 case 'saml20-idp-remote:SingleLogoutService':
1097 case 'saml20-sp-remote:SingleLogoutService':
1098 return \SAML2\Constants::BINDING_HTTP_REDIRECT;
1099 case 'saml20-sp-remote:AssertionConsumerService':
1100 return \SAML2\Constants::BINDING_HTTP_POST;
1101 case 'saml20-idp-remote:ArtifactResolutionService':
1102 return \SAML2\Constants::BINDING_SOAP;
1103 case 'shib13-idp-remote:SingleSignOnService':
1104 return 'urn:mace:shibboleth:1.0:profiles:AuthnRequest';
1105 case 'shib13-sp-remote:AssertionConsumerService':
1106 return 'urn:oasis:names:tc:SAML:1.0:profiles:browser-post';
1107 default:
1108 throw new Exception('Missing default binding for '.$endpointType.' in '.$set);
1109 }
1110 }

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 1238 of file Configuration.php.

1239 {
1240 assert(is_string($endpointType));
1241
1242 $endpoints = $this->getEndpoints($endpointType);
1243
1245 if ($defaultEndpoint !== null) {
1246 return $defaultEndpoint;
1247 }
1248
1249 if ($default === self::REQUIRED_OPTION) {
1250 $loc = $this->location.'['.var_export($endpointType, true).']:';
1251 throw new Exception($loc.'Could not find a supported '.$endpointType.' endpoint.');
1252 }
1253
1254 return $default;
1255 }
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, $default, 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 1203 of file Configuration.php.

1204 {
1205 assert(is_string($endpointType));
1206
1207 $endpoints = $this->getEndpoints($endpointType);
1208
1209 foreach ($bindings as $binding) {
1210 foreach ($endpoints as $ep) {
1211 if ($ep['Binding'] === $binding) {
1212 return $ep;
1213 }
1214 }
1215 }
1216
1217 if ($default === self::REQUIRED_OPTION) {
1218 $loc = $this->location.'['.var_export($endpointType, true).']:';
1219 throw new Exception($loc.'Could not find a supported '.$endpointType.' endpoint.');
1220 }
1221
1222 return $default;
1223 }
$binding

References $binding, $bindings, $default, 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 1122 of file Configuration.php.

1123 {
1124 assert(is_string($endpointType));
1125
1126 $loc = $this->location.'['.var_export($endpointType, true).']:';
1127
1128 if (!array_key_exists($endpointType, $this->configuration)) {
1129 // no endpoints of the given type
1130 return array();
1131 }
1132
1133
1134 $eps = $this->configuration[$endpointType];
1135 if (is_string($eps)) {
1136 // for backwards-compatibility
1137 $eps = array($eps);
1138 } elseif (!is_array($eps)) {
1139 throw new Exception($loc.': Expected array or string.');
1140 }
1141
1142
1143 foreach ($eps as $i => &$ep) {
1144 $iloc = $loc.'['.var_export($i, true).']';
1145
1146 if (is_string($ep)) {
1147 // for backwards-compatibility
1148 $ep = array(
1149 'Location' => $ep,
1150 'Binding' => $this->getDefaultBinding($endpointType),
1151 );
1152 $responseLocation = $this->getString($endpointType.'Response', null);
1153 if ($responseLocation !== null) {
1154 $ep['ResponseLocation'] = $responseLocation;
1155 }
1156 } elseif (!is_array($ep)) {
1157 throw new Exception($iloc.': Expected a string or an array.');
1158 }
1159
1160 if (!array_key_exists('Location', $ep)) {
1161 throw new Exception($iloc.': Missing Location.');
1162 }
1163 if (!is_string($ep['Location'])) {
1164 throw new Exception($iloc.': Location must be a string.');
1165 }
1166
1167 if (!array_key_exists('Binding', $ep)) {
1168 throw new Exception($iloc.': Missing Binding.');
1169 }
1170 if (!is_string($ep['Binding'])) {
1171 throw new Exception($iloc.': Binding must be a string.');
1172 }
1173
1174 if (array_key_exists('ResponseLocation', $ep)) {
1175 if (!is_string($ep['ResponseLocation'])) {
1176 throw new Exception($iloc.': ResponseLocation must be a string.');
1177 }
1178 }
1179
1180 if (array_key_exists('index', $ep)) {
1181 if (!is_int($ep['index'])) {
1182 throw new Exception($iloc.': index must be an integer.');
1183 }
1184 }
1185 }
1186
1187 return $eps;
1188 }
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 325 of file Configuration.php.

326 {
327 assert(is_string($instancename));
328
329 // check if the instance exists already
330 if (array_key_exists($instancename, self::$instance)) {
331 return self::$instance[$instancename];
332 }
333
334 if ($instancename === 'simplesaml') {
335 try {
336 return self::getConfig();
337 } catch (SimpleSAML\Error\ConfigurationError $e) {
338 throw \SimpleSAML\Error\CriticalConfigurationError::fromException($e);
339 }
340 }
341
342 throw new \SimpleSAML\Error\CriticalConfigurationError(
343 'Configuration with name '.$instancename.' is not initialized.'
344 );
345 }
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(), 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(), SimpleSAML\Locale\Translate\translateFromArray(), 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 740 of file Configuration.php.

741 {
742 assert(is_string($name));
743
744 $ret = $this->getValue($name, $default);
745
746 if ($ret === $default) {
747 // the option wasn't found, or it matches the default value. In any case, return this value
748 return $ret;
749 }
750
751 if (!is_int($ret)) {
752 throw new Exception(
753 $this->location.': The option '.var_export($name, true).
754 ' is not a valid integer value.'
755 );
756 }
757
758 return $ret;
759 }

References $default, $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 782 of file Configuration.php.

783 {
784 assert(is_string($name));
785 assert(is_int($minimum));
786 assert(is_int($maximum));
787
788 $ret = $this->getInteger($name, $default);
789
790 if ($ret === $default) {
791 // the option wasn't found, or it matches the default value. In any case, return this value
792 return $ret;
793 }
794
795 if ($ret < $minimum || $ret > $maximum) {
796 throw new Exception(
797 $this->location.': Value of option '.var_export($name, true).
798 ' is out of range. Value is '.$ret.', allowed range is ['
799 .$minimum.' - '.$maximum.']'
800 );
801 }
802
803 return $ret;
804 }
getInteger($name, $default=self::REQUIRED_OPTION)
This function retrieves an integer configuration option.

References $default, $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 1271 of file Configuration.php.

1272 {
1273 assert(is_string($name));
1274
1275 $ret = $this->getValue($name, $default);
1276 if ($ret === $default) {
1277 // the option wasn't found, or it matches the default value. In any case, return this value
1278 return $ret;
1279 }
1280
1281 $loc = $this->location.'['.var_export($name, true).']';
1282
1283 if (is_string($ret)) {
1284 $ret = array('en' => $ret,);
1285 }
1286
1287 if (!is_array($ret)) {
1288 throw new Exception($loc.': Must be an array or a string.');
1289 }
1290
1291 foreach ($ret as $k => $v) {
1292 if (!is_string($k)) {
1293 throw new Exception($loc.': Invalid language code: '.var_export($k, true));
1294 }
1295 if (!is_string($v)) {
1296 throw new Exception($loc.'['.var_export($v, true).']: Must be a string.');
1297 }
1298 }
1299
1300 return $ret;
1301 }

References $default, $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 267 of file Configuration.php.

268 {
269 assert(is_string($filename));
270 assert(is_string($configSet));
271
272 if (!array_key_exists($configSet, self::$configDirs)) {
273 if ($configSet !== 'simplesaml') {
274 throw new Exception('Configuration set \''.$configSet.'\' not initialized.');
275 } else {
276 self::$configDirs['simplesaml'] = SimpleSAML\Utils\Config::getConfigDir();
277 }
278 }
279
280 $dir = self::$configDirs[$configSet];
281 $filePath = $dir.'/'.$filename;
282 return self::loadFromFile($filePath, false);
283 }

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 1060 of file Configuration.php.

1061 {
1062 return array_keys($this->configuration);
1063 }

◆ 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 590 of file Configuration.php.

591 {
592 // return the default value if the option is unset
593 if (!array_key_exists($name, $this->configuration)) {
594 $path = $default;
595 } else {
596 $path = $this->configuration[$name];
597 }
598
599 if ($path === null) {
600 return null;
601 }
602
603 return $this->resolvePath($path).'/';
604 }
$path
Definition: aliased.php:25
resolvePath($path)
This function resolves a path which may be relative to the SimpleSAMLphp base directory.

References $default, $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 Public key data, or empty array 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 1319 of file Configuration.php.

1320 {
1321 assert(is_bool($required));
1322 assert(is_string($prefix));
1323
1324 if ($this->hasValue($prefix.'keys')) {
1325 $ret = array();
1326 foreach ($this->getArray($prefix.'keys') as $key) {
1327 if ($use !== null && isset($key[$use]) && !$key[$use]) {
1328 continue;
1329 }
1330 if (isset($key['X509Certificate'])) {
1331 // Strip whitespace from key
1332 $key['X509Certificate'] = preg_replace('/\s+/', '', $key['X509Certificate']);
1333 }
1334 $ret[] = $key;
1335 }
1336 return $ret;
1337 } elseif ($this->hasValue($prefix.'certData')) {
1338 $certData = $this->getString($prefix.'certData');
1339 $certData = preg_replace('/\s+/', '', $certData);
1340 return array(
1341 array(
1342 'encryption' => true,
1343 'signing' => true,
1344 'type' => 'X509Certificate',
1345 'X509Certificate' => $certData,
1346 ),
1347 );
1348 } elseif ($this->hasValue($prefix.'certificate')) {
1349 $file = $this->getString($prefix.'certificate');
1351 $data = @file_get_contents($file);
1352
1353 if ($data === false) {
1354 throw new Exception($this->location.': Unable to load certificate/public key from file "'.$file.'".');
1355 }
1356
1357 // extract certificate data (if this is a certificate)
1358 $pattern = '/^-----BEGIN CERTIFICATE-----([^-]*)^-----END CERTIFICATE-----/m';
1359 if (!preg_match($pattern, $data, $matches)) {
1361 $this->location.': Could not find PEM encoded certificate in "'.$file.'".'
1362 );
1363 }
1364 $certData = preg_replace('/\s+/', '', $matches[1]);
1365
1366 return array(
1367 array(
1368 'encryption' => true,
1369 'signing' => true,
1370 'type' => 'X509Certificate',
1371 'X509Certificate' => $certData,
1372 ),
1373 );
1374 } elseif ($required === true) {
1375 throw new SimpleSAML_Error_Exception($this->location.': Missing certificate in metadata.');
1376 } else {
1377 return array();
1378 }
1379 }
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
$data
Definition: bench.php:6

References $data, $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 702 of file Configuration.php.

703 {
704 assert(is_string($name));
705
706 $ret = $this->getValue($name, $default);
707
708 if ($ret === $default) {
709 // the option wasn't found, or it matches the default value. In any case, return this value
710 return $ret;
711 }
712
713 if (!is_string($ret)) {
714 throw new Exception(
715 $this->location.': The option '.var_export($name, true).
716 ' is not a valid string value.'
717 );
718 }
719
720 return $ret;
721 }

References $default, $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 433 of file Configuration.php.

434 {
435 // return the default value if the option is unset
436 if (!array_key_exists($name, $this->configuration)) {
437 if ($default === self::REQUIRED_OPTION) {
438 throw new Exception(
439 $this->location.': Could not retrieve the required option '.
440 var_export($name, true)
441 );
442 }
443 return $default;
444 }
445
446 return $this->configuration[$name];
447 }

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 828 of file Configuration.php.

829 {
830 assert(is_string($name));
831 assert(is_array($allowedValues));
832
833 $ret = $this->getValue($name, $default);
834 if ($ret === $default) {
835 // the option wasn't found, or it matches the default value. In any case, return this value
836 return $ret;
837 }
838
839 if (!in_array($ret, $allowedValues, true)) {
840 $strValues = array();
841 foreach ($allowedValues as $av) {
842 $strValues[] = var_export($av, true);
843 }
844 $strValues = implode(', ', $strValues);
845
846 throw new Exception(
847 $this->location.': Invalid value given for the option '.
848 var_export($name, true).'. It should have one of the following values: '.
849 $strValues.'; but it had the following value: '.var_export($ret, true)
850 );
851 }
852
853 return $ret;
854 }

References $default, $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 415 of file Configuration.php.

416 {
417 return '1.16.2';
418 }

◆ 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 457 of file Configuration.php.

458 {
459 return array_key_exists($name, $this->configuration);
460 }

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 470 of file Configuration.php.

471 {
472 foreach ($names as $name) {
473 if ($this->hasValue($name)) {
474 return true;
475 }
476 }
477 return false;
478 }

◆ 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 360 of file Configuration.php.

361 {
362 assert(is_string($path));
363 assert(is_string($instancename));
364 assert(is_string($configfilename));
365
366 if ($instancename === 'simplesaml') {
367 // for backwards compatibility
368 self::setConfigDir($path, 'simplesaml');
369 }
370
371 // check if we already have loaded the given config - return the existing instance if we have
372 if (array_key_exists($instancename, self::$instance)) {
373 return self::$instance[$instancename];
374 }
375
376 self::$instance[$instancename] = self::loadFromFile($path.'/'.$configfilename, true);
377 return self::$instance[$instancename];
378 }
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 297 of file Configuration.php.

298 {
299 assert(is_array($config));
300 assert(is_string($location));
301
303 if ($instance !== null) {
304 self::$instance[$instance] = $c;
305 }
306 return $c;
307 }

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_cas_Auth_Source_CAS\finalStep(), 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 108 of file Configuration.php.

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

565 {
566 if ($path === null) {
567 return null;
568 }
569
570 assert(is_string($path));
571
572 return System::resolvePath($path, $this->getBaseDir());
573 }
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 190 of file Configuration.php.

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

References $path.

Referenced by ilSimpleSAMLphpWrapper\__construct().

+ Here is the caller graph for this function:

◆ setPreLoadedConfig()

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

Store a pre-initialized configuration.

Allows consumers to create configuration objects without having them loaded from a file.

Parameters
SimpleSAML_Configuration$configThe configuration object to store
string$filenameThe name of the configuration file.
string$configSetThe configuration set. Optional, defaults to 'simplesaml'.

Definition at line 208 of file Configuration.php.

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

References $filename.

◆ 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 1071 of file Configuration.php.

1072 {
1073 return $this->configuration;
1074 }

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(), and setPreLoadedConfig().

◆ $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: