ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Configuration.php
Go to the documentation of this file.
1<?php
2
3
11{
12
18 const REQUIRED_OPTION = '___REQUIRED_OPTION___';
19
20
26 private static $instance = array();
27
28
37 private static $configDirs = array();
38
39
47 private static $loadedConfigs = array();
48
49
56
57
63 private $location;
64
65
71 private $filename = null;
72
73
80
81
88 public function __construct($config, $location)
89 {
90 assert('is_array($config)');
91 assert('is_string($location)');
92
93 $this->configuration = $config;
94 $this->location = $location;
95 }
96
97
109 private static function loadFromFile($filename, $required)
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 }
183
184
191 public static function setConfigDir($path, $configSet = 'simplesaml')
192 {
193 assert('is_string($path)');
194 assert('is_string($configSet)');
195
196 self::$configDirs[$configSet] = $path;
197 }
198
199
209 public static function getConfig($filename = 'config.php', $configSet = 'simplesaml')
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 }
226
227
239 public static function getOptionalConfig($filename = 'config.php', $configSet = 'simplesaml')
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 }
256
257
269 public static function loadFromArray($config, $location = '[ARRAY]', $instance = null)
270 {
271 assert('is_array($config)');
272 assert('is_string($location)');
273
274 $c = new SimpleSAML_Configuration($config, $location);
275 if ($instance !== null) {
276 self::$instance[$instance] = $c;
277 }
278 return $c;
279 }
280
281
297 public static function getInstance($instancename = 'simplesaml')
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 }
318
319
332 public static function init($path, $instancename = 'simplesaml', $configfilename = 'config.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 }
351
352
364 public function copyFromBase($instancename, $filename)
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 }
380
381
387 public function getVersion()
388 {
389 return '1.15.3';
390 }
391
392
405 public function getValue($name, $default = null)
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 }
420
421
429 public function hasValue($name)
430 {
431 return array_key_exists($name, $this->configuration);
432 }
433
434
442 public function hasValueOneOf($names)
443 {
444 foreach ($names as $name) {
445 if ($this->hasValue($name)) {
446 return true;
447 }
448 }
449 return false;
450 }
451
452
466 public function getBaseURL()
467 {
468 if (!$this->deprecated_base_url_used) {
469 $this->deprecated_base_url_used = true;
470 SimpleSAML\Logger::warning(
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 }
480
481
491 public function getBasePath()
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 }
524
525
536 public function resolvePath($path)
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 }
558
559
574 public function getPathValue($name, $default = null)
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 }
589
590
600 public function getBaseDir()
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 }
630
631
648 public function getBoolean($name, $default = self::REQUIRED_OPTION)
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 }
668
669
686 public function getString($name, $default = self::REQUIRED_OPTION)
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 }
706
707
724 public function getInteger($name, $default = self::REQUIRED_OPTION)
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 }
744
745
766 public function getIntegerRange($name, $minimum, $maximum, $default = self::REQUIRED_OPTION)
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 }
789
790
812 public function getValueValidate($name, $allowedValues, $default = self::REQUIRED_OPTION)
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 }
839
840
857 public function getArray($name, $default = self::REQUIRED_OPTION)
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 }
874
875
888 public function getArrayize($name, $default = self::REQUIRED_OPTION)
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 }
905
906
921 public function getArrayizeString($name, $default = self::REQUIRED_OPTION)
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 }
943
944
963 public function getConfigItem($name, $default = self::REQUIRED_OPTION)
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 }
983
984
1004 public function getConfigList($name, $default = self::REQUIRED_OPTION)
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 }
1034
1035
1044 public function getOptions()
1045 {
1046 return array_keys($this->configuration);
1047 }
1048
1049
1055 public function toArray()
1056 {
1057 return $this->configuration;
1058 }
1059
1060
1073 private function getDefaultBinding($endpointType)
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 }
1095
1096
1106 public function getEndpoints($endpointType)
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 }
1173
1174
1187 public function getEndpointPrioritizedByBinding($endpointType, array $bindings, $default = self::REQUIRED_OPTION)
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 }
1208
1209
1222 public function getDefaultEndpoint($endpointType, array $bindings = null, $default = self::REQUIRED_OPTION)
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 }
1240
1241
1255 public function getLocalizedString($name, $default = self::REQUIRED_OPTION)
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 }
1286
1287
1303 public function getPublicKeys($use = null, $required = false, $prefix = '')
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 }
1368
1374 public static function clearInternalState()
1375 {
1376 self::$configDirs = array();
1377 self::$instance = array();
1378 self::$loadedConfigs = array();
1379 }
1380}
An exception for terminatinating execution or to throw for unit testing.
static warning($string)
Definition: Logger.php:179
static getDefaultEndpoint(array $endpoints, array $bindings=null)
Find the default endpoint in an endpoint array.
Definition: Metadata.php:221
static getCertPath($path)
Resolves a path that may be relative to the cert-directory.
Definition: Config.php:22
static guessBasePath()
Try to guess the base SimpleSAMLphp path from the current request.
Definition: HTTP.php:563
getLocalizedString($name, $default=self::REQUIRED_OPTION)
Retrieve a string which may be localized into many languages.
toArray()
Convert this configuration object back to an array.
getString($name, $default=self::REQUIRED_OPTION)
This function retrieves a string configuration option.
getBaseDir()
Retrieve the base directory for this SimpleSAMLphp installation.
resolvePath($path)
This function resolves a path which may be relative to the SimpleSAMLphp base directory.
getDefaultBinding($endpointType)
Retrieve the default binding for the given endpoint type.
getOptions()
Retrieve list of options.
__construct($config, $location)
Initializes a configuration from the given array.
getBoolean($name, $default=self::REQUIRED_OPTION)
This function retrieves a boolean configuration option.
getPathValue($name, $default=null)
Retrieve a path configuration option set in config.php.
static loadFromArray($config, $location='[ARRAY]', $instance=null)
Loads a configuration from the given array.
getArrayizeString($name, $default=self::REQUIRED_OPTION)
This function retrieves a configuration option with a string or an array of strings.
getEndpoints($endpointType)
Helper function for dealing with metadata endpoints.
getDefaultEndpoint($endpointType, array $bindings=null, $default=self::REQUIRED_OPTION)
Find the default endpoint of the given type.
getValueValidate($name, $allowedValues, $default=self::REQUIRED_OPTION)
Retrieve a configuration option with one of the given values.
getIntegerRange($name, $minimum, $maximum, $default=self::REQUIRED_OPTION)
This function retrieves an integer configuration option where the value must be in the specified rang...
getValue($name, $default=null)
Retrieve a configuration option set in config.php.
getInteger($name, $default=self::REQUIRED_OPTION)
This function retrieves an integer configuration option.
getArrayize($name, $default=self::REQUIRED_OPTION)
This function retrieves an array configuration option.
static loadFromFile($filename, $required)
Load the given configuration file.
static clearInternalState()
Clear any configuration information cached.
getArray($name, $default=self::REQUIRED_OPTION)
This function retrieves an array configuration option.
getPublicKeys($use=null, $required=false, $prefix='')
Get public key from metadata.
getConfigList($name, $default=self::REQUIRED_OPTION)
Retrieve an array of arrays as an array of SimpleSAML_Configuration objects.
getConfigItem($name, $default=self::REQUIRED_OPTION)
Retrieve an array as a SimpleSAML_Configuration object.
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.
static setConfigDir($path, $configSet='simplesaml')
Set the directory for configuration files for the given configuration set.
hasValue($name)
Check whether a key in the configuration exists or not.
static getConfig($filename='config.php', $configSet='simplesaml')
Load a configuration file from a configuration set.
$key
Definition: croninfo.php:18
$i
Definition: disco.tpl.php:19
foreach( $name as $i=> $nameSection)( $i==count( $name) - 1)( $nameSection) ?></span ><?php else from https
Definition: header.html.php:45
if($format !==null) $name
Definition: metadata.php:146
$index
Definition: metadata.php:60
$eps
Definition: metadata.php:61
$binding
$bindings
$ret
Definition: parser.php:6
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file
catch(Exception $e) if(isset( $_POST[ 'cancel'])) if(isset($_POST['continue'])) $cfg