ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilAuthOpenId.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
11class ilAuthOpenId extends Auth
12{
13 private $settings = null;
14
21 public function __construct($a_container,$a_addition_options = array())
22 {
23 parent::__construct(
24 $a_container,
25 $a_addition_options,
26 array($this,'callProvider'),
27 true);
28 $this->setSessionName("_authhttp".md5(CLIENT_ID));
29
30 $this->initAuth();
31 $this->initSettings();
32
33 if(isset($_GET['oid_check_status']))
34 {
35 $_POST['username'] = 'dummy';
36 $_POST['password'] = 'dummy';
37 }
38
39 }
40
49 public function supportsRedirects()
50 {
51 return true;
52 }
53
63 {
64 global $ilCtrl;
65
66 $username = $_POST['oid_username'];
67
68 if(!$this->parseUsername($username,$auth))
69 {
70 return false;
71 }
72
73 $consumer = $this->settings->getConsumer();
74 $oid_auth = $consumer->begin($username);
75
76 if (!$oid_auth)
77 {
78 $auth->status = AUTH_WRONG_LOGIN;
79 return false;
80 }
81
82 include_once 'Auth/OpenID/SReg.php';
84 // Required
85 array('nickname'),
86 // Optional
87 array(
88 'fullname',
89 'dob',
90 'email',
91 'gender',
92 'postcode',
93 'language',
94 'timezone'
95 )
96 );
97
98 if ($sreg_req)
99 {
100 $oid_auth->addExtension($sreg_req);
101 }
102
103 // TODO: Switch openid v. 1,2
104 $url = $oid_auth->redirectURL(ILIAS_HTTP_PATH,$this->settings->getReturnLocation());
106 }
107
112 protected function initSettings()
113 {
114 include_once './Services/OpenId/classes/class.ilOpenIdSettings.php';
115 $this->settings = ilOpenIdSettings::getInstance();
116 $this->settings->initConsumer();
117 }
118
123 protected function parseUsername(&$username,$auth)
124 {
125 if($_POST['oid_provider'])
126 {
127 include_once './Services/OpenId/classes/class.ilOpenIdProviders.php';
128 try
129 {
130 $url = ilOpenIdProviders::getInstance()->getProviderById($_POST['oid_provider'])->getURL();
131 $username = sprintf($url,(string) $username);
132 $GLOBALS['ilLog']->write(__METHOD__.': Using '.$username.' for authentication');
133 return true;
134 }
135 catch(UnexpectedValueException $e)
136 {
137 $GLOBALS['ilLog']->write(__METHOD__.': Unknown provider id given: '.$username);
138 $auth->status = AUTH_WRONG_LOGIN;
139 return false;
140 }
141 }
142 if($this->settings->forcedProviderSelection())
143 {
144 $auth->status = AUTH_WRONG_LOGIN;
145 return false;
146 }
147 $GLOBALS['ilLog']->write(__METHOD__.': Trying openid url: '.$username);
148 return true;
149 }
150}
151?>
const AUTH_WRONG_LOGIN
Returned if container is unable to authenticate user/password pair.
Definition: Auth.php:38
$_GET["client_id"]
static build($required=null, $optional=null, $policy_url=null, $sreg_ns_uri=Auth_OpenID_SREG_NS_URI, $cls='Auth_OpenID_SRegRequest')
Initialize an empty simple registration request.
Definition: SReg.php:176
$username
Definition: Auth.php:175
setSessionName($name='session')
Set name of the session to a customized value.
Definition: Auth.php:656
$status
Definition: Auth.php:168
initAuth()
Init auth object Enable logging, set callbacks...
@classDescription Open ID auth class
callProvider($username, $status, $auth)
Auth login function Redirects to openid provider.
__construct($a_container, $a_addition_options=array())
Contructor.
initSettings()
Init open id settings.
supportsRedirects()
Returns true, if the current auth mode allows redirection to e.g to loginScreen, public section....
parseUsername(&$username, $auth)
Parse username.
static getInstance()
Get singleton instance.
static getInstance()
Get singleton instance.
static redirect($a_script)
http redirect to other script
$_POST['username']
Definition: cron.php:12
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
global $ilCtrl
Definition: ilias.php:18
$url
Definition: shib_logout.php:72