getInstance() 공개 정적인 메소드

This function retrieves a configuration file by its instance name. The instance name is initialized by the init function, or by copyFromBase function. If no configuration file with the given instance name is found, an exception will be thrown.
public static getInstance ( string $instancename = 'simplesaml' ) : SimpleSAML_Configuration
$instancename string The instance name of the configuration file. Deprecated.
리턴 SimpleSAML_Configuration The configuration object.
예제 #1
0
    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', '*****@*****.**');
        if ($toAddress == '*****@*****.**') {
            SimpleSAML_Logger::error('Cron - Could not send email. [technicalcontact_email] not set in config.');
        } else {
            $email = new SimpleSAML_XHTML_EMail($toAddress, 'JANUS cron report', '*****@*****.**');
            $email->setBody($message);
            $email->send();
        }
    }
    /**
     * 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 = '*****@*****.**';
        $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();
    }
 /**
  * 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;
     }
 }
예제 #4
0
 /**
  * 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;
 }
 /**
  * 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');
 }
예제 #6
0
파일: Signer.php 프로젝트: hukumonline/yii
 /**
  * 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']);
     }
 }
예제 #7
0
 /**
  * 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);
     }
 }
예제 #8
0
 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;
 }
예제 #9
0
파일: ARP.php 프로젝트: danielkjfrog/docker
 private function loadAttributeMap($attributemap)
 {
     $config = SimpleSAML_Configuration::getInstance();
     include $config->getPathValue('attributemap', 'attributemap/') . $attributemap . '.php';
     $this->attributes = $attributemap;
     #	print_r($attributemap); exit;
 }
예제 #10
0
/**
 * 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', '*****@*****.**') === '*****@*****.**') {
        $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;
                }
            }
        }
    }
}
예제 #11
0
 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;
 }
예제 #12
0
 /**
  * Initialize the timezone.
  *
  * This function should be called before any calls to date().
  *
  * @author Olav Morken, UNINETT AS <*****@*****.**>
  */
 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);
 }
예제 #13
0
 /**
  * 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;
 }
예제 #14
0
 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();
     }
 }
예제 #15
0
 /**
  * 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;
 }
예제 #16
0
 protected function __construct()
 {
     /* Call the parent constructor in case it should become
      * necessary in the future.
      */
     parent::__construct();
     /* Initialize the php session handling.
      *
      * If session_id() returns a blank string, then we need
      * to call session start. Otherwise the session is already
      * started, and we should avoid calling session_start().
      */
     if (session_id() === '') {
         $config = SimpleSAML_Configuration::getInstance();
         $cookiepath = $config->getBoolean('session.phpsession.limitedpath', FALSE) ? '/' . $config->getBaseURL() : '/';
         session_set_cookie_params(0, $cookiepath, NULL, SimpleSAML_Utilities::isHTTPS());
         $cookiename = $config->getString('session.phpsession.cookiename', NULL);
         if (!empty($cookiename)) {
             session_name($cookiename);
         }
         $savepath = $config->getString('session.phpsession.savepath', NULL);
         if (!empty($savepath)) {
             session_save_path($savepath);
         }
         if (!array_key_exists(session_name(), $_COOKIE)) {
             /* Session cookie unset - session id not set. Generate new (secure) session id. */
             session_id(SimpleSAML_Utilities::stringToHex(SimpleSAML_Utilities::generateRandomBytes(16)));
         }
         session_start();
     }
 }
예제 #17
0
 /**
  * Send a response to the SP.
  *
  * @param array $state  The authentication state.
  */
 public static function sendResponse(array $state)
 {
     assert('isset($state["Attributes"])');
     assert('isset($state["SPMetadata"])');
     assert('isset($state["saml:shire"])');
     assert('array_key_exists("saml:target", $state)');
     // Can be NULL
     $spMetadata = $state["SPMetadata"];
     $spEntityId = $spMetadata['entityid'];
     $spMetadata = SimpleSAML_Configuration::loadFromArray($spMetadata, '$metadata[' . var_export($spEntityId, TRUE) . ']');
     SimpleSAML\Logger::info('Sending SAML 1.1 Response to ' . var_export($spEntityId, TRUE));
     $attributes = $state['Attributes'];
     $shire = $state['saml:shire'];
     $target = $state['saml:target'];
     $idp = SimpleSAML_IdP::getByState($state);
     $idpMetadata = $idp->getConfig();
     $config = SimpleSAML_Configuration::getInstance();
     $metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
     $statsData = array('spEntityID' => $spEntityId, 'idpEntityID' => $idpMetadata->getString('entityid'), 'protocol' => 'saml1');
     if (isset($state['saml:AuthnRequestReceivedAt'])) {
         $statsData['logintime'] = microtime(TRUE) - $state['saml:AuthnRequestReceivedAt'];
     }
     SimpleSAML_Stats::log('saml:idp:Response', $statsData);
     // Generate and send response.
     $ar = new SimpleSAML_XML_Shib13_AuthnResponse();
     $authnResponseXML = $ar->generate($idpMetadata, $spMetadata, $shire, $attributes);
     $httppost = new SimpleSAML_Bindings_Shib13_HTTPPost($config, $metadata);
     $httppost->sendResponse($authnResponseXML, $idpMetadata, $spMetadata, $target, $shire);
 }
예제 #18
0
 /**
  * Determine whether a module is enabled.
  *
  * Will return FALSE if the given module doesn't exists.
  *
  * @param string $module  Name of the module
  * @return bool  TRUE if the given module is enabled, FALSE if not.
  */
 public static function isModuleEnabled($module)
 {
     $moduleDir = self::getModuleDir($module);
     if (!is_dir($moduleDir)) {
         return FALSE;
     }
     $globalConfig = SimpleSAML_Configuration::getInstance();
     $moduleEnable = $globalConfig->getArray('module.enable', array());
     if (isset($moduleEnable[$module])) {
         if (is_bool($moduleEnable[$module]) === TRUE) {
             return $moduleEnable[$module];
         }
         throw new Exception("Invalid module.enable value for for the module {$module}");
     }
     if (assert_options(ASSERT_ACTIVE) && !file_exists($moduleDir . '/default-enable') && !file_exists($moduleDir . '/default-disable')) {
         SimpleSAML_Logger::error("Missing default-enable or default-disable file for the module {$module}");
     }
     if (file_exists($moduleDir . '/enable')) {
         return TRUE;
     }
     if (!file_exists($moduleDir . '/disable') && file_exists($moduleDir . '/default-enable')) {
         return TRUE;
     }
     return FALSE;
 }
 /**
  * Find the cache file name for an entity,
  *
  * @param string $set  The metadata set this entity belongs to.
  * @param string $entityId  The entity id of this entity.
  * @return string  The full path to the cache file.
  */
 private function getCacheFilename($set, $entityId)
 {
     assert('is_string($set)');
     assert('is_string($entityId)');
     $cachekey = sha1($entityId);
     $globalConfig = SimpleSAML_Configuration::getInstance();
     return $this->cacheDir . '/' . $set . '-' . $cachekey . '.cached.xml';
 }
 private function showException($e)
 {
     $globalConfig = SimpleSAML_Configuration::getInstance();
     $t = new SimpleSAML_XHTML_Template($globalConfig, 'attributefromrestapi:exception.tpl.php');
     $t->data['e'] = $e->getMessage();
     $t->show();
     exit;
 }
예제 #21
0
 /**
  * Finish a failed authentication.
  *
  * This function can be overloaded by a child authentication
  * class that wish to perform some operations on failure
  *
  * @param array &$state  Information about the current authentication.
  */
 public function authFailed(&$state)
 {
     $config = SimpleSAML_Configuration::getInstance();
     $t = new SimpleSAML_XHTML_Template($config, 'authX509:X509error.php');
     $t->data['errorcode'] = $state['authX509.error'];
     $t->show();
     exit;
 }
예제 #22
0
 /**
  * Retrieve the secret salt.
  *
  * This function retrieves the value which is configured as the secret salt. It will check that the value exists
  * and is set to a non-default value. If it isn't, an exception will be thrown.
  *
  * The secret salt can be used as a component in hash functions, to make it difficult to test all possible values
  * in order to retrieve the original value. It can also be used as a simple method for signing data, by hashing the
  * data together with the salt.
  *
  * @return string The secret salt.
  * @throws \InvalidArgumentException If the secret salt hasn't been configured.
  *
  * @author Olav Morken, UNINETT AS <*****@*****.**>
  */
 public static function getSecretSalt()
 {
     $secretSalt = \SimpleSAML_Configuration::getInstance()->getString('secretsalt');
     if ($secretSalt === 'defaultsecretsalt') {
         throw new \InvalidArgumentException('The "secretsalt" configuration option must be set to a secret value.');
     }
     return $secretSalt;
 }
 /**
  * Save a session to the data store.
  *
  * @param SimpleSAML_Session $session The session object we should save.
  */
 public function saveSession(SimpleSAML_Session $session)
 {
     $sessionId = $session->getSessionId();
     $config = SimpleSAML_Configuration::getInstance();
     $sessionDuration = $config->getInteger('session.duration', 8 * 60 * 60);
     $expire = time() + $sessionDuration;
     $this->store->set('session', $sessionId, $session, $expire);
 }
예제 #24
0
 /**
  * Initialize the SQL datastore.
  */
 protected function __construct()
 {
     $config = \SimpleSAML_Configuration::getInstance();
     $dbalconfig = \SimpleSAML_Configuration::getConfig('module_dbal.php');
     $this->prefix = $config->getString('store.sql.prefix', 'simpleSAMLphp');
     $this->kvstorePrefix = $this->prefix . '_kvstore';
     $connectionParams = array('driver' => $dbalconfig->getString('store.dbal.driver'), 'user' => $dbalconfig->getString('store.dbal.user', null), 'password' => $dbalconfig->getString('store.dbal.password', null), 'host' => $dbalconfig->getString('store.dbal.host', 'localhost'), 'dbname' => $dbalconfig->getString('store.dbal.dbname'));
     $this->conn = DriverManager::getConnection($connectionParams);
 }
예제 #25
0
 /**
  * Initialize the outputs.
  */
 private static function initOutputs()
 {
     $config = SimpleSAML_Configuration::getInstance();
     $outputCfgs = $config->getConfigList('statistics.out', array());
     self::$outputs = array();
     foreach ($outputCfgs as $cfg) {
         self::$outputs[] = self::createOutput($cfg);
     }
 }
예제 #26
0
 /**
  * Show the error to the user.
  *
  * This function does not return.
  */
 public function show()
 {
     header('HTTP/1.0 500 Internal Server Error');
     $this->logError();
     $globalConfig = SimpleSAML_Configuration::getInstance();
     $t = new SimpleSAML_XHTML_Template($globalConfig, 'core:no_metadata.tpl.php');
     $t->data['entityId'] = $this->entityId;
     $t->show();
     exit;
 }
예제 #27
0
파일: EMail.php 프로젝트: r4mp/Foodle
 /**
  * Constructor
  */
 function __construct($to, $subject, $from = NULL, $cc = NULL, $replyto = NULL)
 {
     $this->to = $to;
     $this->cc = $cc;
     $this->replyto = $replyto;
     $this->subject = $subject;
     $config = SimpleSAML_Configuration::getInstance('foodle');
     $this->from = $config->getValue('fromAddress', '*****@*****.**');
     require_once dirname(dirname(__FILE__)) . '/lib-ext/swift/swift_required.php';
 }
 /**
  * Constructor for this metadata handler.
  *
  * Parses configuration.
  *
  * @param array $config  The configuration for this metadata handler.
  */
 public function __construct($config)
 {
     assert('is_array($config)');
     $globalConfig = SimpleSAML_Configuration::getInstance();
     $cfgHelp = SimpleSAML_Configuration::loadFromArray($config, 'serialize metadata source');
     $this->directory = $cfgHelp->getString('directory');
     /* Resolve this directory relative to the simpleSAMLphp directory (unless it is
      * an absolute path).
      */
     $this->directory = $globalConfig->resolvePath($this->directory);
 }
예제 #29
0
 /**
  * Retrieves the current database instance. Will create a new one if there isn't an existing connection.
  *
  * @param \SimpleSAML_Configuration $altConfig Optional: Instance of a SimpleSAML_Configuration class
  *
  * @return \SimpleSAML\Database The shared database connection.
  */
 public static function getInstance($altConfig = null)
 {
     $config = $altConfig ? $altConfig : \SimpleSAML_Configuration::getInstance();
     $instanceId = self::generateInstanceId($config);
     // check if we already have initialized the session
     if (isset(self::$instance[$instanceId])) {
         return self::$instance[$instanceId];
     }
     // create a new session
     self::$instance[$instanceId] = new Database($config);
     return self::$instance[$instanceId];
 }
예제 #30
0
 function log_internal($level, $string)
 {
     $config = SimpleSAML_Configuration::getInstance();
     assert($config instanceof SimpleSAML_Configuration);
     $processname = $config->getString('logging.processname', 'simpleSAMLphp');
     if (array_key_exists($level, self::$levelNames)) {
         $levelName = self::$levelNames[$level];
     } else {
         $levelName = sprintf('UNKNOWN%d', $level);
     }
     error_log($processname . ' - ' . $levelName . ': ' . $string);
 }