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
5include_once './Services/Authentication/classes/Provider/class.ilAuthProvider.php';
6include_once './Services/Authentication/interfaces/interface.ilAuthProviderInterface.php';
7include_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?>
$result
An exception for terminatinating execution or to throw for unit testing.
const AUTH_RADIUS
Description of class class.
createNewAccount(\ilAuthStatus $status)
create new account
__construct(\ilAuthCredentials $credentials)
getTriggerAuthMode()
get trigger auth mode
doAuthentication(\ilAuthStatus $status)
do authentication
getExternalAccountName()
get external account name
getUserAuthModeName()
get user auth mode name
migrateAccount(ilAuthStatus $status)
Migrate existing account to radius authentication Create new account..
Base class for authentication providers (radius, ldap, apache, ...)
getLogger()
Get logger.
handleAuthenticationFail(ilAuthStatus $status, $a_reason)
Handle failed authentication.
Auth status implementation.
setStatus($a_status)
Set auth status.
static _lookupId($a_user_str)
Lookup id by login.
static _checkExternalAuthAccount($a_auth, $a_account)
check whether external account and authentication method matches with a user
static _getInstance()
singleton get instance
$server
Interface of auth credentials.
Standard interface for auth provider implementations.
settings()
Definition: settings.php:2