ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilAuthProviderRadius.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once './Services/Authentication/classes/Provider/class.ilAuthProvider.php';
6 include_once './Services/Authentication/interfaces/interface.ilAuthProviderInterface.php';
7 include_once './Services/Authentication/interfaces/interface.ilAuthProviderAccountMigrationInterface.php';
8 
16 {
17  const CONNECT_TIMEOUT = 3;
18  const RETRIES = 1;
19 
23  private $settings = null;
24 
25  private $external_account = '';
26 
27 
29  {
30  parent::__construct($credentials);
31 
32  include_once './Services/Radius/classes/class.ilRadiusSettings.php';
34  }
35 
36 
42  {
43 
44  }
45 
51  {
52  $radius = radius_auth_open();
53 
54  foreach($this->settings->getServers() as $server)
55  {
56  $this->getLogger()->debug('Using: ' . $server.':'. $this->settings->getPort());
57  radius_add_server(
58  $radius,
59  trim($server),
60  $this->settings->getPort(),
61  $this->settings->getSecret(),
62  self::CONNECT_TIMEOUT,
63  self::RETRIES
64  );
65  }
66 
67  radius_create_request($radius, RADIUS_ACCESS_REQUEST);
68  radius_put_attr($radius, RADIUS_USER_NAME, $this->getCredentials()->getUsername());
69  radius_put_attr($radius, RADIUS_USER_PASSWORD, $this->getCredentials()->getPassword());
70 
71  $this->getLogger()->debug('username: ' . $this->getCredentials()->getUsername());
72 
73  $result = radius_send_request($radius);
74 
75  switch($result)
76  {
77  case RADIUS_ACCESS_ACCEPT:
78  $this->getLogger()->info('Radius authentication successful.');
80 
81  $local_login = ilObjUser::_checkExternalAuthAccount('radius',$this->getCredentials()->getUsername());
82  $status->setAuthenticatedUserId(ilObjUser::_lookupId($local_login));
83  return true;
84 
85  case RADIUS_ACCESS_REJECT:
86  $this->getLogger()->info('Radius authentication rejected with message: ' . radius_strerror($radius));
87  $this->handleAuthenticationFail($status, 'err_wrong_login');
88  return false;
89 
90  case RADIUS_ACCESS_CHALLENGE:
91  $this->getLogger()->info('Radius authentication failed (access challenge): ' . radius_strerror($radius));
92  $this->handleAuthenticationFail($status, 'err_wrong_login');
93  return false;
94 
95  default:
96  $this->getLogger()->error('Radius authentication failed with message: ' . radius_strerror($radius));
97  $this->handleAuthenticationFail($status, 'err_wrong_login');
98  return false;
99  }
100  }
101 
106  public function getExternalAccountName()
107  {
109  }
110 
115  public function getTriggerAuthMode()
116  {
117  return AUTH_RADIUS;
118  }
119 
124  public function getUserAuthModeName()
125  {
126  return 'radius';
127  }
128 
134  {
135 
136  }
137 
138 }
139 ?>
Interface of auth credentials.
getExternalAccountName()
get external account name
$result
getUserAuthModeName()
get user auth mode name
Description of class class.
createNewAccount(\ilAuthStatus $status)
create new account
static _lookupId($a_user_str)
Lookup id by login.
setAuthenticatedUserId($a_id)
__construct(\ilAuthCredentials $credentials)
Base class for authentication providers (radius, ldap, apache, ...)
Standard interface for auth provider implementations.
setStatus($a_status)
Set auth status.
doAuthentication(\ilAuthStatus $status)
do authentication
static _getInstance()
singleton get instance
getLogger()
Get logger.
$server
settings()
Definition: settings.php:2
static _checkExternalAuthAccount($a_auth, $a_account)
check whether external account and authentication method matches with a user
handleAuthenticationFail(ilAuthStatus $status, $a_reason)
Handle failed authentication.
getTriggerAuthMode()
get trigger auth mode
Auth status implementation.
migrateAccount(ilAuthStatus $status)
Migrate existing account to radius authentication Create new account..
const AUTH_RADIUS