ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
sspmod_core_Auth_Process_AttributeMap Class Reference
+ Inheritance diagram for sspmod_core_Auth_Process_AttributeMap:
+ Collaboration diagram for sspmod_core_Auth_Process_AttributeMap:

Public Member Functions

 __construct ($config, $reserved)
 Initialize this filter, parse configuration. More...
 
 process (&$request)
 Apply filter to rename attributes. More...
 
- Public Member Functions inherited from SimpleSAML_Auth_ProcessingFilter
 __construct (&$config, $reserved)
 Constructor for a processing filter. More...
 
 process (&$request)
 Process a request. More...
 

Private Member Functions

 loadMapFile ($fileName)
 Loads and merges in a file with a attribute map. More...
 

Private Attributes

 $map = array()
 Associative array with the mappings of attribute names. More...
 
 $duplicate = false
 Should attributes be duplicated or renamed. More...
 

Additional Inherited Members

- Data Fields inherited from SimpleSAML_Auth_ProcessingFilter
 $priority = 50
 Priority of this filter. More...
 

Detailed Description

Definition at line 10 of file AttributeMap.php.

Constructor & Destructor Documentation

◆ __construct()

sspmod_core_Auth_Process_AttributeMap::__construct (   $config,
  $reserved 
)

Initialize this filter, parse configuration.

Parameters
array$configConfiguration information about this filter.
mixed$reservedFor future use.
Exceptions
ExceptionIf the configuration of the filter is wrong.

Definition at line 32 of file AttributeMap.php.

33 {
34 parent::__construct($config, $reserved);
35
36 assert('is_array($config)');
37 $mapFiles = array();
38
39 foreach ($config as $origName => $newName) {
40 if (is_int($origName)) {
41 if ($newName === '%duplicate') {
42 $this->duplicate = true;
43 } else {
44 // no index given, this is a map file
45 $mapFiles[] = $newName;
46 }
47 continue;
48 }
49
50 if (!is_string($origName)) {
51 throw new Exception('Invalid attribute name: '.var_export($origName, true));
52 }
53
54 if (!is_string($newName) && !is_array($newName)) {
55 throw new Exception('Invalid attribute name: '.var_export($newName, true));
56 }
57
58 $this->map[$origName] = $newName;
59 }
60
61 // load map files after we determine duplicate or rename
62 foreach ($mapFiles as &$file) {
63 $this->loadMapFile($file);
64 }
65 }
loadMapFile($fileName)
Loads and merges in a file with a attribute map.
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file

References $config, $file, and loadMapFile().

+ Here is the call graph for this function:

Member Function Documentation

◆ loadMapFile()

sspmod_core_Auth_Process_AttributeMap::loadMapFile (   $fileName)
private

Loads and merges in a file with a attribute map.

Parameters
string$fileNameName of attribute map file. Expected to be in the attributemap directory in the root of the SimpleSAMLphp installation, or in the root of a module.
Exceptions
ExceptionIf the filter could not load the requested attribute map file.

Definition at line 76 of file AttributeMap.php.

77 {
79
80 $m = explode(':', $fileName);
81 if (count($m) === 2) { // we are asked for a file in a module
82 if (!SimpleSAML\Module::isModuleEnabled($m[0])) {
83 throw new Exception("Module '$m[0]' is not enabled.");
84 }
85 $filePath = SimpleSAML\Module::getModuleDir($m[0]).'/attributemap/'.$m[1].'.php';
86 } else {
87 $filePath = $config->getPathValue('attributenamemapdir', 'attributemap/').$fileName.'.php';
88 }
89
90 if (!file_exists($filePath)) {
91 throw new Exception('Could not find attribute map file: '.$filePath);
92 }
93
94 $attributemap = null;
95 include($filePath);
96 if (!is_array($attributemap)) {
97 throw new Exception('Attribute map file "'.$filePath.'" didn\'t define an attribute map.');
98 }
99
100 if ($this->duplicate) {
101 $this->map = array_merge_recursive($this->map, $attributemap);
102 } else {
103 $this->map = array_merge($this->map, $attributemap);
104 }
105 }
$attributemap
Definition: addurnprefix.php:3
static getModuleDir($module)
Retrieve the base directory for a module.
Definition: Module.php:122
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.
Attribute-related utility methods.

References $attributemap, $config, $m, SimpleSAML_Configuration\getInstance(), and SimpleSAML\Module\getModuleDir().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ process()

sspmod_core_Auth_Process_AttributeMap::process ( $request)

Apply filter to rename attributes.

Parameters
array&$requestThe current request.

Reimplemented from SimpleSAML_Auth_ProcessingFilter.

Definition at line 113 of file AttributeMap.php.

114 {
115 assert('is_array($request)');
116 assert('array_key_exists("Attributes", $request)');
117
118 $attributes =& $request['Attributes'];
119
120 foreach ($attributes as $name => $values) {
121 if (array_key_exists($name, $this->map)) {
122 if (!is_array($this->map[$name])) {
123 if (!$this->duplicate) {
124 unset($attributes[$name]);
125 }
126 $attributes[$this->map[$name]] = $values;
127 } else {
128 foreach ($this->map[$name] as $to_map) {
129 $attributes[$to_map] = $values;
130 }
131 if (!$this->duplicate && !in_array($name, $this->map[$name], true)) {
132 unset($attributes[$name]);
133 }
134 }
135 }
136 }
137 }
if($format !==null) $name
Definition: metadata.php:146
$attributes

References $attributes, and $name.

Field Documentation

◆ $duplicate

sspmod_core_Auth_Process_AttributeMap::$duplicate = false
private

Should attributes be duplicated or renamed.

Definition at line 21 of file AttributeMap.php.

◆ $map

sspmod_core_Auth_Process_AttributeMap::$map = array()
private

Associative array with the mappings of attribute names.

Definition at line 16 of file AttributeMap.php.


The documentation for this class was generated from the following file: