Project

General

Profile

Download (1.25 KB) Statistics
| Branch: | Tag: | Revision:
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 1e0b1727 Phil Davis
		if ($this->state!=SASL_BASIC_STATE_START)
25 2cd8d942 Pierre POMES
		{
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 1e0b1727 Phil Davis
		if ($status==SASL_CONTINUE)
37 2cd8d942 Pierre POMES
		{
38
			$message=$this->credentials["user"].":".$this->credentials["password"];
39
			$this->state=SASL_BASIC_STATE_DONE;
40
		}
41
		else
42 1e0b1727 Phil Davis
		{
43 2cd8d942 Pierre POMES
			Unset($message);
44 1e0b1727 Phil Davis
		}
45 2cd8d942 Pierre POMES
		return($status);
46
	}
47
48
	Function Step(&$client, $response, &$message, &$interactions)
49
	{
50 1e0b1727 Phil Davis
		switch ($this->state)
51 2cd8d942 Pierre POMES
		{
52
			case SASL_BASIC_STATE_DONE:
53
				$client->error="Basic authentication was finished without success";
54
				return(SASL_FAIL);
55
			default:
56
				$client->error="invalid Basic authentication step state";
57
				return(SASL_FAIL);
58
		}
59
		return(SASL_CONTINUE);
60
	}
61
};
62
63
?>