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

SAMLParser: Replace the various endpoint parse functions with a single extractEndpoints-function.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1959 44740490-163a-0410-bde0-09ae8108e29a
parent 7f89ab97
No related branches found
No related tags found
No related merge requests found
...@@ -793,18 +793,10 @@ class SimpleSAML_Metadata_SAMLParser { ...@@ -793,18 +793,10 @@ class SimpleSAML_Metadata_SAMLParser {
$sd = self::parseRoleDescriptorType($element, $expireTime); $sd = self::parseRoleDescriptorType($element, $expireTime);
/* Find all SingleLogoutService elements. */ /* Find all SingleLogoutService elements. */
$sd['SingleLogoutService'] = array(); $sd['SingleLogoutService'] = self::extractEndpoints($element, 'SingleLogoutService', FALSE);
$sls = SimpleSAML_Utilities::getDOMChildren($element, 'SingleLogoutService', '@md');
foreach($sls as $child) {
$sd['SingleLogoutService'][] = self::parseSingleLogoutService($child);
}
/* Find all ArtifactResolutionService elements. */ /* Find all ArtifactResolutionService elements. */
$sd['ArtifactResolutionService'] = array(); $sd['ArtifactResolutionService'] = self::extractEndpoints($element, 'ArtifactResolutionService', TRUE);
$acs = SimpleSAML_Utilities::getDOMChildren($element, 'ArtifactResolutionService', '@md');
foreach($acs as $child) {
$sd['ArtifactResolutionService'][] = self::parseArtifactResolutionService($child);
}
/* Process NameIDFormat elements. */ /* Process NameIDFormat elements. */
...@@ -832,11 +824,7 @@ class SimpleSAML_Metadata_SAMLParser { ...@@ -832,11 +824,7 @@ class SimpleSAML_Metadata_SAMLParser {
$sp = self::parseSSODescriptor($element, $expireTime); $sp = self::parseSSODescriptor($element, $expireTime);
/* Find all AssertionConsumerService elements. */ /* Find all AssertionConsumerService elements. */
$sp['AssertionConsumerService'] = array(); $sp['AssertionConsumerService'] = self::extractEndpoints($element, 'AssertionConsumerService', TRUE);
$acs = SimpleSAML_Utilities::getDOMChildren($element, 'AssertionConsumerService', '@md');
foreach($acs as $child) {
$sp['AssertionConsumerService'][] = self::parseAssertionConsumerService($child);
}
/* Find all the attributes and SP name... */ /* Find all the attributes and SP name... */
#$sp['attributes'] = array(); #$sp['attributes'] = array();
...@@ -870,11 +858,7 @@ class SimpleSAML_Metadata_SAMLParser { ...@@ -870,11 +858,7 @@ class SimpleSAML_Metadata_SAMLParser {
/* Find all SingleSignOnService elements. */ /* Find all SingleSignOnService elements. */
$idp['SingleSignOnService'] = array(); $idp['SingleSignOnService'] = self::extractEndpoints($element, 'SingleSignOnService', FALSE);
$acs = SimpleSAML_Utilities::getDOMChildren($element, 'SingleSignOnService', '@md');
foreach($acs as $child) {
$idp['SingleSignOnService'][] = self::parseSingleSignOnService($child);
}
if ($element->getAttribute('WantAuthnRequestsSigned') === 'true') { if ($element->getAttribute('WantAuthnRequestsSigned') === 'true') {
$idp['WantAuthnRequestsSigned'] = TRUE; $idp['WantAuthnRequestsSigned'] = TRUE;
...@@ -986,19 +970,6 @@ class SimpleSAML_Metadata_SAMLParser { ...@@ -986,19 +970,6 @@ class SimpleSAML_Metadata_SAMLParser {
} }
/**
* This function parses AssertionConsumerService elements.
*
* @param $element The element which should be parsed.
* @return Associative array with the data we have extracted from the AssertionConsumerService element.
*/
private static function parseAssertionConsumerService($element) {
assert('$element instanceof DOMElement');
return self::parseGenericEndpoint($element, TRUE);
}
/** /**
* This function parses AttributeConsumerService elements. * This function parses AttributeConsumerService elements.
*/ */
...@@ -1030,45 +1001,6 @@ class SimpleSAML_Metadata_SAMLParser { ...@@ -1030,45 +1001,6 @@ class SimpleSAML_Metadata_SAMLParser {
} }
/**
* This function parses SingleLogoutService elements.
*
* @param $element The element which should be parsed.
* @return Associative array with the data we have extracted from the SingleLogoutService element.
*/
private static function parseSingleLogoutService($element) {
assert('$element instanceof DOMElement');
return self::parseGenericEndpoint($element, FALSE);
}
/**
* This function parses SingleSignOnService elements.
*
* @param $element The element which should be parsed.
* @return Associative array with the data we have extracted from the SingleLogoutService element.
*/
private static function parseSingleSignOnService($element) {
assert('$element instanceof DOMElement');
return self::parseGenericEndpoint($element, FALSE);
}
/**
* This function parses ArtifactResolutionService elements.
*
* @param $element The element which should be parsed.
* @return Associative array with the data we have extracted from the ArtifactResolutionService element.
*/
private static function parseArtifactResolutionService($element) {
assert('$element instanceof DOMElement');
return self::parseGenericEndpoint($element, TRUE);
}
/** /**
* This function parses NameIDFormat elements. * This function parses NameIDFormat elements.
* *
...@@ -1141,6 +1073,28 @@ class SimpleSAML_Metadata_SAMLParser { ...@@ -1141,6 +1073,28 @@ class SimpleSAML_Metadata_SAMLParser {
} }
/**
* Extract generic endpoints.
*
* @param DOMElement $element The element we should extract an endpoint list from.
* @param string $name The name of the elements.
* @param bool $isIndexed Whether the endpoints are indexed.
* @return array Array of parsed endpoints.
*/
private static function extractEndpoints(DOMElement $element, $name, $isIndexed) {
assert('is_bool($isIndexed)');
assert('is_string($name)');
$ret = array();
$endpoints = SimpleSAML_Utilities::getDOMChildren($element, $name, '@md');
foreach ($endpoints as $ep) {
$ret[] = self::parseGenericEndpoint($ep, $isIndexed);
}
return $ret;
}
/** /**
* This function parses a KeyDescriptor element. It currently only supports keys with a single * This function parses a KeyDescriptor element. It currently only supports keys with a single
* X509 certificate. * X509 certificate.
......
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