Skip to content
Snippets Groups Projects
Commit 3b9e8686 authored by Andreas Åkre Solberg's avatar Andreas Åkre Solberg
Browse files

initial change to metadata handler files (not working yet)

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@138 44740490-163a-0410-bde0-09ae8108e29a
parent 3cf01063
No related branches found
No related tags found
No related merge requests found
<?php <?php
/*
/** * This file is part of simpleSAMLphp. See the file COPYING in the
* SimpleSAMLphp * root of the distribution for licence information.
*
* PHP versions 4 and 5
* *
* LICENSE: See the COPYING file included in this distribution. * This file defines a base class for metadata handling.
* * Instantiation of session handler objects should be done through
* @author Andreas kre Solberg, UNINETT AS. <andreas.solberg@uninett.no> * the class method getMetadataHandler().
*/ */
require_once('SimpleSAML/Configuration.php'); require_once('SimpleSAML/Configuration.php');
...@@ -17,15 +15,102 @@ require_once('SimpleSAML/Utilities.php'); ...@@ -17,15 +15,102 @@ require_once('SimpleSAML/Utilities.php');
/** /**
* Configuration of SimpleSAMLphp * Configuration of SimpleSAMLphp
*/ */
class SimpleSAML_XML_MetaDataStore { class SimpleSAML_Metadata_MetaDataStorageHandler {
private $configuration = null; private $configuration = null;
private $metadata = null; private $metadata = null;
private $hostmap = null; private $hostmap = null;
function __construct(SimpleSAML_Configuration $configuration) {
$this->configuration = $configuration;
/* This static variable contains a reference to the current
* instance of the metadata handler. This variable will be NULL if
* we haven't instantiated a metadata handler yet.
*/
private static $metadataHandler = NULL;
/* This function retrieves the current instance of the metadata handler.
* The metadata handler will be instantiated if this is the first call
* to this fuunction.
*
* Returns:
* The current metadata handler.
*/
public static function getMetadataHandler() {
if(self::$metadataHandler === NULL) {
self::createMetadataHandler();
}
return self::$metadataHandler;
}
/* This constructor is included in case it is needed in the the
* future. Including it now allows us to write parent::__construct() in
* the subclasses of this class.
*/
protected function __construct() {
}
/* This function creates an instance of the metadata handler which is
* selected in the 'metadata.handler' configuration directive. If no
* metadata handler is selected, then we will fall back to the default
* PHP metadata handler.
*/
public static function createMetadataHandler() {
/* Get the configuration. */
$config = SimpleSAML_Configuration::getInstance();
assert($config instanceof SimpleSAML_Configuration);
/* Get the session handler option from the configuration. */
$handler = $config->getValue('metadata.handler');
/* If 'session.handler' is NULL or unset, then we want
* to fall back to the default PHP session handler.
*/
if(is_null($handler)) {
$handler = 'phpsession';
}
/* The session handler must be a string. */
if(!is_string($handler)) {
$e = 'Invalid setting for the \'session.handler\'' .
' configuration option. This option should be' .
' set to a valid string.';
error_log($e);
die($e);
}
$handler = strtolower($handler);
if($handler === 'phpsession') {
require_once('SimpleSAML/SessionHandlerPHP.php');
$sh = new SimpleSAML_SessionHandlerPHP();
} else if($handler === 'memcache') {
require_once('SimpleSAML/SessionHandlerMemcache.php');
$sh = new SimpleSAML_SessionHandlerMemcache();
} else {
$e = 'Invalid value for the \'session.handler\'' .
' configuration option. Unknown session' .
' handler: ' . $handler;
error_log($e);
die($e);
}
/* Set the session handler. */
self::$sessionHandler = $sh;
} }
public function load($set) { public function load($set) {
$metadata = null; $metadata = null;
......
<?php <?php
/*
/** * This file is part of simpleSAMLphp. See the file COPYING in the
* SimpleSAMLphp * root of the distribution for licence information.
*
* PHP versions 4 and 5
* *
* LICENSE: See the COPYING file included in this distribution. * This file defines a base class for metadata handling.
* * Instantiation of session handler objects should be done through
* @author Andreas kre Solberg, UNINETT AS. <andreas.solberg@uninett.no> * the class method getMetadataHandler().
*/ */
require_once('SimpleSAML/Configuration.php'); require_once('SimpleSAML/Configuration.php');
...@@ -27,6 +25,97 @@ class SimpleSAML_XML_MetaDataStore { ...@@ -27,6 +25,97 @@ class SimpleSAML_XML_MetaDataStore {
$this->configuration = $configuration; $this->configuration = $configuration;
} }
/* This static variable contains a reference to the current
* instance of the metadata handler. This variable will be NULL if
* we haven't instantiated a metadata handler yet.
*/
private static $metadataHandler = NULL;
/* This function retrieves the current instance of the metadata handler.
* The metadata handler will be instantiated if this is the first call
* to this fuunction.
*
* Returns:
* The current metadata handler.
*/
public static function getMetadataHandler() {
if(self::$metadataHandler === NULL) {
self::createMetadataHandler();
}
return self::$metadataHandler;
}
/* This constructor is included in case it is needed in the the
* future. Including it now allows us to write parent::__construct() in
* the subclasses of this class.
*/
protected function __construct() {
}
/* This function creates an instance of the metadata handler which is
* selected in the 'metadata.handler' configuration directive. If no
* metadata handler is selected, then we will fall back to the default
* PHP metadata handler.
*/
public static function createSessionHandler() {
/* Get the configuration. */
$config = SimpleSAML_Configuration::getInstance();
assert($config instanceof SimpleSAML_Configuration);
/* Get the session handler option from the configuration. */
$handler = $config->getValue('metadata.handler');
/* If 'session.handler' is NULL or unset, then we want
* to fall back to the default PHP session handler.
*/
if(is_null($handler)) {
$handler = 'phpsession';
}
/* The session handler must be a string. */
if(!is_string($handler)) {
$e = 'Invalid setting for the \'session.handler\'' .
' configuration option. This option should be' .
' set to a valid string.';
error_log($e);
die($e);
}
$handler = strtolower($handler);
if($handler === 'phpsession') {
require_once('SimpleSAML/SessionHandlerPHP.php');
$sh = new SimpleSAML_SessionHandlerPHP();
} else if($handler === 'memcache') {
require_once('SimpleSAML/SessionHandlerMemcache.php');
$sh = new SimpleSAML_SessionHandlerMemcache();
} else {
$e = 'Invalid value for the \'session.handler\'' .
' configuration option. Unknown session' .
' handler: ' . $handler;
error_log($e);
die($e);
}
/* Set the session handler. */
self::$sessionHandler = $sh;
}
public function load($set) { public function load($set) {
$metadata = null; $metadata = null;
if (!in_array($set, array( if (!in_array($set, array(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment