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


PHP SimpleSAML_Configuration::getInstance方法代码示例

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


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

示例1: _mailTechnicalContact

    protected function _mailTechnicalContact($tag, sspmod_janus_Cron_Logger $logger)
    {
        $errorHtml = $this->_getHtmlForMessages($logger->getNamespacedErrors(), 'errors');
        $warningHtml = $this->_getHtmlForMessages($logger->getNamespacedWarnings(), 'warnings');
        $noticeHtml = $this->_getHtmlForMessages($logger->getNamespacedNotices(), 'notices');
        $config = SimpleSAML_Configuration::getInstance();
        $time = date(DATE_RFC822);
        $url = SimpleSAML_Utilities::selfURL();
        $message = <<<MESSAGE
<h1>Cron report</h1>
<p>Cron ran at {$time}</p>
<p>URL: <tt>{$url}</tt></p>
<p>Tag: {$tag}</p>
<h2>Errors</h2>
{$errorHtml}
<h2>Warnings</h2>
{$warningHtml}
<h2>Notices</h2>
{$noticeHtml}
MESSAGE;
        $toAddress = $config->getString('technicalcontact_email', 'na@example.org');
        if ($toAddress == 'na@example.org') {
            SimpleSAML_Logger::error('Cron - Could not send email. [technicalcontact_email] not set in config.');
        } else {
            $email = new SimpleSAML_XHTML_EMail($toAddress, 'JANUS cron report', 'no-reply@example.edu');
            $email->setBody($message);
            $email->send();
        }
    }
开发者ID:baszoetekouw,项目名称:janus,代码行数:29,代码来源:Abstract.php

示例2: _mailUpdatedMetaData

    /**
     * Notifies managing contact about updated metadata of entity
     *
     * @param   sspmod_janus_Entity $entity
     * @param   string $metadataXml
     * @return void
     */
    protected function _mailUpdatedMetaData(sspmod_janus_Entity $entity, $metadataXml)
    {
        $config = SimpleSAML_Configuration::getInstance();
        $time = date(DATE_RFC822);
        $entityName = $entity->getPrettyname();
        $entityId = $entity->getEntityId();
        $message = <<<MESSAGE
<h1>Metadata Change detected</h1>
<p>Cron ran at {$time}</p>
<p>Name: {$entityName}</p>
<p>EntityId: {$entityId}</p>
MESSAGE;
        $toAddress = $config->getString('managingcontact_email');
        if (empty($toAddress)) {
            SimpleSAML_Logger::error('Cron - Could not send email. [managingcontact_email] not set in config.');
        }
        $fromAddress = 'no-reply@surfnet.nl';
        $subject = "Metadata Change detected for entity " . $entity->getPrettyname() . " (" . $entity->getEntityId() . "])";
        $email = new SimpleSAML_XHTML_EMail($toAddress, $subject, $fromAddress);
        $email->setBody($message);
        // Add gzipped metadata
        $attachmentContent = gzencode($metadataXml);
        $attachmentFileName = 'metadata-' . $entityName . '.xml.gz';
        $email->addAttachment($attachmentContent, $attachmentFileName, 'application/zip');
        $email->send();
    }
开发者ID:newlongwhitecloudy,项目名称:OpenConext-serviceregistry,代码行数:33,代码来源:Abstract.php

示例3: __construct

 /**
  * This function initializes the dynamic XML metadata source.
  *
  * Options:
  * - 'server': URL of the MDX server (url:port). Mandatory.
  * - 'validateFingerprint': The fingerprint of the certificate used to sign the metadata.
  *                          You don't need this option if you don't want to validate the signature on the metadata.
  * Optional.
  * - 'cachedir':  Directory where metadata can be cached. Optional.
  * - 'cachelength': Maximum time metadata cah be cached, in seconds. Default to 24
  *                  hours (86400 seconds).
  *
  * @param array $config The configuration for this instance of the XML metadata source.
  *
  * @throws Exception If no server option can be found in the configuration.
  */
 protected function __construct($config)
 {
     assert('is_array($config)');
     if (!array_key_exists('server', $config)) {
         throw new Exception("The 'server' configuration option is not set.");
     } else {
         $this->server = $config['server'];
     }
     if (array_key_exists('validateFingerprint', $config)) {
         $this->validateFingerprint = $config['validateFingerprint'];
     } else {
         $this->validateFingerprint = null;
     }
     if (array_key_exists('cachedir', $config)) {
         $globalConfig = SimpleSAML_Configuration::getInstance();
         $this->cacheDir = $globalConfig->resolvePath($config['cachedir']);
     } else {
         $this->cacheDir = null;
     }
     if (array_key_exists('cachelength', $config)) {
         $this->cacheLength = $config['cachelength'];
     } else {
         $this->cacheLength = 86400;
     }
 }
开发者ID:PitcherAG,项目名称:simplesamlphp,代码行数:41,代码来源:MetaDataStorageHandlerMDX.php

示例4: getInstance

 /**
  * Retrieve our singleton instance.
  *
  * @return SimpleSAML_Store|false  The data store, or false if it isn't enabled.
  */
 public static function getInstance()
 {
     if (self::$instance !== null) {
         return self::$instance;
     }
     $config = SimpleSAML_Configuration::getInstance();
     $storeType = $config->getString('store.type', null);
     if ($storeType === null) {
         $storeType = $config->getString('session.handler', 'phpsession');
     }
     switch ($storeType) {
         case 'phpsession':
             // we cannot support advanced features with the PHP session store
             self::$instance = false;
             break;
         case 'memcache':
             self::$instance = new SimpleSAML_Store_Memcache();
             break;
         case 'sql':
             self::$instance = new SimpleSAML_Store_SQL();
             break;
         default:
             // datastore from module
             $className = SimpleSAML_Module::resolveClass($storeType, 'Store', 'SimpleSAML_Store');
             self::$instance = new $className();
     }
     return self::$instance;
 }
开发者ID:PitcherAG,项目名称:simplesamlphp,代码行数:33,代码来源:Store.php

示例5: __construct

 /**
  * This constructor initializes the session id based on what we receive in a cookie. We create a new session id and
  * set a cookie with this id if we don't have a session id.
  */
 protected function __construct()
 {
     // call the constructor in the base class in case it should become necessary in the future
     parent::__construct();
     $config = SimpleSAML_Configuration::getInstance();
     $this->cookie_name = $config->getString('session.cookie.name', 'SimpleSAMLSessionID');
 }
开发者ID:simplesamlphp,项目名称:simplesamlphp,代码行数:11,代码来源:SessionHandlerCookie.php

示例6: __construct

 /**
  * Constructor for the metadata signer.
  *
  * You can pass an list of options as key-value pairs in the array. This allows you to initialize
  * a metadata signer in one call.
  *
  * The following keys are recognized:
  *  - privatekey       The file with the private key, relative to the cert-directory.
  *  - privatekey_pass  The passphrase for the private key.
  *  - certificate      The file with the certificate, relative to the cert-directory.
  *  - privatekey_array The private key, as an array returned from SimpleSAML_Utilities::loadPrivateKey.
  *  - publickey_array  The public key, as an array returned from SimpleSAML_Utilities::loadPublicKey.
  *  - id               The name of the ID attribute.
  *
  * @param $options  Associative array with options for the constructor. Defaults to an empty array.
  */
 public function __construct($options = array())
 {
     assert('is_array($options)');
     if (self::$certDir === FALSE) {
         $config = SimpleSAML_Configuration::getInstance();
         self::$certDir = $config->getPathValue('certdir', 'cert/');
     }
     $this->idAttrName = FALSE;
     $this->privateKey = FALSE;
     $this->certificate = FALSE;
     $this->extraCertificates = array();
     if (array_key_exists('privatekey', $options)) {
         $pass = NULL;
         if (array_key_exists('privatekey_pass', $options)) {
             $pass = $options['privatekey_pass'];
         }
         $this->loadPrivateKey($options['privatekey'], $pass);
     }
     if (array_key_exists('certificate', $options)) {
         $this->loadCertificate($options['certificate']);
     }
     if (array_key_exists('privatekey_array', $options)) {
         $this->loadPrivateKeyArray($options['privatekey_array']);
     }
     if (array_key_exists('publickey_array', $options)) {
         $this->loadPublicKeyArray($options['publickey_array']);
     }
     if (array_key_exists('id', $options)) {
         $this->setIdAttribute($options['id']);
     }
 }
开发者ID:hukumonline,项目名称:yii,代码行数:47,代码来源:Signer.php

示例7: loadMapFile

 /**
  * Loads and merges in a file with a attribute map.
  *
  * @param string $fileName Name of attribute map file. Expected to be in the attributemap directory in the root
  * of the SimpleSAMLphp installation, or in the root of a module.
  *
  * @throws Exception If the filter could not load the requested attribute map file.
  */
 private function loadMapFile($fileName)
 {
     $config = SimpleSAML_Configuration::getInstance();
     $m = explode(':', $fileName);
     if (count($m) === 2) {
         // we are asked for a file in a module
         if (!SimpleSAML\Module::isModuleEnabled($m[0])) {
             throw new Exception("Module '{$m['0']}' is not enabled.");
         }
         $filePath = SimpleSAML\Module::getModuleDir($m[0]) . '/attributemap/' . $m[1] . '.php';
     } else {
         $filePath = $config->getPathValue('attributenamemapdir', 'attributemap/') . $fileName . '.php';
     }
     if (!file_exists($filePath)) {
         throw new Exception('Could not find attribute map file: ' . $filePath);
     }
     $attributemap = null;
     include $filePath;
     if (!is_array($attributemap)) {
         throw new Exception('Attribute map file "' . $filePath . '" didn\'t define an attribute map.');
     }
     if ($this->duplicate) {
         $this->map = array_merge_recursive($this->map, $attributemap);
     } else {
         $this->map = array_merge($this->map, $attributemap);
     }
 }
开发者ID:simplesamlphp,项目名称:simplesamlphp,代码行数:35,代码来源:AttributeMap.php

示例8: getMenu

 function getMenu($thispage)
 {
     $config = SimpleSAML_Configuration::getInstance();
     $t = new SimpleSAML_XHTML_Template($config, 'sanitycheck:check.tpl.php');
     $tabset = $this->getTabset($thispage);
     $logininfo = $this->getLoginInfo($t, $thispage);
     $text = '';
     $text .= '<ul class="tabset_tabs ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">';
     foreach ($this->pages as $pageid => $page) {
         if (isset($tabset) && !in_array($pageid, $tabset, TRUE)) {
             continue;
         }
         $name = 'uknown';
         if (isset($page['text'])) {
             $name = $page['text'];
         }
         if (isset($page['shorttext'])) {
             $name = $page['shorttext'];
         }
         if (!isset($page['href'])) {
             $text .= '<li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active"><a href="#">' . $t->t($name) . '</a></li>';
         } else {
             if ($pageid === $thispage) {
                 $text .= '<li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active"><a href="#">' . $t->t($name) . '</a></li>';
             } else {
                 $text .= '<li class="ui-state-default ui-corner-top"><a href="' . $page['href'] . '">' . $t->t($name) . '</a></li>';
             }
         }
     }
     $text .= '</ul>';
     if (!empty($logininfo)) {
         $text .= '<p class="logininfo" style="text-align: right; margin: 0px">' . $logininfo . '</p>';
     }
     return $text;
 }
开发者ID:simplesamlphp,项目名称:simplesamlphp,代码行数:35,代码来源:Portal.php

示例9: loadAttributeMap

 private function loadAttributeMap($attributemap)
 {
     $config = SimpleSAML_Configuration::getInstance();
     include $config->getPathValue('attributemap', 'attributemap/') . $attributemap . '.php';
     $this->attributes = $attributemap;
     #	print_r($attributemap); exit;
 }
开发者ID:danielkjfrog,项目名称:docker,代码行数:7,代码来源:ARP.php

示例10: core_hook_sanitycheck

/**
 * Hook to do sanitycheck
 *
 * @param array &$hookinfo  hookinfo
 */
function core_hook_sanitycheck(&$hookinfo)
{
    assert('is_array($hookinfo)');
    assert('array_key_exists("errors", $hookinfo)');
    assert('array_key_exists("info", $hookinfo)');
    $config = SimpleSAML_Configuration::getInstance();
    if ($config->getString('auth.adminpassword', '123') === '123') {
        $hookinfo['errors'][] = '[core] Password in config.php is not set properly';
    } else {
        $hookinfo['info'][] = '[core] Password in config.php is set properly';
    }
    if ($config->getString('technicalcontact_email', 'na@example.org') === 'na@example.org') {
        $hookinfo['errors'][] = '[core] In config.php technicalcontact_email is not set properly';
    } else {
        $hookinfo['info'][] = '[core] In config.php technicalcontact_email is set properly';
    }
    if (version_compare(phpversion(), '5.3', '>=')) {
        $hookinfo['info'][] = '[core] You are running PHP version ' . phpversion() . '. Great.';
    } else {
        $hookinfo['errors'][] = '[core] You are running PHP version ' . phpversion() . '. SimpleSAMLphp requires version >= 5.3. Please upgrade!';
    }
    $info = array();
    $mihookinfo = array('info' => &$info);
    $availmodules = SimpleSAML_Module::getModules();
    SimpleSAML_Module::callHooks('moduleinfo', $mihookinfo);
    foreach ($info as $mi => $i) {
        if (isset($i['dependencies']) && is_array($i['dependencies'])) {
            foreach ($i['dependencies'] as $dep) {
                if (!in_array($dep, $availmodules)) {
                    $hookinfo['errors'][] = '[core] Module dependency not met: ' . $mi . ' requires ' . $dep;
                }
            }
        }
    }
}
开发者ID:palantirnet,项目名称:simplesamlphp,代码行数:40,代码来源:hook_sanitycheck.php

示例11: validate

 public function validate()
 {
     assert('$this->dom instanceof DOMDocument');
     if ($this->messageValidated) {
         /* This message was validated externally. */
         return TRUE;
     }
     /* Validate the signature. */
     $this->validator = new SimpleSAML_XML_Validator($this->dom, array('ResponseID', 'AssertionID'));
     // Get the issuer of the response.
     $issuer = $this->getIssuer();
     /* Get the metadata of the issuer. */
     $metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
     $md = $metadata->getMetaData($issuer, 'shib13-idp-remote');
     if (array_key_exists('certFingerprint', $md)) {
         /* Get fingerprint for the certificate of the issuer. */
         $issuerFingerprint = $md['certFingerprint'];
         /* Validate the fingerprint. */
         $this->validator->validateFingerprint($issuerFingerprint);
     } elseif (array_key_exists('caFile', $md)) {
         /* Validate against CA. */
         $globalConfig = SimpleSAML_Configuration::getInstance();
         $this->validator->validateCA($globalConfig->getPathValue('certdir', 'cert/') . $md['caFile']);
     } else {
         throw new Exception('Required field [certFingerprint] or [caFile] in Shibboleth 1.3 IdP Remote metadata was not found for identity provider [' . $issuer . ']. Please add a fingerprint and try again. You can add a dummy fingerprint first, and then an error message will be printed with the real fingerprint.');
     }
     return true;
 }
开发者ID:hukumonline,项目名称:yii,代码行数:28,代码来源:AuthnResponse.php

示例12: initTimezone

 /**
  * Initialize the timezone.
  *
  * This function should be called before any calls to date().
  *
  * @author Olav Morken, UNINETT AS <olav.morken@uninett.no>
  */
 public static function initTimezone()
 {
     static $initialized = false;
     if ($initialized) {
         return;
     }
     $initialized = true;
     $globalConfig = \SimpleSAML_Configuration::getInstance();
     $timezone = $globalConfig->getString('timezone', null);
     if ($timezone !== null) {
         if (!date_default_timezone_set($timezone)) {
             throw new \SimpleSAML_Error_Exception('Invalid timezone set in the "timezone" option in config.php.');
         }
         return;
     }
     // we don't have a timezone configured
     /*
      * The date_default_timezone_get() function is likely to cause a warning.
      * Since we have a custom error handler which logs the errors with a backtrace,
      * this error will be logged even if we prefix the function call with '@'.
      * Instead we temporarily replace the error handler.
      */
     set_error_handler(function () {
         return true;
     });
     $serverTimezone = date_default_timezone_get();
     restore_error_handler();
     // set the timezone to the default
     date_default_timezone_set($serverTimezone);
 }
开发者ID:palantirnet,项目名称:simplesamlphp,代码行数:37,代码来源:Time.php

示例13: getInstance

 /**
  * Retrieve our singleton instance.
  *
  * @return SimpleSAML_Store|FALSE  The datastore, or FALSE if it isn't enabled.
  */
 public static function getInstance()
 {
     if (self::$instance !== NULL) {
         return self::$instance;
     }
     $config = SimpleSAML_Configuration::getInstance();
     $storeType = $config->getString('store.type', NULL);
     if ($storeType === NULL) {
         $storeType = $config->getString('session.handler', 'phpsession');
     }
     switch ($storeType) {
         case 'phpsession':
             /* We cannot support advanced features with the PHP session store. */
             self::$instance = FALSE;
             break;
         case 'memcache':
             self::$instance = new SimpleSAML_Store_Memcache();
             break;
         case 'sql':
             self::$instance = new SimpleSAML_Store_SQL();
             break;
         default:
             if (strpos($storeType, ':') === FALSE) {
                 throw new SimpleSAML_Error_Exception('Unknown datastore type: ' . var_export($storeType, TRUE));
             }
             /* Datastore from module. */
             $className = SimpleSAML_Module::resolveClass($storeType, 'Store', 'SimpleSAML_Store');
             self::$instance = new $className();
     }
     return self::$instance;
 }
开发者ID:shirlei,项目名称:simplesaml,代码行数:36,代码来源:Store.php

示例14: process

 public function process(&$state)
 {
     assert('is_array($state)');
     if (empty($state['Expire']) || empty($state['Authority'])) {
         return;
     }
     $now = time();
     $delta = $state['Expire'] - $now;
     $globalConfig = SimpleSAML_Configuration::getInstance();
     $sessionDuration = $globalConfig->getInteger('session.duration', 8 * 60 * 60);
     /* Extend only if half of session duration already passed */
     if ($delta >= $sessionDuration * 0.5) {
         return;
     }
     /* Update authority expire time */
     $session = SimpleSAML_Session::getSessionFromRequest();
     $session->setAuthorityExpire($state['Authority']);
     /* Update session cookies duration */
     /* If remember me is active */
     $rememberMeExpire = $session->getRememberMeExpire();
     if (!empty($state['RememberMe']) && $rememberMeExpire !== NULL && $globalConfig->getBoolean('session.rememberme.enable', FALSE)) {
         $session->setRememberMeExpire();
         return;
     }
     /* Or if session lifetime is more than zero */
     $sessionHandler = SimpleSAML_SessionHandler::getSessionHandler();
     $cookieParams = $sessionHandler->getCookieParams();
     if ($cookieParams['lifetime'] > 0) {
         $session->updateSessionCookies();
     }
 }
开发者ID:tractorcow,项目名称:simplesamlphp,代码行数:31,代码来源:ExtendIdPSession.php

示例15: getInstance

 /**
  * Retrieve our singleton instance.
  *
  * @return SimpleSAML_Store|false  The data store, or false if it isn't enabled.
  */
 public static function getInstance()
 {
     if (self::$instance !== null) {
         return self::$instance;
     }
     $config = SimpleSAML_Configuration::getInstance();
     $storeType = $config->getString('store.type', null);
     if ($storeType === null) {
         $storeType = $config->getString('session.handler', 'phpsession');
     }
     switch ($storeType) {
         case 'phpsession':
             // we cannot support advanced features with the PHP session store
             self::$instance = false;
             break;
         case 'memcache':
             self::$instance = new SimpleSAML_Store_Memcache();
             break;
         case 'sql':
             self::$instance = new SimpleSAML_Store_SQL();
             break;
         default:
             // datastore from module
             try {
                 $className = SimpleSAML\Module::resolveClass($storeType, 'Store', 'SimpleSAML_Store');
             } catch (Exception $e) {
                 $c = $config->toArray();
                 $c['store.type'] = 'phpsession';
                 throw new SimpleSAML\Error\CriticalConfigurationError("Invalid 'store.type' configuration option. Cannot find store '{$storeType}'.", null, $c);
             }
             self::$instance = new $className();
     }
     return self::$instance;
 }
开发者ID:simplesamlphp,项目名称:simplesamlphp,代码行数:39,代码来源:Store.php


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