From fe80b8ad59fd1a07e8ff1eadd234318a083466f5 Mon Sep 17 00:00:00 2001 From: Olav Morken <olav.morken@uninett.no> Date: Mon, 15 Sep 2008 13:52:33 +0000 Subject: [PATCH] Metadata parser - include original EntityDescriptor in metadata. git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@871 44740490-163a-0410-bde0-09ae8108e29a --- lib/SimpleSAML/Metadata/SAMLParser.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/SimpleSAML/Metadata/SAMLParser.php b/lib/SimpleSAML/Metadata/SAMLParser.php index 49c920dca..502f1f530 100644 --- a/lib/SimpleSAML/Metadata/SAMLParser.php +++ b/lib/SimpleSAML/Metadata/SAMLParser.php @@ -110,6 +110,12 @@ class SimpleSAML_Metadata_SAMLParser { private $validator = array(); + /** + * The original EntityDescriptor element for this entity, as a base64 encoded string. + */ + private $entityDescriptor; + + /** * This is the constructor for the SAMLParser class. * @@ -119,14 +125,16 @@ class SimpleSAML_Metadata_SAMLParser { * with a Signature element. * @param int|NULL $expireTime The unix timestamp for when this entity should expire, or NULL if unknwon. */ - private function __construct($entityElement, $entitiesValidator, $expireTime) { + private function __construct(DOMElement $entityElement, $entitiesValidator, $expireTime) { + assert('is_null($entitiesValidator) || $entitiesValidator instanceof SimpleSAML_XML_Validator'); assert('is_null($expireTime) || is_int($expireTime)'); $this->spDescriptors = array(); $this->idpDescriptors = array(); - - assert('$entityElement instanceof DOMElement'); + $tmpDoc = new DOMDocument(); + $tmpDoc->appendChild($tmpDoc->importNode($entityElement, TRUE)); + $this->entityDescriptor = base64_encode($tmpDoc->saveXML()); /* Extract the entity id from the EntityDescriptor element. This is a required * attribute, so we throw an exception if it isn't found. @@ -410,6 +418,7 @@ class SimpleSAML_Metadata_SAMLParser { $ret = array(); $ret['entityid'] = $this->entityId; + $ret['entityDescriptor'] = $this->entityDescriptor; /* Find SP information which supports one of the SAML 1.x protocols. */ @@ -461,6 +470,7 @@ class SimpleSAML_Metadata_SAMLParser { $ret = array(); $ret['entityid'] = $this->entityId; + $ret['entityDescriptor'] = $this->entityDescriptor; $ret['name'] = $this->entityId; @@ -534,6 +544,7 @@ class SimpleSAML_Metadata_SAMLParser { $ret = array(); $ret['entityid'] = $this->entityId; + $ret['entityDescriptor'] = $this->entityDescriptor; /* Find SP information which supports the SAML 2.0 protocol. */ @@ -601,6 +612,7 @@ class SimpleSAML_Metadata_SAMLParser { $ret = array(); $ret['entityid'] = $this->entityId; + $ret['entityDescriptor'] = $this->entityDescriptor; $ret['name'] = $this->entityId; -- GitLab