summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/SimpleSAML/Error/Error.php2
-rw-r--r--lib/SimpleSAML/Metadata/MetaDataStorageHandlerFlatFile.php2
-rw-r--r--lib/SimpleSAML/Module.php2
-rw-r--r--lib/SimpleSAML/Utilities.php40
-rw-r--r--lib/SimpleSAML/Utils/HTTP.php41
5 files changed, 46 insertions, 41 deletions
diff --git a/lib/SimpleSAML/Error/Error.php b/lib/SimpleSAML/Error/Error.php
index a422e62..2c035bc 100644
--- a/lib/SimpleSAML/Error/Error.php
+++ b/lib/SimpleSAML/Error/Error.php
@@ -265,7 +265,7 @@ class SimpleSAML_Error_Error extends SimpleSAML_Error_Exception {
if($config->getBoolean('errorreporting', TRUE) &&
$config->getString('technicalcontact_email', 'na@example.org') !== 'na@example.org') {
/* Enable error reporting. */
- $baseurl = SimpleSAML_Utilities::getBaseURL();
+ $baseurl = \SimpleSAML\Utils\HTTP::getBaseURL();
$data['errorReportAddress'] = $baseurl . 'errorreport.php';
}
diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerFlatFile.php b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerFlatFile.php
index 22688c2..b028bb4 100644
--- a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerFlatFile.php
+++ b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerFlatFile.php
@@ -116,7 +116,7 @@ class SimpleSAML_Metadata_MetaDataStorageHandlerFlatFile extends SimpleSAML_Meta
private function generateDynamicHostedEntityID($set) {
/* Get the configuration. */
- $baseurl = SimpleSAML_Utilities::getBaseURL();
+ $baseurl = \SimpleSAML\Utils\HTTP::getBaseURL();
if ($set === 'saml20-idp-hosted') {
return $baseurl . 'saml2/idp/metadata.php';
diff --git a/lib/SimpleSAML/Module.php b/lib/SimpleSAML/Module.php
index 829fa7b..45b1ae6 100644
--- a/lib/SimpleSAML/Module.php
+++ b/lib/SimpleSAML/Module.php
@@ -155,7 +155,7 @@ class SimpleSAML_Module {
assert('is_string($resource)');
assert('$resource[0] !== "/"');
- $url = SimpleSAML_Utilities::getBaseURL() . 'module.php/' . $resource;
+ $url = \SimpleSAML\Utils\HTTP::getBaseURL() . 'module.php/' . $resource;
if (!empty($parameters)) {
$url = \SimpleSAML\Utils\HTTP::addURLParameters($url, $parameters);
}
diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php
index 81d8a28..b592539 100644
--- a/lib/SimpleSAML/Utilities.php
+++ b/lib/SimpleSAML/Utilities.php
@@ -208,46 +208,10 @@ class SimpleSAML_Utilities {
/**
- * Retrieve and return the absolute base URL for the simpleSAMLphp installation.
- *
- * For example: https://idp.example.org/simplesaml/
- *
- * The URL will always end with a '/'.
- *
- * @return string The absolute base URL for the simpleSAMLphp installation.
+ * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::getBaseURL() instead.
*/
public static function getBaseURL() {
-
- $globalConfig = SimpleSAML_Configuration::getInstance();
- $baseURL = $globalConfig->getString('baseurlpath', 'simplesaml/');
-
- if (preg_match('#^https?://.*/$#D', $baseURL, $matches)) {
- /* full URL in baseurlpath, override local server values */
- return $baseURL;
- } elseif (
- (preg_match('#^/?([^/]?.*/)$#D', $baseURL, $matches)) ||
- (preg_match('#^\*(.*)/$#D', $baseURL, $matches)) ||
- ($baseURL === '')) {
- /* get server values */
-
- if (self::getServerHTTPS()) {
- $protocol = 'https://';
- } else {
- $protocol = 'http://';
- }
-
- $hostname = self::getServerHost();
- $port = self::getServerPort();
- $path = '/' . $globalConfig->getBaseURL();
-
- return $protocol.$hostname.$port.$path;
- } else {
- throw new SimpleSAML_Error_Exception('Invalid value of \'baseurl\' in '.
- 'config.php. Valid format is in the form: '.
- '[(http|https)://(hostname|fqdn)[:port]]/[path/to/simplesaml/]. '.
- 'It must end with a \'/\'.');
- }
-
+ return \SimpleSAML\Utils\HTTP::getBaseURL();
}
diff --git a/lib/SimpleSAML/Utils/HTTP.php b/lib/SimpleSAML/Utils/HTTP.php
index 5c50427..96577ff 100644
--- a/lib/SimpleSAML/Utils/HTTP.php
+++ b/lib/SimpleSAML/Utils/HTTP.php
@@ -208,6 +208,47 @@ class HTTP
/**
+ * Retrieve the base URL of the SimpleSAMLphp installation. The URL will always end with a '/'. For example:
+ * https://idp.example.org/simplesaml/
+ *
+ * @return string The absolute base URL for the simpleSAMLphp installation.
+ * @throws \SimpleSAML_Error_Exception If 'baseurlpath' has an invalid format.
+ *
+ * @author Olav Morken, UNINETT AS <olav.morken@uninett.no>
+ */
+ public static function getBaseURL()
+ {
+ $globalConfig = \SimpleSAML_Configuration::getInstance();
+ $baseURL = $globalConfig->getString('baseurlpath', 'simplesaml/');
+
+ if (preg_match('#^https?://.*/$#D', $baseURL, $matches)) {
+ // full URL in baseurlpath, override local server values
+ return $baseURL;
+ } elseif (
+ (preg_match('#^/?([^/]?.*/)$#D', $baseURL, $matches)) ||
+ (preg_match('#^\*(.*)/$#D', $baseURL, $matches)) ||
+ ($baseURL === '')
+ ) {
+ // get server values
+ $protocol = 'http';
+ $protocol .= (self::getServerHTTPS()) ? 's' : '';
+ $protocol .= '://';
+
+ $hostname = self::getServerHost();
+ $port = self::getServerPort();
+ $path = '/'.$globalConfig->getBaseURL();
+
+ return $protocol.$hostname.$port.$path;
+ } else {
+ throw new \SimpleSAML_Error_Exception('Invalid value for \'baseurlpath\' in '.
+ 'config.php. Valid format is in the form: '.
+ '[(http|https)://(hostname|fqdn)[:port]]/[path/to/simplesaml/]. '.
+ 'It must end with a \'/\'.');
+ }
+ }
+
+
+ /**
* Parse a query string into an array.
*
* This function parses a query string into an array, similar to the way the builtin 'parse_str' works, except it