ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ilSamlMappedUserAttributeValueParser Class Reference

Class ilSamlMappedUserAttributeValueParser. More...

+ Collaboration diagram for ilSamlMappedUserAttributeValueParser:

Public Member Functions

 __construct (ilExternalAuthUserAttributeMappingRule $rule, array $userData)
 
 getAttributeKey ()
 
 parse ()
 

Protected Member Functions

 getValueIndex ()
 

Protected Attributes

ilExternalAuthUserAttributeMappingRule $rule
 
array $userData = []
 

Private Attributes

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

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

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

References $rule, and $userData.

34  {
35  $this->rule = $rule;
36  $this->userData = $userData;
37  }

Member Function Documentation

◆ getAttributeKey()

ilSamlMappedUserAttributeValueParser::getAttributeKey ( )

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

Referenced by parse().

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

◆ getValueIndex()

ilSamlMappedUserAttributeValueParser::getValueIndex ( )
protected

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

References $index, and ILIAS\Repository\int().

Referenced by parse().

39  : int
40  {
41  $index = 0;
42 
43  $matches = [];
44  preg_match(self::ATTR_REGEX, $this->rule->getExternalAttribute(), $matches);
45 
46  if (is_array($matches) && isset($matches[3]) && is_numeric($matches[3])) {
47  $index = (int) $matches[3];
48  }
49 
50  return max($index, 0);
51  }
$index
Definition: metadata.php:145
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parse()

ilSamlMappedUserAttributeValueParser::parse ( )

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

References getAttributeKey(), and getValueIndex().

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

Field Documentation

◆ $rule

ilExternalAuthUserAttributeMappingRule ilSamlMappedUserAttributeValueParser::$rule
protected

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

Referenced by __construct().

◆ $userData

array ilSamlMappedUserAttributeValueParser::$userData = []
protected

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

Referenced by __construct().

◆ ATTR_REGEX

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

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