| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package VikBooking |
| 4 |
* @subpackage com_vikbooking |
| 5 |
* @author Alessio Gaggii - e4j - Extensionsforjoomla.com |
| 6 |
* @copyright Copyright (C) 2018 e4j - Extensionsforjoomla.com. All rights reserved. |
| 7 |
* @license GNU General Public License version 2 or later; see LICENSE |
| 8 |
* @link https://vikwp.com |
| 9 |
*/ |
| 10 |
|
| 11 |
defined('ABSPATH') or die('No script kiddies please!'); |
| 12 |
|
| 13 |
define("SASL_LOGIN_STATE_START", 0); |
| 14 |
define("SASL_LOGIN_STATE_IDENTIFY_USER", 1); |
| 15 |
define("SASL_LOGIN_STATE_IDENTIFY_PASSWORD", 2); |
| 16 |
define("SASL_LOGIN_STATE_DONE", 3); |
| 17 |
|
| 18 |
class login_sasl_client_class |
| 19 |
{ |
| 20 |
var $credentials=array(); |
| 21 |
var $state=SASL_LOGIN_STATE_START; |
| 22 |
|
| 23 |
Function Initialize(&$client) |
| 24 |
{ |
| 25 |
return(1); |
| 26 |
} |
| 27 |
|
| 28 |
Function Start(&$client, &$message, &$interactions) |
| 29 |
{ |
| 30 |
if($this->state!=SASL_LOGIN_STATE_START) |
| 31 |
{ |
| 32 |
$client->error="LOGIN authentication state is not at the start"; |
| 33 |
return(SASL_FAIL); |
| 34 |
} |
| 35 |
$this->credentials=array( |
| 36 |
"user"=>"", |
| 37 |
"password"=>"", |
| 38 |
"realm"=>"" |
| 39 |
); |
| 40 |
$defaults=array( |
| 41 |
"realm"=>"" |
| 42 |
); |
| 43 |
$status=$client->GetCredentials($this->credentials,$defaults,$interactions); |
| 44 |
if($status==SASL_CONTINUE) |
| 45 |
$this->state=SASL_LOGIN_STATE_IDENTIFY_USER; |
| 46 |
Unset($message); |
| 47 |
return($status); |
| 48 |
} |
| 49 |
|
| 50 |
Function Step(&$client, $response, &$message, &$interactions) |
| 51 |
{ |
| 52 |
switch($this->state) |
| 53 |
{ |
| 54 |
case SASL_LOGIN_STATE_IDENTIFY_USER: |
| 55 |
$message=$this->credentials["user"].(strlen($this->credentials["realm"]) ? "@".$this->credentials["realm"] : ""); |
| 56 |
$this->state=SASL_LOGIN_STATE_IDENTIFY_PASSWORD; |
| 57 |
break; |
| 58 |
case SASL_LOGIN_STATE_IDENTIFY_PASSWORD: |
| 59 |
$message=$this->credentials["password"]; |
| 60 |
$this->state=SASL_LOGIN_STATE_DONE; |
| 61 |
break; |
| 62 |
case SASL_LOGIN_STATE_DONE: |
| 63 |
$client->error="LOGIN authentication was finished without success"; |
| 64 |
break; |
| 65 |
default: |
| 66 |
$client->error="invalid LOGIN authentication step state"; |
| 67 |
return(SASL_FAIL); |
| 68 |
} |
| 69 |
return(SASL_CONTINUE); |
| 70 |
} |
| 71 |
}; |
| 72 |
|
| 73 |
?> |