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

SAMLParser: Seperate out RoleDescriptorType parsing from SSODescriptor parsing.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1958 44740490-163a-0410-bde0-09ae8108e29a
parent bc38cac6
No related branches found
No related tags found
No related merge requests found
...@@ -722,26 +722,24 @@ class SimpleSAML_Metadata_SAMLParser { ...@@ -722,26 +722,24 @@ class SimpleSAML_Metadata_SAMLParser {
} }
/** /**
* This function extracts metadata from a SSODescriptor element. * Parse a RoleDescriptorType element.
* *
* The returned associative array has the following elements: * The returned associative array has the following elements:
* - 'protocols': Array with the protocols this SSODescriptor supports. * - 'protocols': Array with the protocols supported.
* - 'SingleLogoutService': Array with the single logout service endpoints. Each endpoint is stored * - 'expire': Timestamp for when this descriptor expires.
* as an associative array with the elements that parseGenericEndpoint returns. * - 'keys': Array of associative arrays with the elements from parseKeyDescriptor.
* - 'nameIDFormats': The NameIDFormats supported by this SSODescriptor. This may be an empty array.
* - 'keys': Array of associative arrays with the elements from parseKeyDescriptor:
* *
* @param $element The element we should extract metadata from. * @param DOMElement $element The element we should extract metadata from.
* @param int|NULL $expireTime The unix timestamp for when this element should expire, or * @param int|NULL $expireTime The unix timestamp for when this element should expire, or
* NULL if unknwon. * NULL if unknwon.
* @return Associative array with metadata we have extracted from this element. * @return Associative array with metadata we have extracted from this element.
*/ */
private static function parseSSODescriptor($element, $expireTime) { private static function parseRoleDescriptorType(DOMElement $element, $expireTime) {
assert('$element instanceof DOMElement');
assert('is_null($expireTime) || is_int($expireTime)'); assert('is_null($expireTime) || is_int($expireTime)');
$ret = array();
if ($expireTime === NULL) { if ($expireTime === NULL) {
/* No expiry time defined by a parent element. Check if this element defines /* No expiry time defined by a parent element. Check if this element defines
* one. * one.
...@@ -750,17 +748,49 @@ class SimpleSAML_Metadata_SAMLParser { ...@@ -750,17 +748,49 @@ class SimpleSAML_Metadata_SAMLParser {
} }
$sd = array();
if ($expireTime !== NULL) { if ($expireTime !== NULL) {
/* We have got an expire timestamp, either from this element, or one of the /* We have got an expire timestamp, either from this element, or one of the
* parent elements. * parent elements.
*/ */
$sd['expire'] = $expireTime; $ret['expire'] = $expireTime;
} }
$sd['protocols'] = self::getSupportedProtocols($element); $ret['protocols'] = self::getSupportedProtocols($element);
/* Process KeyDescriptor elements. */
$ret['keys'] = array();
$keys = SimpleSAML_Utilities::getDOMChildren($element, 'KeyDescriptor', '@md');
foreach($keys as $kd) {
$key = self::parseKeyDescriptor($kd);
if($key !== NULL) {
$ret['keys'][] = $key;
}
}
return $ret;
}
/**
* This function extracts metadata from a SSODescriptor element.
*
* The returned associative array has the following elements:
* - 'protocols': Array with the protocols this SSODescriptor supports.
* - 'SingleLogoutService': Array with the single logout service endpoints. Each endpoint is stored
* as an associative array with the elements that parseGenericEndpoint returns.
* - 'nameIDFormats': The NameIDFormats supported by this SSODescriptor. This may be an empty array.
* - 'keys': Array of associative arrays with the elements from parseKeyDescriptor:
*
* @param $element The element we should extract metadata from.
* @param int|NULL $expireTime The unix timestamp for when this element should expire, or
* NULL if unknwon.
* @return Associative array with metadata we have extracted from this element.
*/
private static function parseSSODescriptor($element, $expireTime) {
assert('$element instanceof DOMElement');
assert('is_null($expireTime) || is_int($expireTime)');
$sd = self::parseRoleDescriptorType($element, $expireTime);
/* Find all SingleLogoutService elements. */ /* Find all SingleLogoutService elements. */
$sd['SingleLogoutService'] = array(); $sd['SingleLogoutService'] = array();
...@@ -784,17 +814,6 @@ class SimpleSAML_Metadata_SAMLParser { ...@@ -784,17 +814,6 @@ class SimpleSAML_Metadata_SAMLParser {
$sd['nameIDFormats'][] = self::parseNameIDFormat($nif[0]); $sd['nameIDFormats'][] = self::parseNameIDFormat($nif[0]);
} }
/* Process KeyDescriptor elements. */
$sd['keys'] = array();
$keys = SimpleSAML_Utilities::getDOMChildren($element, 'KeyDescriptor', '@md');
foreach($keys as $kd) {
$key = self::parseKeyDescriptor($kd);
if($key !== NULL) {
$sd['keys'][] = $key;
}
}
return $sd; return $sd;
} }
......
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