diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php b/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php index 7ec37a88e07cbf5db6cc0bc1762cceb143ba22ac..48c3e0470aa3244739de96085a7872ef122d42f8 100644 --- a/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php +++ b/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php @@ -187,7 +187,7 @@ class SimpleSAML_Metadata_MetaDataStorageHandler { assert('is_string($set)'); /* First we look for the hostname/path combination. */ - $currenthostwithpath = SimpleSAML_Utilities::getSelfHostWithPath(); // sp.example.org/university + $currenthostwithpath = \SimpleSAML\Utils\HTTP::getSelfHostWithPath(); // sp.example.org/university foreach($this->sources as $source) { $index = $source->getEntityIdFromHostPath($currenthostwithpath, $set, $type); diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php index f315e86e7d414f44bee71ffa9b5fb5168a679449..655fcdb17d7a8669c62acf8078be4803aa41c094 100644 --- a/lib/SimpleSAML/Utilities.php +++ b/lib/SimpleSAML/Utilities.php @@ -87,18 +87,10 @@ class SimpleSAML_Utilities { /** - * Will return sp.example.org/ssp/sp1 - * - * Please note this function will return the base URL for the current - * SP, as defined in the global configuration. + * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::getSelfHostWithPath() instead. */ public static function getSelfHostWithPath() { - - $baseurl = explode("/", self::getBaseURL()); - $elements = array_slice($baseurl, 3 - count($baseurl), count($baseurl) - 4); - $path = implode("/", $elements); - $selfhostwithpath = self::getSelfHost(); - return $selfhostwithpath . "/" . $path; + return \SimpleSAML\Utils\HTTP::getSelfHostWithPath(); } /** diff --git a/lib/SimpleSAML/Utils/HTTP.php b/lib/SimpleSAML/Utils/HTTP.php index 38840c5a22b6a7d701609af0a11b7fbfe02753fb..aecd23be39dc5beebeac00a42a2839af5d3e7d88 100644 --- a/lib/SimpleSAML/Utils/HTTP.php +++ b/lib/SimpleSAML/Utils/HTTP.php @@ -319,7 +319,7 @@ class HTTP /** * Retrieve our own host. * - * @return string The current host. + * @return string The current host (with non-default ports included). * * @author Andreas Solberg, UNINETT AS <andreas.solberg@uninett.no> * @author Olav Morken, UNINETT AS <olav.morken@uninett.no> @@ -335,6 +335,24 @@ class HTTP } + /** + * Retrieve our own host together with the URL path. Please note this function will return the base URL for the + * current SP, as defined in the global configuration. + * + * @return string The current host (with non-default ports included) plus the URL path. + * + * @author Andreas Solberg, UNINETT AS <andreas.solberg@uninett.no> + * @author Olav Morken, UNINETT AS <olav.morken@uninett.no> + */ + public static function getSelfHostWithPath() + { + $baseurl = explode("/", self::getBaseURL()); + $elements = array_slice($baseurl, 3 - count($baseurl), count($baseurl) - 4); + $path = implode("/", $elements); + return self::getSelfHost()."/".$path; + } + + /** * Parse a query string into an array. * diff --git a/www/admin/hostnames.php b/www/admin/hostnames.php index 90792209d93f992f2ba85efbf7a469c07b3e4ecd..04c9a06e8d3d74f21634ecc3e0f98c45f024f718 100644 --- a/www/admin/hostnames.php +++ b/www/admin/hostnames.php @@ -20,7 +20,7 @@ $attributes['Utilities_getBaseURL()'] = array(\SimpleSAML\Utils\HTTP::getBaseURL $attributes['Utilities_getSelfHost()'] = array(\SimpleSAML\Utils\HTTP::getSelfHost()); $attributes['Utilities_selfURLhost()'] = array(SimpleSAML_Utilities::selfURLhost()); $attributes['Utilities_selfURLNoQuery()'] = array(SimpleSAML_Utilities::selfURLNoQuery()); -$attributes['Utilities_getSelfHostWithPath()'] = array(SimpleSAML_Utilities::getSelfHostWithPath()); +$attributes['Utilities_getSelfHostWithPath()'] = array(\SimpleSAML\Utils\HTTP::getSelfHostWithPath()); $attributes['Utilities_getFirstPathElement()'] = array(SimpleSAML_Utilities::getFirstPathElement()); $attributes['Utilities_selfURL()'] = array(SimpleSAML_Utilities::selfURL());