ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Configuration.php
Go to the documentation of this file.
1<?php
2
4
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
108 private static function loadFromFile($filename, $required)
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 }
182
183
190 public static function setConfigDir($path, $configSet = 'simplesaml')
191 {
192 assert(is_string($path));
193 assert(is_string($configSet));
194
195 self::$configDirs[$configSet] = $path;
196 }
197
208 public static function setPreLoadedConfig(SimpleSAML_Configuration $config, $filename = 'config.php', $configSet = 'simplesaml')
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 }
226
227
237 public static function getConfig($filename = 'config.php', $configSet = 'simplesaml')
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 }
254
255
267 public static function getOptionalConfig($filename = 'config.php', $configSet = 'simplesaml')
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 }
284
285
297 public static function loadFromArray($config, $location = '[ARRAY]', $instance = null)
298 {
299 assert(is_array($config));
300 assert(is_string($location));
301
302 $c = new SimpleSAML_Configuration($config, $location);
303 if ($instance !== null) {
304 self::$instance[$instance] = $c;
305 }
306 return $c;
307 }
308
309
325 public static function getInstance($instancename = 'simplesaml')
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 }
346
347
360 public static function init($path, $instancename = 'simplesaml', $configfilename = 'config.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 }
379
380
392 public function copyFromBase($instancename, $filename)
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 }
408
409
415 public function getVersion()
416 {
417 return '1.16.2';
418 }
419
420
433 public function getValue($name, $default = null)
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 }
448
449
457 public function hasValue($name)
458 {
459 return array_key_exists($name, $this->configuration);
460 }
461
462
470 public function hasValueOneOf($names)
471 {
472 foreach ($names as $name) {
473 if ($this->hasValue($name)) {
474 return true;
475 }
476 }
477 return false;
478 }
479
480
494 public function getBaseURL()
495 {
496 if (!$this->deprecated_base_url_used) {
497 $this->deprecated_base_url_used = true;
498 SimpleSAML\Logger::warning(
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 }
508
509
519 public function getBasePath()
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 }
552
553
564 public function resolvePath($path)
565 {
566 if ($path === null) {
567 return null;
568 }
569
570 assert(is_string($path));
571
572 return System::resolvePath($path, $this->getBaseDir());
573 }
574
575
590 public function getPathValue($name, $default = null)
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 }
605
606
616 public function getBaseDir()
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 }
646
647
664 public function getBoolean($name, $default = self::REQUIRED_OPTION)
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 }
684
685
702 public function getString($name, $default = self::REQUIRED_OPTION)
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 }
722
723
740 public function getInteger($name, $default = self::REQUIRED_OPTION)
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 }
760
761
782 public function getIntegerRange($name, $minimum, $maximum, $default = self::REQUIRED_OPTION)
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 }
805
806
828 public function getValueValidate($name, $allowedValues, $default = self::REQUIRED_OPTION)
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 }
855
856
873 public function getArray($name, $default = self::REQUIRED_OPTION)
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 }
890
891
904 public function getArrayize($name, $default = self::REQUIRED_OPTION)
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 }
921
922
937 public function getArrayizeString($name, $default = self::REQUIRED_OPTION)
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 }
959
960
979 public function getConfigItem($name, $default = self::REQUIRED_OPTION)
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 }
999
1000
1020 public function getConfigList($name, $default = self::REQUIRED_OPTION)
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 }
1050
1051
1060 public function getOptions()
1061 {
1062 return array_keys($this->configuration);
1063 }
1064
1065
1071 public function toArray()
1072 {
1073 return $this->configuration;
1074 }
1075
1076
1089 private function getDefaultBinding($endpointType)
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 }
1111
1112
1122 public function getEndpoints($endpointType)
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 }
1189
1190
1203 public function getEndpointPrioritizedByBinding($endpointType, array $bindings, $default = self::REQUIRED_OPTION)
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 }
1224
1225
1238 public function getDefaultEndpoint($endpointType, array $bindings = null, $default = self::REQUIRED_OPTION)
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 }
1256
1257
1271 public function getLocalizedString($name, $default = self::REQUIRED_OPTION)
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 }
1302
1303
1319 public function getPublicKeys($use = null, $required = false, $prefix = '')
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 }
1380
1386 public static function clearInternalState()
1387 {
1388 self::$configDirs = array();
1389 self::$instance = array();
1390 self::$loadedConfigs = array();
1391 }
1392}
$path
Definition: aliased.php:25
$default
Definition: build.php:20
An exception for terminatinating execution or to throw for unit testing.
static warning($string)
Definition: Logger.php:177
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:562
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.
static setPreLoadedConfig(SimpleSAML_Configuration $config, $filename='config.php', $configSet='simplesaml')
Store a pre-initialized configuration.
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.
if(!file_exists(getcwd() . '/ilias.ini.php'))
registration confirmation script for ilias
Definition: confirmReg.php:12
$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
$config
Definition: bootstrap.php:15
$index
Definition: metadata.php:60
$eps
Definition: metadata.php:61
$binding
$bindings
$ret
Definition: parser.php:6
$data
Definition: bench.php:6
catch(Exception $e) if(isset( $_POST[ 'cancel'])) if(isset($_POST['continue'])) $cfg