ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
sspmod_core_Auth_Process_CardinalitySingle Class Reference
+ Inheritance diagram for sspmod_core_Auth_Process_CardinalitySingle:
+ Collaboration diagram for sspmod_core_Auth_Process_CardinalitySingle:

Public Member Functions

 __construct ($config, $reserved, HTTPAdapter $http=null)
 Initialize this filter, parse configuration. More...
 
 process (&$request)
 Process this filter. 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 Attributes

 $singleValued = array()
 
 $firstValue = array()
 
 $flatten = array()
 
 $flattenWith = ';'
 
 $ignoreEntities = array()
 
 $http
 

Additional Inherited Members

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

Detailed Description

Definition at line 14 of file CardinalitySingle.php.

Constructor & Destructor Documentation

◆ __construct()

sspmod_core_Auth_Process_CardinalitySingle::__construct (   $config,
  $reserved,
HTTPAdapter  $http = null 
)

Initialize this filter, parse configuration.

Parameters
array$configConfiguration information about this filter.
mixed$reservedFor future use.
HTTPAdapter$httpHTTP utility service (handles redirects).

Definition at line 41 of file CardinalitySingle.php.

References $config, $http, and ILIAS\FileDelivery\http().

42  {
43  parent::__construct($config, $reserved);
44  assert(is_array($config));
45 
46  $this->http = $http ?: new HTTPAdapter();
47 
48  if (array_key_exists('singleValued', $config)) {
49  $this->singleValued = $config['singleValued'];
50  }
51  if (array_key_exists('firstValue', $config)) {
52  $this->firstValue = $config['firstValue'];
53  }
54  if (array_key_exists('flattenWith', $config)) {
55  $this->flattenWith = is_array($config['flattenWith']) ? array_shift($config['flattenWith']) : $config['flattenWith'];
56  }
57  if (array_key_exists('flatten', $config)) {
58  $this->flatten = $config['flatten'];
59  }
60  if (array_key_exists('ignoreEntities', $config)) {
61  $this->ignoreEntities = $config['ignoreEntities'];
62  }
63  /* for consistency with core:Cardinality */
64  if (array_key_exists('%ignoreEntities', $config)) {
65  $this->ignoreEntities = $config['%ignoreEntities'];
66  }
67  }
$config
Definition: bootstrap.php:15
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:

Member Function Documentation

◆ process()

sspmod_core_Auth_Process_CardinalitySingle::process ( $request)

Process this filter.

Parameters
array&$requestThe current request

Definition at line 74 of file CardinalitySingle.php.

References $id, $request, $url, SimpleSAML\Logger\debug(), SimpleSAML\Module\getModuleURL(), ILIAS\FileDelivery\http(), and SimpleSAML_Auth_State\saveState().

75  {
76  assert(is_array($request));
77  assert(array_key_exists("Attributes", $request));
78 
79  if (array_key_exists('Source', $request) &&
80  array_key_exists('entityid', $request['Source']) &&
81  in_array($request['Source']['entityid'], $this->ignoreEntities, true)
82  ) {
83  SimpleSAML\Logger::debug('CardinalitySingle: Ignoring assertions from '.$request['Source']['entityid']);
84  return;
85  }
86 
87  foreach ($request['Attributes'] as $k => $v) {
88  if (!is_array($v)) {
89  continue;
90  }
91  if (count($v) <= 1) {
92  continue;
93  }
94 
95  if (in_array($k, $this->singleValued)) {
96  $request['core:cardinality:errorAttributes'][$k] = array(count($v), '0 ≤ n ≤ 1');
97  continue;
98  }
99  if (in_array($k, $this->firstValue)) {
100  $request['Attributes'][$k] = array(array_shift($v));
101  continue;
102  }
103  if (in_array($k, $this->flatten)) {
104  $request['Attributes'][$k] = array(implode($this->flattenWith, $v));
105  continue;
106  }
107  }
108 
109  /* abort if we found a problematic attribute */
110  if (array_key_exists('core:cardinality:errorAttributes', $request)) {
111  $id = SimpleSAML_Auth_State::saveState($request, 'core:cardinality');
112  $url = SimpleSAML\Module::getModuleURL('core/cardinality_error.php');
113  $this->http->redirectTrustedURL($url, array('StateId' => $id));
114  return;
115  }
116  }
foreach($paths as $path) $request
Definition: asyncclient.php:32
static debug($string)
Definition: Logger.php:211
if(!array_key_exists('StateId', $_REQUEST)) $id
static getModuleURL($resource, array $parameters=array())
Get absolute URL to a specified module resource.
Definition: Module.php:220
static http()
Fetches the global http state from ILIAS.
$url
static saveState(&$state, $stage, $rawId=false)
Save the state.
Definition: State.php:194
+ Here is the call graph for this function:

Field Documentation

◆ $firstValue

sspmod_core_Auth_Process_CardinalitySingle::$firstValue = array()
private

Definition at line 20 of file CardinalitySingle.php.

◆ $flatten

sspmod_core_Auth_Process_CardinalitySingle::$flatten = array()
private

Definition at line 23 of file CardinalitySingle.php.

◆ $flattenWith

sspmod_core_Auth_Process_CardinalitySingle::$flattenWith = ';'
private

Definition at line 26 of file CardinalitySingle.php.

◆ $http

sspmod_core_Auth_Process_CardinalitySingle::$http
private

Definition at line 32 of file CardinalitySingle.php.

Referenced by __construct().

◆ $ignoreEntities

sspmod_core_Auth_Process_CardinalitySingle::$ignoreEntities = array()
private

Definition at line 29 of file CardinalitySingle.php.

◆ $singleValued

sspmod_core_Auth_Process_CardinalitySingle::$singleValued = array()
private

Definition at line 17 of file CardinalitySingle.php.


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