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

Adding to aggregator module support for including maxDuration and validUntil...

Adding to aggregator module support for including maxDuration and validUntil attributes to entitydecriptor metadata

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1092 44740490-163a-0410-bde0-09ae8108e29a
parent 5ccd03c2
No related branches found
No related tags found
No related merge requests found
......@@ -24,20 +24,40 @@ class SimpleSAML_Metadata_SAMLBuilder {
private $entityDescriptor;
private $maxCache = NULL;
private $maxDuration = NULL;
/**
* Initialize the builder.
*
* @param string $entityId The entity id of the entity.
*/
public function __construct($entityId) {
public function __construct($entityId, $maxCache = NULL, $maxDuration = NULL) {
assert('is_string($entityId)');
$this->maxCache = $maxCache;
$this->maxDuration = $maxDuration;
$this->document = new DOMDocument();
$this->entityDescriptor = $this->createElement('EntityDescriptor');
$this->entityDescriptor->setAttribute('entityID', $entityId);
$this->document->appendChild($this->entityDescriptor);
}
private function setExpiration($metadata) {
if (array_key_exists('expire', $metadata)) {
if ($metadata['expire'] - time() < $this->maxDuration)
$this->maxDuration = $metadata['expire'] - time();
}
if ($this->maxCache !== NULL)
$this->entityDescriptor->setAttribute('cacheDuration', $this->maxCache);
if ($this->maxDuration !== NULL)
$this->entityDescriptor->setAttribute('validUntil', SimpleSAML_Utilities::generateTimestamp(time() + $this->maxDuration));
}
/**
* Retrieve the EntityDescriptor.
......@@ -175,6 +195,8 @@ class SimpleSAML_Metadata_SAMLBuilder {
public function addMetadata($set, $metadata) {
assert('is_string($set)');
assert('is_array($metadata)');
$this->setExpiration($metadata);
switch ($set) {
case 'saml20-sp-remote':
......@@ -194,7 +216,6 @@ class SimpleSAML_Metadata_SAMLBuilder {
}
}
/**
* Add SAML 2.0 SP metadata.
*
......
......@@ -12,6 +12,9 @@ $config = array(
),
),
'maxCache' => 60*60*24, // 24 hour cache time
'maxDuration' => 60*60*24*5, // Maximum 5 days duration on ValidUntil.
/* Whether metadata should be signed. */
'sign.enable' => FALSE,
......
......@@ -100,7 +100,9 @@ foreach ($entities as $entity => $sets) {
$tmp->loadXML(base64_decode($entityDescriptor));
$entityDescriptor = $tmp->documentElement;
} else {
$tmp = new SimpleSAML_Metadata_SAMLBuilder($entity);
$tmp = new SimpleSAML_Metadata_SAMLBuilder($entity,
$aggregatorConfig->getValue('maxCache', NULL), $aggregatorConfig->getValue('maxDuration', NULL));
foreach ($sets as $set => $metadata) {
$tmp->addMetadata($set, $metadata);
}
......
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