ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilAuthBase.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 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 
33 abstract class ilAuthBase
34 {
35  // Used for SOAP Auth
36  // TODO: Find another solution
37  protected $sub_status = null;
38 
44  public function supportRedirects()
45  {
46  return true;
47  }
48 
53  public final function getContainer()
54  {
55  return $this->storage;
56  }
57 
63  protected final function initAuth()
64  {
66 
67  //$this->enableLogging = true;
68  $this->enableLogging = false;
69 
70  if ($this->enableLogging)
71  {
72  $GLOBALS['ilLog']->write(__METHOD__.': Init callbacks');
73  }
74  $this->setLoginCallback(array($this,'loginObserver'));
75  $this->setFailedLoginCallback(array($this,'failedLoginObserver'));
76  $this->setCheckAuthCallback(array($this,'checkAuthObserver'));
77  $this->setLogoutCallback(array($this,'logoutObserver'));
78 
79  include_once('Services/Authentication/classes/class.ilAuthLogObserver.php');
80  $this->attachLogObserver(new ilAuthLogObserver(AUTH_LOG_INFO));
81 
82  }
83 
90  protected function loginObserver($a_username,$a_auth)
91  {
92  ilSessionControl::handleLoginEvent($a_username, $a_auth);
93 
94  global $ilLog, $ilAppEventHandler;
95 
96  if($this->getContainer()->loginObserver($a_username,$a_auth))
97  {
98  $ilAppEventHandler->raise("Services/Authentication", "afterLogin",
99  array("username" => $a_auth->getUsername()));
100 
101  $ilLog->write(__METHOD__.': logged in as '.$a_auth->getUsername().
102  ', remote:'.$_SERVER['REMOTE_ADDR'].':'.$_SERVER['REMOTE_PORT'].
103  ', server:'.$_SERVER['SERVER_ADDR'].':'.$_SERVER['SERVER_PORT']
104  );
105  }
106 
107  }
108 
109 
116  protected function failedLoginObserver($a_username,$a_auth)
117  {
118  global $ilLog;
119 
120  $ilLog->write(__METHOD__.': login failed for user '.$a_username.
121  ', remote:'.$_SERVER['REMOTE_ADDR'].':'.$_SERVER['REMOTE_PORT'].
122  ', server:'.$_SERVER['SERVER_ADDR'].':'.$_SERVER['SERVER_PORT']
123  );
124  return $this->getContainer()->failedLoginObserver($a_username,$a_auth);
125  }
126 
133  protected function checkAuthObserver($a_username,$a_auth)
134  {
135  #$GLOBALS['ilLog']->write(__METHOD__.': Check auth observer called');
136  return $this->getContainer()->checkAuthObserver($a_username,$a_auth);
137  }
138 
145  protected function logoutObserver($a_username,$a_auth)
146  {
148 
149  $GLOBALS['ilLog']->write(__METHOD__.': Logout observer called');
150  $this->getContainer()->logoutObserver($a_username,$a_auth);
151  }
152 
153 }
154 ?>