Skip to content
Snippets Groups Projects
Commit 03e69236 authored by Olav Morken's avatar Olav Morken
Browse files

SAML metadata parser: added getEntityId method and added entity id as key to...

SAML metadata parser: added getEntityId method and added entity id as key to array returned by parseDescriptorsElement. Also fix case of entityId various places in the source.


git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@347 44740490-163a-0410-bde0-09ae8108e29a
parent 8d3e38eb
No related branches found
No related tags found
No related merge requests found
......@@ -93,13 +93,13 @@ class SimpleSAML_Metadata_SAMLParser {
assert('$entityElement instanceof DOMElement');
/* Extract the entityID from the EntityDescriptor element. This is a required
/* Extract the entity id from the EntityDescriptor element. This is a required
* attribute, so we throw an exception if it isn't found.
*/
if(!$entityElement->hasAttribute('entityID')) {
throw new Exception('EntityDescriptor missing required entityID attribute.');
}
$this->entityID = $entityElement->getAttribute('entityID');
$this->entityId = $entityElement->getAttribute('entityID');
/* Look over the child nodes for any known element types. */
......@@ -188,7 +188,7 @@ class SimpleSAML_Metadata_SAMLParser {
/**
* This function parses a file where the root node is either an EntityDescriptor element or an
* EntitiesDescriptor element. In both cases it will return an array of SAMLParser instances. If
* EntitiesDescriptor element. In both cases it will return an associative array of SAMLParser instances. If
* the file contains a single EntityDescriptorElement, then the array will contain a single SAMLParser
* instance.
*
......@@ -210,10 +210,11 @@ class SimpleSAML_Metadata_SAMLParser {
/**
* This function parses a string with XML data. The root node of the XML data is expected to be either an
* EntityDescriptor element or an EntitiesDescriptor element. It will return an array of SAMLParser instances.
* EntityDescriptor element or an EntitiesDescriptor element. It will return an associative array of
* SAMLParser instances.
*
* @param $string The string with XML data.
* @return An array of SAMLParser instances.
* @return An associative array of SAMLParser instances. The key of the array will be the entity id.
*/
public static function parseDescriptorsString($string) {
......@@ -230,11 +231,11 @@ class SimpleSAML_Metadata_SAMLParser {
/**
* This function parses a DOMElement which represents either an EntityDescriptor element or an
* EntitiesDescriptor element. It will return an array of SAMLParser instances in both cases.
* EntitiesDescriptor element. It will return an associative array of SAMLParser instances in both cases.
*
* @param $element The DOMElement which contains the EntityDescriptor element or the EntitiesDescriptor
* element.
* @return An array of SAMLParser instances.
* @return An associative array of SAMLParser instances. The key of the array will be the entity id.
*/
public static function parseDescriptorsElement($element) {
......@@ -256,17 +257,28 @@ class SimpleSAML_Metadata_SAMLParser {
$ret = array();
foreach($elements as $e) {
$ret[] = self::parseElement($e);
$entity = self::parseElement($e);
$ret[$entity->getEntityId()] = $entity;
}
return $ret;
}
/**
* This function returns the entity id of this parsed entity.
*
* @return The entity id of this parsed entity.
*/
public function getEntityId() {
return $this->entityId;
}
/**
* This function returns the metadata for SAML 1.x SPs in the format simpleSAMLphp expects.
* This is an associative array with the following fields:
* - 'entityID': The entity id of the entity described in the metadata.
* - 'entityid': The entity id of the entity described in the metadata.
* - 'AssertionConsumerService': String with the url of the assertion consumer service which supports
* the browser-post binding.
*
......@@ -278,7 +290,7 @@ class SimpleSAML_Metadata_SAMLParser {
$ret = array();
$ret['entityID'] = $this->entityID;
$ret['entityid'] = $this->entityId;
/* Find SP information which supports one of the SAML 1.x protocols. */
......@@ -307,8 +319,8 @@ class SimpleSAML_Metadata_SAMLParser {
/**
* This function returns the metadata for SAML 2.0 IdPs in the format simpleSAMLphp expects.
* This is an associative array with the following fields:
* - 'entityID': The entity id of the entity described in the metadata.
* - 'name': Autogenerated name for this entity. Currently set to the entityID.
* - 'entityid': The entity id of the entity described in the metadata.
* - 'name': Autogenerated name for this entity. Currently set to the entity id.
* - 'SingleSignOnService': String with the url of the SSO service which supports the redirect binding.
* - 'SingleLogoutService': String with the url where we should send logout requests/responses.
* - 'certFingerprint': Fingerprint of the X509Certificate from the metadata.
......@@ -321,9 +333,9 @@ class SimpleSAML_Metadata_SAMLParser {
$ret = array();
$ret['entityID'] = $this->entityID;
$ret['entityid'] = $this->entityId;
$ret['name'] = $this->entityID;
$ret['name'] = $this->entityId;
/* Find IdP information which supports the SAML 1.x protocol. */
$idp = $this->getIdPDescriptors(self::$SAML1xProtocols);
......@@ -363,7 +375,7 @@ class SimpleSAML_Metadata_SAMLParser {
/**
* This function returns the metadata for SAML 2.0 SPs in the format simpleSAMLphp expects.
* This is an associative array with the following fields:
* - 'entityID': The entity id of the entity described in the metadata.
* - 'entityid': The entity id of the entity described in the metadata.
* - 'AssertionConsumerService': String with the url of the assertion consumer service which supports
* the browser-post binding.
* - 'SingleLogoutService': String with the url where we should send logout requests/responses.
......@@ -377,7 +389,7 @@ class SimpleSAML_Metadata_SAMLParser {
$ret = array();
$ret['entityID'] = $this->entityID;
$ret['entityid'] = $this->entityId;
/* Find SP information which supports the SAML 2.0 protocol. */
......@@ -422,8 +434,8 @@ class SimpleSAML_Metadata_SAMLParser {
/**
* This function returns the metadata for SAML 2.0 IdPs in the format simpleSAMLphp expects.
* This is an associative array with the following fields:
* - 'entityID': The entity id of the entity described in the metadata.
* - 'name': Autogenerated name for this entity. Currently set to the entityID.
* - 'entityid': The entity id of the entity described in the metadata.
* - 'name': Autogenerated name for this entity. Currently set to the entity id.
* - 'SingleSignOnService': String with the url of the SSO service which supports the redirect binding.
* - 'SingleLogoutService': String with the url where we should send logout requests/responses.
* - 'certFingerprint': Fingerprint of the X509Certificate from the metadata.
......@@ -436,9 +448,9 @@ class SimpleSAML_Metadata_SAMLParser {
$ret = array();
$ret['entityID'] = $this->entityID;
$ret['entityid'] = $this->entityId;
$ret['name'] = $this->entityID;
$ret['name'] = $this->entityId;
/* Find IdP information which supports the SAML 2.0 protocol. */
$idp = $this->getIdPDescriptors(self::$SAML20Protocols);
......
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