Esempio n. 1
0
 /**
  * Create an output from a configuration object.
  *
  * @param SimpleSAML_Configuration $config  The configuration object.
  * @return
  */
 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;
 }
Esempio n. 2
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;
 }
Esempio 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
             $className = SimpleSAML_Module::resolveClass($storeType, 'Store', 'SimpleSAML_Store');
             self::$instance = new $className();
     }
     return self::$instance;
 }
Esempio 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;
 }
 /**
  * Get and initialize the configured collector
  *
  * @param array $config	 Configuration information about this filter.
  */
 private function getCollector($config)
 {
     if (!array_key_exists("collector", $config) || !array_key_exists("class", $config["collector"])) {
         throw new Exception('No collector class specified in configuration');
     }
     $collectorConfig = $config["collector"];
     $collectorClassName = SimpleSAML_Module::resolveClass($collectorConfig['class'], 'Collector', 'sspmod_attributecollector_SimpleCollector');
     unset($collectorConfig['class']);
     return new $collectorClassName($collectorConfig);
 }
 /**
  * Get en instance of the exporter
  *
  * @param string $type   The exporter type
  * @param array  $option Options for the exporter
  *
  * @return ssmod_janus_Exporter An instance
  */
 public static final function getInstance($type, array $option = null)
 {
     assert('is_string($type)');
     assert('is_array($option) || is_null($option)');
     // Resolve classname of exporter
     try {
         $className = SimpleSAML_Module::resolveClass($type, 'Exporter', 'sspmod_janus_Exporter');
         SimpleSAML_Logger::debug('External exporter class found: ' . $className);
     } catch (Exception $e) {
         SimpleSAML_Logger::debug('External exporter class not found: ' . $type);
         throw $e;
     }
     // Return new instance of exporter
     return new $className($option);
 }
 public function __construct(\SimpleSAML_Configuration $config)
 {
     $this->configuredClients = array();
     foreach ($config->getValue('clients', array()) as $clientId => $client) {
         $scopes = array();
         foreach (isset($client['scope']) ? $client['scope'] : array() as $scope) {
             $scopes[$scope] = false;
         }
         foreach (isset($client['scopeRequired']) ? $client['scopeRequired'] : array() as $scope) {
             $scopes[$scope] = true;
         }
         unset($client['scopeRequired']);
         $client['scope'] = $scopes;
         $this->configuredClients[$clientId] = $client;
     }
     $storeConfig = $config->getValue('store');
     $storeClass = SimpleSAML_Module::resolveClass($storeConfig['class'], 'Store');
     $this->store = new $storeClass($storeConfig);
     $this->validScopes = array_keys($config->getValue('scopes', array()));
     $this->registrationEnabled = $config->getValue('enable_client_registration', false);
 }
Esempio n. 8
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();
 }
Esempio n. 9
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.
  */
 private static function parseAuthSource($authId, $config)
 {
     assert('is_string($authId)');
     assert('is_array($config)');
     if (!array_key_exists(0, $config) || !is_string($config[0])) {
         throw new Exception('Invalid authentication source \'' . $authId . '\': First element must be a string which identifies the authentication source.');
     }
     $className = SimpleSAML_Module::resolveClass($config[0], 'Auth_Source', 'SimpleSAML_Auth_Source');
     $info = array('AuthId' => $authId);
     unset($config[0]);
     return new $className($info, $config);
 }
Esempio n. 10
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);
 }
    $message = 'Logout not allowed';
    SimpleSAML_Logger::debug('casserver:' . $message);
    throw new Exception($message);
}
$skipLogoutPage = $casconfig->getValue('skip_logout_page', false);
if ($skipLogoutPage && !array_key_exists('url', $_GET)) {
    $message = 'Required URL query parameter [url] not provided. (CAS Server)';
    SimpleSAML_Logger::debug('casserver:' . $message);
    throw new Exception($message);
}
/* Load simpleSAMLphp metadata */
$as = new SimpleSAML_Auth_Simple($casconfig->getValue('authsource'));
$session = SimpleSAML_Session::getSession();
if (!is_null($session)) {
    $ticketStoreConfig = $casconfig->getValue('ticketstore', array('class' => 'casserver:FileSystemTicketStore'));
    $ticketStoreClass = SimpleSAML_Module::resolveClass($ticketStoreConfig['class'], 'Cas_Ticket');
    $ticketStore = new $ticketStoreClass($casconfig);
    $ticketStore->deleteTicket($session->getSessionId());
}
if ($as->isAuthenticated()) {
    SimpleSAML_Logger::debug('casserver: performing a real logout');
    if ($casconfig->getValue('skip_logout_page', false)) {
        $as->logout($_GET['url']);
    } else {
        $as->logout(SimpleSAML\Utils\HTTP::addURLParameters(SimpleSAML_Module::getModuleURL('casserver/loggedOut.php'), array_key_exists('url', $_GET) ? array('url' => $_GET['url']) : array()));
    }
} else {
    SimpleSAML_Logger::debug('casserver: no session to log out of, performing redirect');
    if ($casconfig->getValue('skip_logout_page', false)) {
        SimpleSAML\Utils\HTTP::redirectTrustedURL(SimpleSAML\Utils\HTTP::addURLParameters($_GET['url'], array()));
    } else {
*  pgtUrl
*
*/
require_once 'urlUtils.php';
/* Load simpleSAMLphp, configuration and metadata */
$casconfig = SimpleSAML_Configuration::getConfig('module_casserver.php');
/* Instantiate protocol handler */
$protocolClass = SimpleSAML_Module::resolveClass('casserver:Cas20', 'Cas_Protocol');
$protocol = new $protocolClass($casconfig);
if (array_key_exists('service', $_GET) && array_key_exists('ticket', $_GET)) {
    $forceAuthn = isset($_GET['renew']) && $_GET['renew'];
    try {
        $ticketStoreConfig = $casconfig->getValue('ticketstore', array('class' => 'casserver:FileSystemTicketStore'));
        $ticketStoreClass = SimpleSAML_Module::resolveClass($ticketStoreConfig['class'], 'Cas_Ticket');
        $ticketStore = new $ticketStoreClass($casconfig);
        $ticketFactoryClass = SimpleSAML_Module::resolveClass('casserver:TicketFactory', 'Cas_Ticket');
        $ticketFactory = new $ticketFactoryClass($casconfig);
        $serviceTicket = $ticketStore->getTicket($_GET['ticket']);
        if (!is_null($serviceTicket) && ($ticketFactory->isServiceTicket($serviceTicket) || $ticketFactory->isProxyTicket($serviceTicket) && $method == 'proxyValidate')) {
            $ticketStore->deleteTicket($_GET['ticket']);
            $attributes = $serviceTicket['attributes'];
            if (!$ticketFactory->isExpired($serviceTicket) && sanitize($serviceTicket['service']) == sanitize($_GET['service']) && (!$forceAuthn || $serviceTicket['forceAuthn'])) {
                $protocol->setAttributes($attributes);
                if (isset($_GET['pgtUrl'])) {
                    $sessionTicket = $ticketStore->getTicket($serviceTicket['sessionId']);
                    $pgtUrl = $_GET['pgtUrl'];
                    if (!is_null($sessionTicket) && $ticketFactory->isSessionTicket($sessionTicket) && !$ticketFactory->isExpired($sessionTicket)) {
                        $proxyGrantingTicket = $ticketFactory->createProxyGrantingTicket(array('userName' => $serviceTicket['userName'], 'attributes' => $attributes, 'forceAuthn' => false, 'proxies' => array_merge(array($_GET['service']), $serviceTicket['proxies']), 'sessionId' => $serviceTicket['sessionId']));
                        try {
                            SimpleSAML\Utils\HTTP::fetch($pgtUrl . '?pgtIou=' . $proxyGrantingTicket['iou'] . '&pgtId=' . $proxyGrantingTicket['id']);
                            $protocol->setProxyGrantingTicketIOU($proxyGrantingTicket['iou']);
Esempio n. 13
0
            $location[$key] = $value;
        }
    }
    return $location;
}
$start = microtime(TRUE);
foreach ($orgs as $orgkey => $org) {
    if (array_key_exists($orgkey, $results)) {
        continue;
    }
    $orgconfig = SimpleSAML_Configuration::loadFromArray($org, 'org:[' . $orgkey . ']');
    $orglocs = $org['locations'];
    $results[$orgkey] = array();
    foreach ($orglocs as $orgloc) {
        $orgloc = mergeWithTemplate($orgloc, $locationTemplate);
        $classname = SimpleSAML_Module::resolveClass($orgloc['testType'], 'Auth_Backend_Test');
        $tester = new $classname(SimpleSAML_Configuration::loadFromArray($orgloc, 'Location@[' . $orgkey . ']'), $orgconfig);
        $results[$orgkey][] = $tester->test();
    }
    if (microtime(TRUE) - $start > $maxtime) {
        SimpleSAML_Logger::debug('ldapstatus: Completing execution after maxtime [' . (microtime(TRUE) - $start) . ' of maxtime ' . $maxtime . ']');
        break;
    }
}
$session->setData('module:ldapstatus', 'results', $results);
#echo '<pre>'; print_r($results); exit;
$lightCounter = array(0, 0, 0);
function resultCode($res, $sortby = NULL)
{
    global $lightCounter;
    $code = '';
Esempio n. 14
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);
 }
Esempio n. 15
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);
 }
 public function __construct(\SimpleSAML_Configuration $config)
 {
     $storeConfig = $config->getValue('store');
     $storeClass = SimpleSAML_Module::resolveClass($storeConfig['class'], 'Store');
     $this->store = new $storeClass($storeConfig);
 }