29 require_once
"Auth/Container.php";
33 require_once
"Auth/RADIUS.php";
83 $this->authtype =
'PAP';
85 $this->authtype =
$options[
'authtype'];
88 if (!class_exists($classname)) {
93 $this->radius =
new $classname;
96 $this->radius->setConfigfile(
$options[
'configfile']);
100 if (is_array($servers)) {
101 foreach ($servers as
$server) {
102 $servername = $server[0];
103 $port = isset($server[1]) ? $server[1] : 0;
104 $sharedsecret = isset($server[2]) ? $server[2] :
'testing123';
105 $timeout = isset($server[3]) ? $server[3] : 3;
106 $maxtries = isset($server[4]) ? $server[4] : 3;
107 $this->radius->addServer($servername, $port, $sharedsecret, $timeout, $maxtries);
111 if (!$this->radius->start()) {
126 function fetchData($username, $password, $challenge = null)
130 switch($this->authtype) {
133 if (isset($challenge)) {
134 $this->radius->challenge = $challenge;
135 $this->radius->chapid = 1;
136 $this->radius->response = pack(
'H*', $password);
138 require_once
'Crypt/CHAP.php';
140 $crpt =
new $classname;
141 $crpt->password = $password;
142 $this->radius->challenge = $crpt->challenge;
143 $this->radius->chapid = $crpt->chapid;
144 $this->radius->response = $crpt->challengeResponse();
149 require_once
'Crypt/CHAP.php';
150 $crpt =
new Crypt_MSCHAPv2;
151 $crpt->username = $username;
152 $crpt->password = $password;
153 $this->radius->challenge = $crpt->authChallenge;
154 $this->radius->peerChallenge = $crpt->peerChallenge;
155 $this->radius->chapid = $crpt->chapid;
156 $this->radius->response = $crpt->challengeResponse();
160 $this->radius->password = $password;
164 $this->radius->username = $username;
166 $this->radius->putAuthAttributes();
167 $result = $this->radius->send();
172 $this->radius->getAttributes();