diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/SimpleSAML/Metadata/MetaDataStorageHandler.php | 4 | ||||
-rw-r--r-- | lib/SimpleSAML/Metadata/MetaDataStorageSource.php | 4 | ||||
-rw-r--r-- | lib/SimpleSAML/Utils/HTTP.php | 27 |
3 files changed, 22 insertions, 13 deletions
diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php b/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php index 3903e72..5c1c6e8 100644 --- a/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php +++ b/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php @@ -208,10 +208,6 @@ class SimpleSAML_Metadata_MetaDataStorageHandler // then we look for the hostname $currenthost = \SimpleSAML\Utils\HTTP::getSelfHost(); // sp.example.org - if (strpos($currenthost, ":") !== false) { - $currenthostdecomposed = explode(":", $currenthost); - $currenthost = $currenthostdecomposed[0]; - } foreach ($this->sources as $source) { $index = $source->getEntityIdFromHostPath($currenthost, $set, $type); diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageSource.php b/lib/SimpleSAML/Metadata/MetaDataStorageSource.php index bc7e896..9d677cd 100644 --- a/lib/SimpleSAML/Metadata/MetaDataStorageSource.php +++ b/lib/SimpleSAML/Metadata/MetaDataStorageSource.php @@ -199,10 +199,6 @@ abstract class SimpleSAML_Metadata_MetaDataStorageSource // check for hostname $currenthost = \SimpleSAML\Utils\HTTP::getSelfHost(); // sp.example.org - if (strpos($currenthost, ":") !== false) { - $currenthostdecomposed = explode(":", $currenthost); - $currenthost = $currenthostdecomposed[0]; - } foreach ($metadataSet as $index => $entry) { if ($index === $entityId) { diff --git a/lib/SimpleSAML/Utils/HTTP.php b/lib/SimpleSAML/Utils/HTTP.php index 5f791de..00946fc 100644 --- a/lib/SimpleSAML/Utils/HTTP.php +++ b/lib/SimpleSAML/Utils/HTTP.php @@ -336,7 +336,7 @@ class HTTP /** - * Helper function to retrieve a file or URL with proxy support, also + * Helper function to retrieve a file or URL with proxy support, also * supporting proxy basic authorization.. * * An exception will be thrown if we are unable to retrieve the data. @@ -595,22 +595,39 @@ class HTTP /** * Retrieve our own host. * - * @return string The current host (with non-default ports included). + * E.g. www.example.com + * + * @return string The current host. + * + * @author Jaime Perez, UNINETT AS <jaime.perez@uninett.no> + */ + public static function getSelfHost() + { + return array_shift(explode(':', self::getSelfHostWithNonStandardPort())); + } + + /** + * Retrieve our own host, including the port in case the it is not standard for the protocol in use. That is port + * 80 for HTTP and port 443 for HTTPS. + * + * E.g. www.example.com:8080 + * + * @return string The current host, followed by a colon and the port number, in case the port is not standard for + * the protocol. * * @author Andreas Solberg, UNINETT AS <andreas.solberg@uninett.no> * @author Olav Morken, UNINETT AS <olav.morken@uninett.no> */ - public static function getSelfHost() + public static function getSelfHostWithNonStandardPort() { $url = self::getBaseURL(); $start = strpos($url, '://') + 3; - $length = strcspn($url, '/:', $start); + $length = strcspn($url, '/', $start); return substr($url, $start, $length); } - /** * 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. |