Skip to content
Snippets Groups Projects
Commit 277523f8 authored by Jaime Perez Crespo's avatar Jaime Perez Crespo
Browse files

Move SimpleSAML_Utilities::getSelfHost() to...

Move SimpleSAML_Utilities::getSelfHost() to SimpleSAML\Utils\HTTP::getSelfHost() and deprecate the former.
parent 7d723a1d
Branches
Tags
No related merge requests found
...@@ -198,7 +198,7 @@ class SimpleSAML_Metadata_MetaDataStorageHandler { ...@@ -198,7 +198,7 @@ class SimpleSAML_Metadata_MetaDataStorageHandler {
/* Then we look for the hostname. */ /* 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) { if(strpos($currenthost, ":") !== FALSE) {
$currenthostdecomposed = explode(":", $currenthost); $currenthostdecomposed = explode(":", $currenthost);
$currenthost = $currenthostdecomposed[0]; $currenthost = $currenthostdecomposed[0];
......
...@@ -123,9 +123,9 @@ class SimpleSAML_Metadata_MetaDataStorageHandlerFlatFile extends SimpleSAML_Meta ...@@ -123,9 +123,9 @@ class SimpleSAML_Metadata_MetaDataStorageHandlerFlatFile extends SimpleSAML_Meta
} elseif($set === 'shib13-idp-hosted') { } elseif($set === 'shib13-idp-hosted') {
return $baseurl . 'shib13/idp/metadata.php'; return $baseurl . 'shib13/idp/metadata.php';
} elseif($set === 'wsfed-sp-hosted') { } elseif($set === 'wsfed-sp-hosted') {
return 'urn:federation:' . SimpleSAML_Utilities::getSelfHost(); return 'urn:federation:' . \SimpleSAML\Utils\HTTP::getSelfHost();
} elseif($set === 'adfs-idp-hosted') { } elseif($set === 'adfs-idp-hosted') {
return 'urn:federation:' . SimpleSAML_Utilities::getSelfHost() . ':idp'; return 'urn:federation:' . \SimpleSAML\Utils\HTTP::getSelfHost() . ':idp';
} else { } else {
throw new Exception('Can not generate dynamic EntityID for metadata of this type: [' . $set . ']'); throw new Exception('Can not generate dynamic EntityID for metadata of this type: [' . $set . ']');
} }
......
...@@ -178,7 +178,7 @@ abstract class SimpleSAML_Metadata_MetaDataStorageSource { ...@@ -178,7 +178,7 @@ abstract class SimpleSAML_Metadata_MetaDataStorageSource {
$metadataSet = $this->getMetadataSet($set); $metadataSet = $this->getMetadataSet($set);
/* Check for hostname. */ /* Check for hostname. */
$currenthost = SimpleSAML_Utilities::getSelfHost(); // sp.example.org $currenthost = \SimpleSAML\Utils\HTTP::getSelfHost(); // sp.example.org
if(strpos($currenthost, ":") !== FALSE) { if(strpos($currenthost, ":") !== FALSE) {
$currenthostdecomposed = explode(":", $currenthost); $currenthostdecomposed = explode(":", $currenthost);
$currenthost = $currenthostdecomposed[0]; $currenthost = $currenthostdecomposed[0];
......
...@@ -29,19 +29,12 @@ class SimpleSAML_Utilities { ...@@ -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() { public static function getSelfHost() {
return \SimpleSAML\Utils\HTTP::getSelfHost();
$url = self::getBaseURL();
$start = strpos($url,'://') + 3;
$length = strcspn($url,'/:',$start);
return substr($url, $start, $length);
} }
/** /**
* Retrieve Host value from $_SERVER environment variables * Retrieve Host value from $_SERVER environment variables
*/ */
......
...@@ -316,6 +316,25 @@ class HTTP ...@@ -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. * Parse a query string into an array.
* *
......
...@@ -17,7 +17,7 @@ $attributes['SERVER_PROTOCOL'] = array($_SERVER['SERVER_PROTOCOL']); ...@@ -17,7 +17,7 @@ $attributes['SERVER_PROTOCOL'] = array($_SERVER['SERVER_PROTOCOL']);
$attributes['SERVER_PORT'] = array($_SERVER['SERVER_PORT']); $attributes['SERVER_PORT'] = array($_SERVER['SERVER_PORT']);
$attributes['Utilities_getBaseURL()'] = array(\SimpleSAML\Utils\HTTP::getBaseURL()); $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_selfURLhost()'] = array(SimpleSAML_Utilities::selfURLhost());
$attributes['Utilities_selfURLNoQuery()'] = array(SimpleSAML_Utilities::selfURLNoQuery()); $attributes['Utilities_selfURLNoQuery()'] = array(SimpleSAML_Utilities::selfURLNoQuery());
$attributes['Utilities_getSelfHostWithPath()'] = array(SimpleSAML_Utilities::getSelfHostWithPath()); $attributes['Utilities_getSelfHostWithPath()'] = array(SimpleSAML_Utilities::getSelfHostWithPath());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment