ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilAuthContainerECS.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 include_once('Auth/Container.php');
25 
35 {
36  protected $mid = null;
37  protected $abreviation = null;
38 
46  public function __construct($a_params)
47  {
48  parent::__construct(array());
49  $this->initECSServices();
50  }
51 
59  public function getAbreviation()
60  {
61  return $this->abreviation;
62  }
63 
69  public function getMID()
70  {
71  return $this->mid;
72  }
73 
74 
83  public function fetchData($a_username,$a_pass)
84  {
85  global $ilLog;
86 
87  $ilLog->write(__METHOD__.': Starting ECS authentication.');
88 
89  if(!$this->settings->isEnabled())
90  {
91  $ilLog->write(__METHOD__.': ECS settings .');
92  return false;
93  }
94 
95  // Check if hash is valid ...
96  include_once('./Services/WebServices/ECS/classes/class.ilECSConnector.php');
97 
98  try
99  {
100  $connector = new ilECSConnector();
101  $res = $connector->getAuth($_GET['ecs_hash']);
102  $auths = $res->getResult();
103  $this->mid = $auths[0]->mid;
104  $ilLog->write(__METHOD__.': Got mid: '.$this->mid);
105  $this->abreviation = $auths[0]->abr;
106  $ilLog->write(__METHOD__.': Got abr: '.$this->abreviation);
107  /*
108  // Read abbreviation from mid
109  $res = $connector->getMemberships($this->mid);
110  $member = $res->getResult();
111  $this->abbreviation = $member[0]->participants[0]->abr;
112  */
113  return true;
114  }
115  catch(ilECSConnectorException $e)
116  {
117  $ilLog->write(__METHOD__.': Authentication failed with message: '.$e->getMessage());
118  return false;
119  }
120  }
121 
128  private function initECSServices()
129  {
130  include_once('./Services/WebServices/ECS/classes/class.ilECSSettings.php');
131  $this->settings = ilECSSettings::_getInstance();
132  }
133 
134 }
135 
136 
137 ?>