diff options
author | Olav Morken <olav.morken@uninett.no> | 2009-11-04 13:51:53 +0000 |
---|---|---|
committer | Olav Morken <olav.morken@uninett.no> | 2009-11-04 13:51:53 +0000 |
commit | 69fdcc7f8da9b83dd1fdd8773669922cb551901a (patch) | |
tree | f12368e0e7875539f559da46347bff4556487e43 /lib/SimpleSAML | |
parent | 2ab141787cbbc4627ae08cbb3b9935bdaebb12c2 (diff) | |
download | simplesamlphp-69fdcc7f8da9b83dd1fdd8773669922cb551901a.zip simplesamlphp-69fdcc7f8da9b83dd1fdd8773669922cb551901a.tar.gz simplesamlphp-69fdcc7f8da9b83dd1fdd8773669922cb551901a.tar.bz2 |
SimpleSAML_Configuration: Add getDefaultEndpoint function.
git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1945 44740490-163a-0410-bde0-09ae8108e29a
Diffstat (limited to 'lib/SimpleSAML')
-rw-r--r-- | lib/SimpleSAML/Configuration.php | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/SimpleSAML/Configuration.php b/lib/SimpleSAML/Configuration.php index 3bca636..d46a199 100644 --- a/lib/SimpleSAML/Configuration.php +++ b/lib/SimpleSAML/Configuration.php @@ -944,6 +944,32 @@ class SimpleSAML_Configuration { return $eps; } + + /** + * Find the default endpoint of the given type. + * + * @param string $endpointType The endpoint type. + * @param array $bindings Array with acceptable bindings. Can be NULL if any binding is allowed. + * @param mixed $default The default value to return if no matching endpoint is found. If no default is provided, an exception will be thrown. + * @return array|NULL The default endpoint, or NULL if no acceptable endpoints are used. + */ + public function getDefaultEndpoint($endpointType, array $bindings = NULL, $default = self::REQUIRED_OPTION) { + assert('is_string($endpointType)'); + + $endpoints = $this->getEndpoints($endpointType); + $defaultEndpoint = SimpleSAML_Utilities::getDefaultEndpoint($endpoints, $bindings); + if ($defaultEndpoint !== NULL) { + return $defaultEndpoint; + } + + if ($default === self::REQUIRED_OPTION) { + $loc = $this->location . '[' . var_export($endpointType, TRUE) . ']:'; + throw new Exception($loc . 'Could not find a supported ' . $endpointType . ' endpoint.'); + } + + return $default; + } + } ?>
\ No newline at end of file |