diff --git a/lib/SimpleSAML/Session.php b/lib/SimpleSAML/Session.php index 003c3db73d9c712d0becbb6ee701c7cd17c302d5..232713439cda0e58f23a99bfd80af71cf00eb137 100644 --- a/lib/SimpleSAML/Session.php +++ b/lib/SimpleSAML/Session.php @@ -637,6 +637,38 @@ class SimpleSAML_Session { } + /** + * This function retrieves all data of the specified type from the data store. + * + * The data will be returned as an associative array with the id of the data as the key, and the data + * as the value of each key. The value will be stored as a copy of the original data. setData must be + * used to update the data. + * + * An empty array will be returned if no data of the given type is found. + * + * @param $type The type of the data. + * @return An associative array with all data of the given type. + */ + public function getDataOfType($type) { + assert('is_string($type)'); + + if(!is_array($this->dataStore)) { + return array(); + } + + if(!array_key_exists($type, $this->dataStore)) { + return array(); + } + + $ret = array(); + foreach($this->dataStore[$type] as $id => $info) { + $ret[$id] = $info['data']; + } + + return $ret; + } + + /** * Load a session from the session handler. *