diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php b/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php index 70aba6d1d0c13b6caf062f850a9948ec4b4d9848..7ec37a88e07cbf5db6cc0bc1762cceb143ba22ac 100644 --- a/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php +++ b/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php @@ -198,7 +198,7 @@ class SimpleSAML_Metadata_MetaDataStorageHandler { /* Then we look for the hostname. */ - $currenthost = SimpleSAML_Utilities::getSelfHost(); // sp.example.org + $currenthost = \SimpleSAML\Utils\HTTP::getSelfHost(); // sp.example.org if(strpos($currenthost, ":") !== FALSE) { $currenthostdecomposed = explode(":", $currenthost); $currenthost = $currenthostdecomposed[0]; diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerFlatFile.php b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerFlatFile.php index b028bb4f877bb92f5c1e9a7bdd5b0bed7237af1a..656426b17b124e4a6e3b96a1e6ca3966e926ec7b 100644 --- a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerFlatFile.php +++ b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerFlatFile.php @@ -123,9 +123,9 @@ class SimpleSAML_Metadata_MetaDataStorageHandlerFlatFile extends SimpleSAML_Meta } elseif($set === 'shib13-idp-hosted') { return $baseurl . 'shib13/idp/metadata.php'; } elseif($set === 'wsfed-sp-hosted') { - return 'urn:federation:' . SimpleSAML_Utilities::getSelfHost(); + return 'urn:federation:' . \SimpleSAML\Utils\HTTP::getSelfHost(); } elseif($set === 'adfs-idp-hosted') { - return 'urn:federation:' . SimpleSAML_Utilities::getSelfHost() . ':idp'; + return 'urn:federation:' . \SimpleSAML\Utils\HTTP::getSelfHost() . ':idp'; } else { throw new Exception('Can not generate dynamic EntityID for metadata of this type: [' . $set . ']'); } diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageSource.php b/lib/SimpleSAML/Metadata/MetaDataStorageSource.php index 0ce41216502c6e20799cab08de19e5d56b202084..1fc1160b37a920d5f8f6646484ec36ca93872cb1 100644 --- a/lib/SimpleSAML/Metadata/MetaDataStorageSource.php +++ b/lib/SimpleSAML/Metadata/MetaDataStorageSource.php @@ -178,7 +178,7 @@ abstract class SimpleSAML_Metadata_MetaDataStorageSource { $metadataSet = $this->getMetadataSet($set); /* Check for hostname. */ - $currenthost = SimpleSAML_Utilities::getSelfHost(); // sp.example.org + $currenthost = \SimpleSAML\Utils\HTTP::getSelfHost(); // sp.example.org if(strpos($currenthost, ":") !== FALSE) { $currenthostdecomposed = explode(":", $currenthost); $currenthost = $currenthostdecomposed[0]; diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php index 38e6bc71c5988ae4fe9c95dbdf6d9a37dda42ae5..303956dd32561fafadb2aa8efc13041a8c300eb6 100644 --- a/lib/SimpleSAML/Utilities.php +++ b/lib/SimpleSAML/Utilities.php @@ -29,19 +29,12 @@ class SimpleSAML_Utilities { /** - * Will return sp.example.org + * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::getSelfHost() instead. */ public static function getSelfHost() { - - $url = self::getBaseURL(); - - $start = strpos($url,'://') + 3; - $length = strcspn($url,'/:',$start); - - return substr($url, $start, $length); - + return \SimpleSAML\Utils\HTTP::getSelfHost(); } - + /** * Retrieve Host value from $_SERVER environment variables */ diff --git a/lib/SimpleSAML/Utils/HTTP.php b/lib/SimpleSAML/Utils/HTTP.php index e754b17bb105b7d3768b44ce02921c93890d6b59..38840c5a22b6a7d701609af0a11b7fbfe02753fb 100644 --- a/lib/SimpleSAML/Utils/HTTP.php +++ b/lib/SimpleSAML/Utils/HTTP.php @@ -316,6 +316,25 @@ class HTTP } + /** + * Retrieve our own host. + * + * @return string The current host. + * + * @author Andreas Solberg, UNINETT AS <andreas.solberg@uninett.no> + * @author Olav Morken, UNINETT AS <olav.morken@uninett.no> + */ + public static function getSelfHost() + { + $url = self::getBaseURL(); + + $start = strpos($url, '://') + 3; + $length = strcspn($url, '/:', $start); + + return substr($url, $start, $length); + } + + /** * Parse a query string into an array. * diff --git a/www/admin/hostnames.php b/www/admin/hostnames.php index 0a520a93ae97d7c0f084ffe783aaa57201443d83..90792209d93f992f2ba85efbf7a469c07b3e4ecd 100644 --- a/www/admin/hostnames.php +++ b/www/admin/hostnames.php @@ -17,7 +17,7 @@ $attributes['SERVER_PROTOCOL'] = array($_SERVER['SERVER_PROTOCOL']); $attributes['SERVER_PORT'] = array($_SERVER['SERVER_PORT']); $attributes['Utilities_getBaseURL()'] = array(\SimpleSAML\Utils\HTTP::getBaseURL()); -$attributes['Utilities_getSelfHost()'] = array(SimpleSAML_Utilities::getSelfHost()); +$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());