1 |
2cd8d942
|
Pierre POMES
|
<?php
|
2 |
|
|
/*
|
3 |
|
|
* basic_sasl_client.php
|
4 |
|
|
*
|
5 |
|
|
* @(#) $Id: basic_sasl_client.php,v 1.1 2004/11/17 08:01:23 mlemos Exp $
|
6 |
|
|
*
|
7 |
|
|
*/
|
8 |
|
|
|
9 |
|
|
define("SASL_BASIC_STATE_START", 0);
|
10 |
|
|
define("SASL_BASIC_STATE_DONE", 1);
|
11 |
|
|
|
12 |
|
|
class basic_sasl_client_class
|
13 |
|
|
{
|
14 |
|
|
var $credentials=array();
|
15 |
|
|
var $state=SASL_BASIC_STATE_START;
|
16 |
|
|
|
17 |
|
|
Function Initialize(&$client)
|
18 |
|
|
{
|
19 |
|
|
return(1);
|
20 |
|
|
}
|
21 |
|
|
|
22 |
|
|
Function Start(&$client, &$message, &$interactions)
|
23 |
|
|
{
|
24 |
|
|
if($this->state!=SASL_BASIC_STATE_START)
|
25 |
|
|
{
|
26 |
|
|
$client->error="Basic authentication state is not at the start";
|
27 |
|
|
return(SASL_FAIL);
|
28 |
|
|
}
|
29 |
|
|
$this->credentials=array(
|
30 |
|
|
"user"=>"",
|
31 |
|
|
"password"=>""
|
32 |
|
|
);
|
33 |
|
|
$defaults=array(
|
34 |
|
|
);
|
35 |
|
|
$status=$client->GetCredentials($this->credentials,$defaults,$interactions);
|
36 |
|
|
if($status==SASL_CONTINUE)
|
37 |
|
|
{
|
38 |
|
|
$message=$this->credentials["user"].":".$this->credentials["password"];
|
39 |
|
|
$this->state=SASL_BASIC_STATE_DONE;
|
40 |
|
|
}
|
41 |
|
|
else
|
42 |
|
|
Unset($message);
|
43 |
|
|
return($status);
|
44 |
|
|
}
|
45 |
|
|
|
46 |
|
|
Function Step(&$client, $response, &$message, &$interactions)
|
47 |
|
|
{
|
48 |
|
|
switch($this->state)
|
49 |
|
|
{
|
50 |
|
|
case SASL_BASIC_STATE_DONE:
|
51 |
|
|
$client->error="Basic authentication was finished without success";
|
52 |
|
|
return(SASL_FAIL);
|
53 |
|
|
default:
|
54 |
|
|
$client->error="invalid Basic authentication step state";
|
55 |
|
|
return(SASL_FAIL);
|
56 |
|
|
}
|
57 |
|
|
return(SASL_CONTINUE);
|
58 |
|
|
}
|
59 |
|
|
};
|
60 |
|
|
|
61 |
|
|
?>
|