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

Copied the flat file metadata handler to a new SAML2 Meta data class. For now,...

Copied the flat file metadata handler to a new SAML2 Meta data class. For now, just a copy, will implement this class tomorrow.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@144 44740490-163a-0410-bde0-09ae8108e29a
parent 92bac5c7
No related branches found
No related tags found
No related merge requests found
<?php
/*
* This file is part of simpleSAMLphp. See the file COPYING in the
* root of the distribution for licence information.
*
* This file defines a base class for metadata handling.
* Instantiation of session handler objects should be done through
* the class method getMetadataHandler().
*/
require_once('SimpleSAML/Configuration.php');
require_once('SimpleSAML/Utilities.php');
require_once('SimpleSAML/Metadata/MetaDataStorageHandler.php');
/**
* Configuration of SimpleSAMLphp
*/
class MetaDataStorageHandlerSAML2Meta extends SimpleSAML_Metadata_MetaDataStorageHandler {
/* 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() {
}
public function load($set) {
$metadata = null;
if (!in_array($set, array(
'saml20-sp-hosted', 'saml20-sp-remote','saml20-idp-hosted', 'saml20-idp-remote',
'shib13-sp-hosted', 'shib13-sp-remote', 'shib13-idp-hosted', 'shib13-idp-remote',
'openid-provider'))) {
throw new Exception('Trying to load illegal set of Meta data [' . $set . ']');
}
/* Get the configuration. */
$config = SimpleSAML_Configuration::getInstance();
assert($config instanceof SimpleSAML_Configuration);
$metadatasetfile = $config->getBaseDir() . '/' .
$config->getValue('metadatadir') . '/' . $set . '.php';
if (!file_exists($metadatasetfile)) {
throw new Exception('Could not open file: ' . $metadatasetfile);
}
include($metadatasetfile);
if (!is_array($metadata)) {
throw new Exception('Could not load metadata set [' . $set . '] from file: ' . $metadatasetfile);
}
foreach ($metadata AS $key => $entry) {
$this->metadata[$set][$key] = $entry;
$this->metadata[$set][$key]['entityid'] = $key;
if (isset($entry['host'])) {
$this->hostmap[$set][$entry['host']] = $key;
}
}
}
public function getMetaData($entityid = null, $set = 'saml20-sp-hosted') {
if (!isset($entityid)) {
return $this->getMetaDataCurrent($set);
}
//echo 'find metadata for entityid [' . $entityid . '] in metadata set [' . $set . ']';
if (!isset($this->metadata[$set])) {
$this->load($set);
}
if (!isset($this->metadata[$set][$entityid]) ) {
throw new Exception('Could not find metadata for entityid [' . $entityid . '] in metadata set [' . $set . ']');
}
return $this->metadata[$set][$entityid];
}
}
?>
\ No newline at end of file
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