ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilSamlMappedUserAttributeValueParser Class Reference

Class ilSamlMappedUserAttributeValueParser. More...

+ Collaboration diagram for ilSamlMappedUserAttributeValueParser:

Public Member Functions

 __construct (\ilExternalAuthUserAttributeMappingRule $rule, array $userData)
 ilSamlMappedUserAttributeValueParser constructor. More...
 
 getAttributeKey ()
 
 parse ()
 

Data Fields

const ATTR_REGEX = '/^(.*?)(\|(\d+))?$/'
 

Protected Member Functions

 getValueIndex ()
 

Protected Attributes

 $rule
 
 $userData = []
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilSamlMappedUserAttributeValueParser::__construct ( \ilExternalAuthUserAttributeMappingRule  $rule,
array  $userData 
)

Member Function Documentation

◆ getAttributeKey()

ilSamlMappedUserAttributeValueParser::getAttributeKey ( )
Returns
string

Definition at line 52 of file class.ilSamlMappedUserAttributeValueParser.php.

References array.

Referenced by parse().

53  {
54  $attribute = '';
55 
56  $matches = array();
57  preg_match(self::ATTR_REGEX, $this->rule->getExternalAttribute(), $matches);
58 
59  if (is_array($matches) && isset($matches[1]) && is_string($matches[1])) {
60  $attribute = $matches[1];
61  }
62 
63  return $attribute;
64  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getValueIndex()

ilSamlMappedUserAttributeValueParser::getValueIndex ( )
protected
Returns
int

Definition at line 35 of file class.ilSamlMappedUserAttributeValueParser.php.

References $index, and array.

Referenced by parse().

36  {
37  $index = 0;
38 
39  $matches = array();
40  preg_match(self::ATTR_REGEX, $this->rule->getExternalAttribute(), $matches);
41 
42  if (is_array($matches) && isset($matches[3]) && is_numeric($matches[3])) {
43  $index = (int) $matches[3];
44  }
45 
46  return $index >= 0 ? $index : 0;
47  }
$index
Definition: metadata.php:60
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ parse()

ilSamlMappedUserAttributeValueParser::parse ( )
Exceptions

Definition at line 70 of file class.ilSamlMappedUserAttributeValueParser.php.

References getAttributeKey(), and getValueIndex().

71  {
72  $attributeKey = $this->getAttributeKey();
73 
74  if (!array_key_exists($attributeKey, $this->userData)) {
75  throw new \ilSamlException(sprintf(
76  "Configured external attribute of mapping '%s' -> '%s' does not exist in SAML attribute data.",
77  $this->rule->getAttribute(),
78  $this->rule->getExternalAttribute()
79  ));
80  }
81 
82  $value = $this->userData[$attributeKey];
83 
84  if (is_array($value)) {
85  $valueIndex = $this->getValueIndex();
86 
87  if (!array_key_exists($valueIndex, $value)) {
88  throw new \ilSamlException(sprintf(
89  "Configured external attribute of mapping '%s' -> '%s' does not exist in SAML attribute data.",
90  $this->rule->getAttribute(),
91  $this->rule->getExternalAttribute()
92  ));
93  }
94 
95  $value = $value[$valueIndex];
96  }
97 
98  if (!is_scalar($value)) {
99  throw new \ilSamlException(sprintf(
100  "Could not parse a scalar value based on the user attribute mapping '%s' -> '%s'.",
101  $this->rule->getAttribute(),
102  $this->rule->getExternalAttribute()
103  ));
104  }
105 
106  return $value;
107  }
+ Here is the call graph for this function:

Field Documentation

◆ $rule

ilSamlMappedUserAttributeValueParser::$rule
protected

Definition at line 14 of file class.ilSamlMappedUserAttributeValueParser.php.

Referenced by __construct().

◆ $userData

ilSamlMappedUserAttributeValueParser::$userData = []
protected

Definition at line 19 of file class.ilSamlMappedUserAttributeValueParser.php.

Referenced by __construct().

◆ ATTR_REGEX

const ilSamlMappedUserAttributeValueParser::ATTR_REGEX = '/^(.*?)(\|(\d+))?$/'

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