34 parent::__construct(
$config, $reserved);
39 foreach (
$config as $origName => $newName) {
40 if (is_int($origName)) {
41 if ($newName ===
'%duplicate') {
42 $this->duplicate =
true;
45 $mapFiles[] = $newName;
50 if (!is_string($origName)) {
51 throw new Exception(
'Invalid attribute name: '.var_export($origName,
true));
54 if (!is_string($newName) && !is_array($newName)) {
55 throw new Exception(
'Invalid attribute name: '.var_export($newName,
true));
58 $this->map[$origName] = $newName;
62 foreach ($mapFiles as &$file) {
80 $m = explode(
':', $fileName);
81 if (count(
$m) === 2) {
83 throw new Exception(
"Module '$m[0]' is not enabled.");
87 $filePath =
$config->getPathValue(
'attributenamemapdir',
'attributemap/').$fileName.
'.php';
90 if (!file_exists($filePath)) {
91 throw new Exception(
'Could not find attribute map file: '.$filePath);
97 throw new Exception(
'Attribute map file "'.$filePath.
'" didn\'t define an attribute map.');
100 if ($this->duplicate) {
101 $this->map = array_merge_recursive($this->map,
$attributemap);
116 assert(array_key_exists(
'Attributes',
$request));
118 $mapped_attributes = array();
121 if (array_key_exists(
$name, $this->map)) {
122 if (!is_array($this->map[
$name])) {
123 if ($this->duplicate) {
128 foreach ($this->map[$name] as $to_map) {
129 $mapped_attributes[$to_map] =
$values;
131 if ($this->duplicate && !in_array($name, $this->map[$name],
true)) {
140 $request[
'Attributes'] = $mapped_attributes;
foreach($paths as $path) $request
static getModuleDir($module)
Retrieve the base directory for a module.
$duplicate
Should attributes be duplicated or renamed.
process(&$request)
Apply filter to rename attributes.
Attribute-related utility methods.
$map
Associative array with the mappings of attribute names.
loadMapFile($fileName)
Loads and merges in a file with a attribute map.
__construct($config, $reserved)
Initialize this filter, parse configuration.
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.