Revision: 1739
Author: olavmrk
Date: Thu Sep  3 03:37:06 2009
Log: SimpleSAML_Auth_Source: Add getSourcesOfType().
http://code.google.com/p/simplesamlphp/source/detail?r=1739

Modified:
  /trunk/lib/SimpleSAML/Auth/Source.php

=======================================
--- /trunk/lib/SimpleSAML/Auth/Source.php       Fri Aug 28 00:47:31 2009
+++ /trunk/lib/SimpleSAML/Auth/Source.php       Thu Sep  3 03:37:06 2009
@@ -36,6 +36,39 @@
                assert('array_key_exists("AuthId", $info)');
                $this->authId = $info['AuthId'];
        }
+
+
+       /**
+        * Get sources of a specific type.
+        *
+        * @param string $type  The type of the authentication source.
+        * @return array  Array of SimpleSAML_Auth_Source objects of the  
specified type.
+        */
+       public static function getSourcesOfType($type) {
+               assert('is_string($type)');
+
+               $config = 
SimpleSAML_Configuration::getConfig('authsources.php');
+
+               $ret = array();
+
+               $sources = $config->getOptions();
+               foreach ($sources as $id) {
+                       $source = $config->getArray($id);
+
+                       if (!array_key_exists(0, $source) || 
!is_string($source[0])) {
+                               throw new Exception('Invalid authentication 
source \'' . $authId .
+                                       '\': First element must be a string 
which identifies the  
authentication source.');
+                       }
+
+                       if ($source[0] !== $type) {
+                               continue;
+                       }
+
+                       $ret[] = self::parseAuthSource($id, $source);
+               }
+
+               return $ret;
+       }


        /**

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"simpleSAMLphp commits" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/simplesamlphp-commits?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to