当前位置: 首页>>代码示例>>PHP>>正文


PHP HTTP::getSelfURLHost方法代码示例

本文整理汇总了PHP中SimpleSAML\Utils\HTTP::getSelfURLHost方法的典型用法代码示例。如果您正苦于以下问题:PHP HTTP::getSelfURLHost方法的具体用法?PHP HTTP::getSelfURLHost怎么用?PHP HTTP::getSelfURLHost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SimpleSAML\Utils\HTTP的用法示例。


在下文中一共展示了HTTP::getSelfURLHost方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getGenerated

 /**
  * This function is used to generate some metadata elements automatically.
  *
  * @param $property  The metadata property which should be autogenerated.
  * @param $set  The set we the property comes from.
  * @return The autogenerated metadata property.
  */
 public function getGenerated($property, $set)
 {
     /* First we check if the user has overridden this property in the metadata. */
     try {
         $metadataSet = $this->getMetaDataCurrent($set);
         if (array_key_exists($property, $metadataSet)) {
             return $metadataSet[$property];
         }
     } catch (Exception $e) {
         /* Probably metadata wasn't found. In any case we continue by generating the metadata. */
     }
     /* Get the configuration. */
     $config = SimpleSAML_Configuration::getInstance();
     assert($config instanceof SimpleSAML_Configuration);
     $baseurl = \SimpleSAML\Utils\HTTP::getSelfURLHost() . '/' . $config->getBaseURL();
     if ($set == 'saml20-sp-hosted') {
         switch ($property) {
             case 'SingleLogoutServiceBinding':
                 return SAML2_Const::BINDING_HTTP_REDIRECT;
         }
     } elseif ($set == 'saml20-idp-hosted') {
         switch ($property) {
             case 'SingleSignOnService':
                 return $baseurl . 'saml2/idp/SSOService.php';
             case 'SingleSignOnServiceBinding':
                 return SAML2_Const::BINDING_HTTP_REDIRECT;
             case 'SingleLogoutService':
                 return $baseurl . 'saml2/idp/SingleLogoutService.php';
             case 'SingleLogoutServiceBinding':
                 return SAML2_Const::BINDING_HTTP_REDIRECT;
         }
     } elseif ($set == 'shib13-idp-hosted') {
         switch ($property) {
             case 'SingleSignOnService':
                 return $baseurl . 'shib13/idp/SSOService.php';
         }
     }
     throw new Exception('Could not generate metadata property ' . $property . ' for set ' . $set . '.');
 }
开发者ID:jstormes,项目名称:simplesamlphp,代码行数:46,代码来源:MetaDataStorageHandler.php

示例2: testGetSelfURLMethods

 /**
  * Test SimpleSAML\Utils\HTTP::getSelfURL().
  */
 public function testGetSelfURLMethods()
 {
     $original = $_SERVER;
     /*
      * Test a URL pointing to a script that's not part of the public interface. This allows us to test calls to
      * getSelfURL() from scripts outside of SimpleSAMLphp
      */
     \SimpleSAML_Configuration::loadFromArray(array('baseurlpath' => 'http://example.com/simplesaml/'), '[ARRAY]', 'simplesaml');
     $url = 'https://example.com/app/script.php/some/path?foo=bar';
     $this->setupEnvFromURL($url);
     $_SERVER['SCRIPT_FILENAME'] = '/var/www/app/script.php';
     $this->assertEquals($url, HTTP::getSelfURL());
     $this->assertEquals('https://example.com', HTTP::getSelfURLHost());
     $this->assertEquals('https://example.com/app/script.php/some/path', HTTP::getSelfURLNoQuery());
     $this->assertTrue(HTTP::isHTTPS());
     $this->assertEquals('https://' . HTTP::getSelfHostWithNonStandardPort(), HTTP::getSelfURLHost());
     // test a request URI that doesn't match the current script
     $cfg = \SimpleSAML_Configuration::loadFromArray(array('baseurlpath' => 'https://example.org/simplesaml/'), '[ARRAY]', 'simplesaml');
     $baseDir = $cfg->getBaseDir();
     $_SERVER['SCRIPT_FILENAME'] = $baseDir . 'www/module.php';
     $this->setupEnvFromURL('http://www.example.com/protected/resource.asp?foo=bar');
     $this->assertEquals('http://www.example.com/protected/resource.asp?foo=bar', HTTP::getSelfURL());
     $this->assertEquals('http://www.example.com', HTTP::getSelfURLHost());
     $this->assertEquals('http://www.example.com/protected/resource.asp', HTTP::getSelfURLNoQuery());
     $this->assertFalse(HTTP::isHTTPS());
     $this->assertEquals('example.org', HTTP::getSelfHostWithNonStandardPort());
     $this->assertEquals('http://www.example.com', HTTP::getSelfURLHost());
     // test a valid, full URL, based on a full URL in the configuration
     \SimpleSAML_Configuration::loadFromArray(array('baseurlpath' => 'https://example.com/simplesaml/'), '[ARRAY]', 'simplesaml');
     $this->setupEnvFromURL('http://www.example.org/module.php/module/file.php?foo=bar');
     $this->assertEquals('https://example.com/simplesaml/module.php/module/file.php?foo=bar', HTTP::getSelfURL());
     $this->assertEquals('https://example.com', HTTP::getSelfURLHost());
     $this->assertEquals('https://example.com/simplesaml/module.php/module/file.php', HTTP::getSelfURLNoQuery());
     $this->assertTrue(HTTP::isHTTPS());
     $this->assertEquals('https://' . HTTP::getSelfHostWithNonStandardPort(), HTTP::getSelfURLHost());
     // test a valid, full URL, based on a full URL *without* a trailing slash in the configuration
     \SimpleSAML_Configuration::loadFromArray(array('baseurlpath' => 'https://example.com/simplesaml'), '[ARRAY]', 'simplesaml');
     $this->assertEquals('https://example.com/simplesaml/module.php/module/file.php?foo=bar', HTTP::getSelfURL());
     $this->assertEquals('https://example.com', HTTP::getSelfURLHost());
     $this->assertEquals('https://example.com/simplesaml/module.php/module/file.php', HTTP::getSelfURLNoQuery());
     $this->assertTrue(HTTP::isHTTPS());
     $this->assertEquals('https://' . HTTP::getSelfHostWithNonStandardPort(), HTTP::getSelfURLHost());
     // test a valid, full URL, based on a full URL *without* a path in the configuration
     \SimpleSAML_Configuration::loadFromArray(array('baseurlpath' => 'https://example.com'), '[ARRAY]', 'simplesaml');
     $this->assertEquals('https://example.com/module.php/module/file.php?foo=bar', HTTP::getSelfURL());
     $this->assertEquals('https://example.com', HTTP::getSelfURLHost());
     $this->assertEquals('https://example.com/module.php/module/file.php', HTTP::getSelfURLNoQuery());
     $this->assertTrue(HTTP::isHTTPS());
     $this->assertEquals('https://' . HTTP::getSelfHostWithNonStandardPort(), HTTP::getSelfURLHost());
     // test a valid, full URL, based on a relative path in the configuration
     \SimpleSAML_Configuration::loadFromArray(array('baseurlpath' => '/simplesaml/'), '[ARRAY]', 'simplesaml');
     $this->setupEnvFromURL('http://www.example.org/simplesaml/module.php/module/file.php?foo=bar');
     $this->assertEquals('http://www.example.org/simplesaml/module.php/module/file.php?foo=bar', HTTP::getSelfURL());
     $this->assertEquals('http://www.example.org', HTTP::getSelfURLHost());
     $this->assertEquals('http://www.example.org/simplesaml/module.php/module/file.php', HTTP::getSelfURLNoQuery());
     $this->assertFalse(HTTP::isHTTPS());
     $this->assertEquals('http://' . HTTP::getSelfHostWithNonStandardPort(), HTTP::getSelfURLHost());
     // test a valid, full URL, based on a relative path in the configuration and a non standard port
     \SimpleSAML_Configuration::loadFromArray(array('baseurlpath' => '/simplesaml/'), '[ARRAY]', 'simplesaml');
     $this->setupEnvFromURL('http://example.org:8080/simplesaml/module.php/module/file.php?foo=bar');
     $this->assertEquals('http://example.org:8080/simplesaml/module.php/module/file.php?foo=bar', HTTP::getSelfURL());
     $this->assertEquals('http://example.org:8080', HTTP::getSelfURLHost());
     $this->assertEquals('http://example.org:8080/simplesaml/module.php/module/file.php', HTTP::getSelfURLNoQuery());
     $this->assertFalse(HTTP::isHTTPS());
     $this->assertEquals('http://' . HTTP::getSelfHostWithNonStandardPort(), HTTP::getSelfURLHost());
     // test a valid, full URL, based on a relative path in the configuration, a non standard port and HTTPS
     \SimpleSAML_Configuration::loadFromArray(array('baseurlpath' => '/simplesaml/'), '[ARRAY]', 'simplesaml');
     $this->setupEnvFromURL('https://example.org:8080/simplesaml/module.php/module/file.php?foo=bar');
     $this->assertEquals('https://example.org:8080/simplesaml/module.php/module/file.php?foo=bar', HTTP::getSelfURL());
     $this->assertEquals('https://example.org:8080', HTTP::getSelfURLHost());
     $this->assertEquals('https://example.org:8080/simplesaml/module.php/module/file.php', HTTP::getSelfURLNoQuery());
     $this->assertTrue(HTTP::isHTTPS());
     $this->assertEquals('https://' . HTTP::getSelfHostWithNonStandardPort(), HTTP::getSelfURLHost());
     $_SERVER = $original;
 }
开发者ID:simplesamlphp,项目名称:simplesamlphp,代码行数:78,代码来源:HTTPTest.php

示例3: selfURLhost

 /**
  * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::getSelfURLHost() instead.
  */
 public static function selfURLhost()
 {
     return \SimpleSAML\Utils\HTTP::getSelfURLHost();
 }
开发者ID:jstormes,项目名称:simplesamlphp,代码行数:7,代码来源:Utilities.php

示例4: array

<?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();
开发者ID:tractorcow,项目名称:simplesamlphp,代码行数:26,代码来源:hostnames.php

示例5: getTrustRoot

 /**
  * Retrieve the trust root for this openid site.
  *
  * @return string  The trust root.
  */
 private function getTrustRoot()
 {
     if (!empty($this->realm)) {
         return $this->realm;
     } else {
         return \SimpleSAML\Utils\HTTP::getSelfURLHost();
     }
 }
开发者ID:simplesamlphp,项目名称:simplesamlphp-module-openid,代码行数:13,代码来源:OpenIDConsumer.php


注:本文中的SimpleSAML\Utils\HTTP::getSelfURLHost方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。