Exemplo n.º 1
0
 /**
  * Create an output from a configuration object.
  *
  * @param SimpleSAML_Configuration $config The configuration object.
  *
  * @return mixed A new instance of the configured class.
  */
 private static function createOutput(SimpleSAML_Configuration $config)
 {
     $cls = $config->getString('class');
     $cls = SimpleSAML\Module::resolveClass($cls, 'Stats_Output', 'SimpleSAML_Stats_Output');
     $output = new $cls($config);
     return $output;
 }
Exemplo n.º 2
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;
 }
Exemplo n.º 3
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;
 }
Exemplo n.º 4
0
 public function getRule($preferRule)
 {
     $rule = $this->resolveSelectedRule($preferRule);
     $statrulesConfig = $this->statconfig->getConfigItem('statrules');
     $statruleConfig = $statrulesConfig->getConfigItem($rule);
     $presenterClass = SimpleSAML\Module::resolveClass($statruleConfig->getValue('presenter', 'statistics:BaseRule'), 'Statistics_Rulesets');
     $statrule = new $presenterClass($this->statconfig, $statruleConfig, $rule, $this->available);
     return $statrule;
 }
Exemplo n.º 5
0
 public function getDelimiterPresentation()
 {
     $config = SimpleSAML_Configuration::getInstance();
     $t = new SimpleSAML_XHTML_Template($config, 'statistics:statistics-tpl.php');
     $availdelimiters = $this->availDelimiters();
     // create a delimiter presentation filter for this rule...
     if ($this->ruleconfig->hasValue('fieldPresentation')) {
         $fieldpresConfig = $this->ruleconfig->getConfigItem('fieldPresentation');
         $classname = SimpleSAML\Module::resolveClass($fieldpresConfig->getValue('class'), 'Statistics_FieldPresentation');
         if (!class_exists($classname)) {
             throw new Exception('Could not find field presentation plugin [' . $classname . ']: No class found');
         }
         $presentationHandler = new $classname($availdelimiters, $fieldpresConfig->getValue('config'), $t);
         return $presentationHandler->getPresentation();
     }
     return array();
 }
Exemplo n.º 6
0
 /**
  * Parse consent storage configuration.
  *
  * This function parses the configuration for a consent storage method.
  * An exception will be thrown if configuration parsing fails.
  *
  * @param mixed $config The configuration.
  *
  * @return sspmod_consent_Store An object which implements the
  *                              sspmod_consent_Store class.
  */
 public static function parseStoreConfig($config)
 {
     if (is_string($config)) {
         $config = array($config);
     }
     if (!is_array($config)) {
         throw new Exception('Invalid configuration for consent store option: ' . var_export($config, true));
     }
     if (!array_key_exists(0, $config)) {
         throw new Exception('Consent store without name given.');
     }
     $className = SimpleSAML\Module::resolveClass($config[0], 'Consent_Store', 'sspmod_consent_Store');
     unset($config[0]);
     return new $className($config);
 }
Exemplo n.º 7
0
 /**
  * Create authentication source object from configuration array.
  *
  * This function takes an array with the configuration for an authentication source object,
  * and returns the object.
  *
  * @param string $authId The authentication source identifier.
  * @param array  $config The configuration.
  *
  * @return SimpleSAML_Auth_Source The parsed authentication source.
  * @throws Exception If the authentication source is invalid.
  */
 private static function parseAuthSource($authId, $config)
 {
     assert('is_string($authId)');
     assert('is_array($config)');
     self::validateSource($config, $authId);
     $className = SimpleSAML\Module::resolveClass($config[0], 'Auth_Source', 'SimpleSAML_Auth_Source');
     $info = array('AuthId' => $authId);
     unset($config[0]);
     return new $className($info, $config);
 }
Exemplo n.º 8
0
 /**
  * Parse an authentication processing filter.
  *
  * @param array $config  	Array with the authentication processing filter configuration.
  * @param int $priority		The priority of the current filter, (not included in the filter 
  *							definition.)
  * @return SimpleSAML_Auth_ProcessingFilter  The parsed filter.
  */
 private static function parseFilter($config, $priority)
 {
     assert('is_array($config)');
     if (!array_key_exists('class', $config)) {
         throw new Exception('Authentication processing filter without name given.');
     }
     $className = SimpleSAML\Module::resolveClass($config['class'], 'Auth_Process', 'SimpleSAML_Auth_ProcessingFilter');
     $config['%priority'] = $priority;
     unset($config['class']);
     return new $className($config, NULL);
 }