4 include_once
'Auth/Container.php';
38 public function fetchData($a_username,$a_password,$isChallengeResponse =
false)
42 $ilLog->write(__METHOD__.
': Fetch Data called');
44 $response = $this->settings->getConsumer()->complete($this->settings->getReturnLocation());
46 switch($response->status)
49 die(
"Auth cancelled");
52 die(
"Auth failed with message: ".$response->message);
55 $openid = $response->getDisplayIdentifier();
56 $esc_identity = htmlentities($openid);
57 $ilLog->write(__METHOD__.
': Auth success with identity '.$esc_identity);
59 if($response->endpoint->canonicalID)
61 $escaped_canonicalID = htmlentities($response->endpoint->canonicalID);
62 $ilLog->write(__METHOD__.
': Auth success with canonical id: '.$esc_identity);
65 include_once
'Auth/OpenID/SReg.php';
71 $this->response_data = $sreg_resp->contents();
74 $ilLog->write(__METHOD__.
' auth data: '.print_r($this->response_data,
true));
80 foreach($response->message->args->keys as $key => $mapping)
82 if($mapping[1] ==
'sreg.nickname')
84 $this->response_data[
'nickname'] = $response->message->args->values[$key];
86 if($mapping[1] ==
'sreg.email')
88 $this->response_data[
'email'] = $response->message->args->values[$key];
107 $this->force_creation =
true;
118 $GLOBALS[
'ilLog']->write(__METHOD__.
': Login observer called for openid');
123 $this->response_data[
'nickname']
125 if(!$this->response_data[
'ilInternalAccount'])
127 if($this->settings->isCreationEnabled())
129 if($this->settings->isAccountMigrationEnabled() and !$this->force_creation and !
$_SESSION[
'force_creation'])
133 $_SESSION[
'tmp_oid_username'] = urldecode(
$_GET[
'openid_identity']);
135 $_SESSION[
'tmp_external_account'] = $this->response_data[
'nickname'];
137 $_SESSION[
'tmp_roles'] = array(0 => $this->settings->getDefaultRole());
139 $GLOBALS[
'ilLog']->write(__METHOD__.
': Redirect migration');
140 ilUtil::redirect(
'ilias.php?baseClass=ilStartUpGUI&cmd=showAccountMigration&cmdClass=ilstartupgui');
143 include_once
'./Services/OpenId/classes/class.ilOpenIdAttributeToUser.php';
145 $new_name =
$new_user->create($this->response_data[
'nickname'],$this->response_data);
147 $GLOBALS[
'ilLog']->write(__METHOD__.
': Create user with name:'. $new_name);
148 $a_auth->setAuth($new_name);
156 $GLOBALS[
'ilLog']->write(__METHOD__.
': No creation');
163 $GLOBALS[
'ilLog']->write(__METHOD__.
': Using old name: ' . $this->response_data[
'ilInternalAccount']);
164 $a_auth->setAuth($this->response_data[
'ilInternalAccount']);
176 include_once
'./Services/OpenId/classes/class.ilOpenIdSettings.php';
179 $this->settings->initConsumer();