Apply filter to add the targeted ID.
81 {
83 assert(array_key_exists(
'Attributes',
$state));
84
85 if ($this->attribute === NULL) {
86 if (!array_key_exists(
'UserID',
$state)) {
87 throw new Exception('core:TargetedID: Missing UserID for this user. Please' .
88 ' check the \'userid.attribute\' option in the metadata against the' .
89 ' attributes provided by the authentication source.');
90 }
91
92 $userID =
$state[
'UserID'];
93 } else {
94 if (!array_key_exists($this->attribute,
$state[
'Attributes'])) {
95 throw new Exception('core:TargetedID: Missing attribute \'' . $this->attribute .
96 '\', which is needed to generate the targeted ID.');
97 }
98
99 $userID = $state['Attributes'][$this->attribute][0];
100 }
101
102
103 $secretSalt = SimpleSAML\Utils\Config::getSecretSalt();
104
105 if (array_key_exists('Source', $state)) {
106 $srcID = self::getEntityId($state['Source']);
107 } else {
108 $srcID = '';
109 }
110
111 if (array_key_exists('Destination', $state)) {
112 $dstID = self::getEntityId($state['Destination']);
113 } else {
114 $dstID = '';
115 }
116
117 $uidData = 'uidhashbase' . $secretSalt;
118 $uidData .= strlen($srcID) . ':' . $srcID;
119 $uidData .= strlen($dstID) . ':' . $dstID;
120 $uidData .= strlen($userID) . ':' . $userID;
121 $uidData .= $secretSalt;
122
123 $uid = hash('sha1', $uidData);
124
125 if ($this->generateNameId) {
126 // Convert the targeted ID to a SAML 2.0 name identifier element
127 $nameId = new \SAML2\XML\saml\NameID();
128 $nameId->value = $uid;
129 $nameId->Format = \SAML2\Constants::NAMEID_PERSISTENT;
130
131 if (isset($state['Source']['entityid'])) {
132 $nameId->NameQualifier = $state['Source']['entityid'];
133 }
134 if (isset($state['Destination']['entityid'])) {
135 $nameId->SPNameQualifier = $state['Destination']['entityid'];
136 }
137 } else {
138 $nameId = $uid;
139 }
140
141 $state['Attributes']['eduPersonTargetedID'] = array($nameId);
142 }
if(!array_key_exists('stateid', $_REQUEST)) $state
Handle linkback() response from LinkedIn.