getSelfHostWithPath() public static method

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.
Author: Andreas Solberg, UNINETT AS (andreas.solberg@uninett.no)
Author: Olav Morken, UNINETT AS (olav.morken@uninett.no)
public static getSelfHostWithPath ( ) : string
return string The current host (with non-default ports included) plus the URL path.
Exemplo n.º 1
0
 /**
  * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::getSelfHostWithPath() instead.
  */
 public static function getSelfHostWithPath()
 {
     return \SimpleSAML\Utils\HTTP::getSelfHostWithPath();
 }
 /**
  * This function locates the current entity id based on the hostname/path combination the user accessed.
  * It will throw an exception if it is unable to locate the entity id.
  *
  * @param string $set The set we look for the entity id in.
  * @param string $type Do you want to return the metaindex or the entityID. [entityid|metaindex]
  *
  * @return string The entity id which is associated with the current hostname/path combination.
  * @throws Exception If no default metadata can be found in the set for the current host.
  */
 public function getMetaDataCurrentEntityID($set, $type = 'entityid')
 {
     assert('is_string($set)');
     // first we look for the hostname/path combination
     $currenthostwithpath = \SimpleSAML\Utils\HTTP::getSelfHostWithPath();
     // sp.example.org/university
     foreach ($this->sources as $source) {
         $index = $source->getEntityIdFromHostPath($currenthostwithpath, $set, $type);
         if ($index !== null) {
             return $index;
         }
     }
     // 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);
         if ($index !== null) {
             return $index;
         }
     }
     // then we look for the DEFAULT entry
     foreach ($this->sources as $source) {
         $entityId = $source->getEntityIdFromHostPath('__DEFAULT__', $set, $type);
         if ($entityId !== null) {
             return $entityId;
         }
     }
     // we were unable to find the hostname/path in any metadata source
     throw new Exception('Could not find any default metadata entities in set [' . $set . '] for host [' . $currenthost . ' : ' . $currenthostwithpath . ']');
 }
Exemplo n.º 3
0
<?php

require_once '../_include.php';
/* Load simpleSAMLphp, configuration */
$config = SimpleSAML_Configuration::getInstance();
$session = SimpleSAML_Session::getSessionFromRequest();
/* Check if valid local session exists.. */
SimpleSAML\Utils\Auth::requireAdmin();
$attributes = array();
$attributes['HTTP_HOST'] = array($_SERVER['HTTP_HOST']);
$attributes['HTTPS'] = isset($_SERVER['HTTPS']) ? array($_SERVER['HTTPS']) : array();
$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\Utils\HTTP::getSelfHost());
$attributes['Utilities_selfURLhost()'] = array(\SimpleSAML\Utils\HTTP::getSelfURLHost());
$attributes['Utilities_selfURLNoQuery()'] = array(\SimpleSAML\Utils\HTTP::getSelfURLNoQuery());
$attributes['Utilities_getSelfHostWithPath()'] = array(\SimpleSAML\Utils\HTTP::getSelfHostWithPath());
$attributes['Utilities_getFirstPathElement()'] = array(\SimpleSAML\Utils\HTTP::getFirstPathElement());
$attributes['Utilities_selfURL()'] = array(\SimpleSAML\Utils\HTTP::getSelfURL());
$template = new SimpleSAML_XHTML_Template($config, 'hostnames.php');
$template->data['remaining'] = $session->getAuthData('admin', 'Expire') - time();
$template->data['attributes'] = $attributes;
$template->data['valid'] = 'na';
$template->data['logout'] = null;
$template->show();