Permalink
Browse files

Ticket #3734: Retire smtp.inc, sasl.inc and *sasl_client.inc in favor…

… of pear-Mail port
  • Loading branch information...
1 parent d4c5ada commit 626ff13a0eb92f539f7860314235ba8d0cf70ad2 @rbgarga rbgarga committed Aug 11, 2016
@@ -1,61 +0,0 @@
-<?php
-/*
- * basic_sasl_client.php
- *
- * @(#) $Id: basic_sasl_client.php,v 1.1 2004/11/17 08:01:23 mlemos Exp $
- *
- */
-
-define("SASL_BASIC_STATE_START", 0);
-define("SASL_BASIC_STATE_DONE", 1);
-
-class basic_sasl_client_class
-{
- var $credentials=array();
- var $state=SASL_BASIC_STATE_START;
-
- Function Initialize(&$client)
- {
- return(1);
- }
-
- Function Start(&$client, &$message, &$interactions)
- {
- if($this->state!=SASL_BASIC_STATE_START)
- {
- $client->error="Basic authentication state is not at the start";
- return(SASL_FAIL);
- }
- $this->credentials=array(
- "user"=>"",
- "password"=>""
- );
- $defaults=array(
- );
- $status=$client->GetCredentials($this->credentials,$defaults,$interactions);
- if($status==SASL_CONTINUE)
- {
- $message=$this->credentials["user"].":".$this->credentials["password"];
- $this->state=SASL_BASIC_STATE_DONE;
- }
- else
- Unset($message);
- return($status);
- }
-
- Function Step(&$client, $response, &$message, &$interactions)
- {
- switch($this->state)
- {
- case SASL_BASIC_STATE_DONE:
- $client->error="Basic authentication was finished without success";
- return(SASL_FAIL);
- default:
- $client->error="invalid Basic authentication step state";
- return(SASL_FAIL);
- }
- return(SASL_CONTINUE);
- }
-};
-
-?>
@@ -1,67 +0,0 @@
-<?php
-/*
- * cram_md5_sasl_client.php
- *
- * @(#) $Id: cram_md5_sasl_client.php,v 1.3 2004/11/17 08:00:37 mlemos Exp $
- *
- */
-
-define("SASL_CRAM_MD5_STATE_START", 0);
-define("SASL_CRAM_MD5_STATE_RESPOND_CHALLENGE", 1);
-define("SASL_CRAM_MD5_STATE_DONE", 2);
-
-class cram_md5_sasl_client_class
-{
- var $credentials=array();
- var $state=SASL_CRAM_MD5_STATE_START;
-
- Function Initialize(&$client)
- {
- return(1);
- }
-
- Function HMACMD5($key,$text)
- {
- $key=(strlen($key)<64 ? str_pad($key,64,"\0") : substr($key,0,64));
- return(md5((str_repeat("\x5c", 64)^$key).pack("H32", md5((str_repeat("\x36", 64)^$key).$text))));
- }
-
- Function Start(&$client, &$message, &$interactions)
- {
- if($this->state!=SASL_CRAM_MD5_STATE_START)
- {
- $client->error="CRAM-MD5 authentication state is not at the start";
- return(SASL_FAIL);
- }
- $this->credentials=array(
- "user"=>"",
- "password"=>""
- );
- $defaults=array();
- $status=$client->GetCredentials($this->credentials,$defaults,$interactions);
- if($status==SASL_CONTINUE)
- $this->state=SASL_CRAM_MD5_STATE_RESPOND_CHALLENGE;
- Unset($message);
- return($status);
- }
-
- Function Step(&$client, $response, &$message, &$interactions)
- {
- switch($this->state)
- {
- case SASL_CRAM_MD5_STATE_RESPOND_CHALLENGE:
- $message=$this->credentials["user"]." ".$this->HMACMD5($this->credentials["password"], $response);
- $this->state=SASL_CRAM_MD5_STATE_DONE;
- break;
- case SASL_CRAM_MD5_STATE_DONE:
- $client->error="CRAM-MD5 authentication was finished without success";
- return(SASL_FAIL);
- default:
- $client->error="invalid CRAM-MD5 authentication step state";
- return(SASL_FAIL);
- }
- return(SASL_CONTINUE);
- }
-};
-
-?>
@@ -1,135 +0,0 @@
-<?php
-/*
- * digest_sasl_client.php
- *
- * @(#) $Id: digest_sasl_client.php,v 1.1 2005/10/27 05:24:15 mlemos Exp $
- *
- */
-
-define('SASL_DIGEST_STATE_START', 0);
-define('SASL_DIGEST_STATE_RESPOND_CHALLENGE', 1);
-define('SASL_DIGEST_STATE_DONE', 2);
-
-class digest_sasl_client_class
-{
- var $credentials=array();
- var $state=SASL_DIGEST_STATE_START;
-
- Function unq($string)
- {
- return(($string[0]=='"' && $string[strlen($string)-1]=='"') ? substr($string, 1, strlen($string)-2) : $string);
- }
-
- Function H($data)
- {
- return md5($data);
- }
-
- Function KD($secret, $data)
- {
- return $this->H($secret.':'.$data);
- }
-
- Function Initialize(&$client)
- {
- return(1);
- }
-
- Function Start(&$client, &$message, &$interactions)
- {
- if($this->state!=SASL_DIGEST_STATE_START)
- {
- $client->error='Digest authentication state is not at the start';
- return(SASL_FAIL);
- }
- $this->credentials=array(
- 'user'=>'',
- 'password'=>'',
- 'uri'=>'',
- 'method'=>'',
- 'session'=>''
- );
- $defaults=array();
- $status=$client->GetCredentials($this->credentials,$defaults,$interactions);
- if($status==SASL_CONTINUE)
- $this->state=SASL_DIGEST_STATE_RESPOND_CHALLENGE;
- Unset($message);
- return($status);
- }
-
- Function Step(&$client, $response, &$message, &$interactions)
- {
- switch($this->state)
- {
- case SASL_DIGEST_STATE_RESPOND_CHALLENGE:
- $values=explode(',',$response);
- $parameters=array();
- for($v=0; $v<count($values); $v++)
- $parameters[strtok(trim($values[$v]), '=')]=strtok('');
-
- $message='username="'.$this->credentials['user'].'"';
- if(!IsSet($parameters[$p='realm'])
- && !IsSet($parameters[$p='nonce']))
- {
- $client->error='Digest authentication parameter '.$p.' is missing from the server response';
- return(SASL_FAIL);
- }
- $message.=', realm='.$parameters['realm'];
- $message.=', nonce='.$parameters['nonce'];
- $message.=', uri="'.$this->credentials['uri'].'"';
- if(IsSet($parameters['algorithm']))
- {
- $algorithm=$this->unq($parameters['algorithm']);
- $message.=', algorithm='.$parameters['algorithm'];
- }
- else
- $algorithm='';
-
- $realm=$this->unq($parameters['realm']);
- $nonce=$this->unq($parameters['nonce']);
- if(IsSet($parameters['qop']))
- {
- switch($qop=$this->unq($parameters['qop']))
- {
- case "auth":
- $cnonce=$this->credentials['session'];
- break;
- default:
- $client->error='Digest authentication quality of protection '.$qop.' is not yet supported';
- return(SASL_FAIL);
- }
- }
- $nc_value='00000001';
- if(IsSet($parameters['qop'])
- && !strcmp($algorithm, 'MD5-sess'))
- $A1=$this->H($this->credentials['user'].':'. $realm.':'. $this->credentials['password']).':'.$nonce.':'.$cnonce;
- else
- $A1=$this->credentials['user'].':'. $realm.':'. $this->credentials['password'];
- $A2=$this->credentials['method'].':'.$this->credentials['uri'];
- if(IsSet($parameters['qop']))
- $response=$this->KD($this->H($A1), $nonce.':'. $nc_value.':'. $cnonce.':'. $qop.':'. $this->H($A2));
- else
- $response=$this->KD($this->H($A1), $nonce.':'. $this->H($A2));
- $message.=', response="'.$response.'"';
- if(IsSet($parameters['opaque']))
- $message.=', opaque='.$parameters['opaque'];
- if(IsSet($parameters['qop']))
- $message.=', qop="'.$qop.'"';
- $message.=', nc='.$nc_value;
- if(IsSet($parameters['qop']))
- $message.=', cnonce="'.$cnonce.'"';
- $client->encode_response=0;
- $this->state=SASL_DIGEST_STATE_DONE;
- break;
- case SASL_DIGEST_STATE_DONE:
- $client->error='Digest authentication was finished without success';
- return(SASL_FAIL);
- default:
- $client->error='invalid Digest authentication step state';
- return(SASL_FAIL);
- }
- return(SASL_CONTINUE);
- }
-};
-
-?>
@@ -1,69 +0,0 @@
-<?php
-/*
- * login_sasl_client.php
- *
- * @(#) $Id: login_sasl_client.php,v 1.2 2004/11/17 08:00:37 mlemos Exp $
- *
- */
-
-define("SASL_LOGIN_STATE_START", 0);
-define("SASL_LOGIN_STATE_IDENTIFY_USER", 1);
-define("SASL_LOGIN_STATE_IDENTIFY_PASSWORD", 2);
-define("SASL_LOGIN_STATE_DONE", 3);
-
-class login_sasl_client_class
-{
- var $credentials=array();
- var $state=SASL_LOGIN_STATE_START;
-
- Function Initialize(&$client)
- {
- return(1);
- }
-
- Function Start(&$client, &$message, &$interactions)
- {
- if($this->state!=SASL_LOGIN_STATE_START)
- {
- $client->error="LOGIN authentication state is not at the start";
- return(SASL_FAIL);
- }
- $this->credentials=array(
- "user"=>"",
- "password"=>"",
- "realm"=>""
- );
- $defaults=array(
- "realm"=>""
- );
- $status=$client->GetCredentials($this->credentials,$defaults,$interactions);
- if($status==SASL_CONTINUE)
- $this->state=SASL_LOGIN_STATE_IDENTIFY_USER;
- Unset($message);
- return($status);
- }
-
- Function Step(&$client, $response, &$message, &$interactions)
- {
- switch($this->state)
- {
- case SASL_LOGIN_STATE_IDENTIFY_USER:
- $message=$this->credentials["user"].(strlen($this->credentials["realm"]) ? "@".$this->credentials["realm"] : "");
- $this->state=SASL_LOGIN_STATE_IDENTIFY_PASSWORD;
- break;
- case SASL_LOGIN_STATE_IDENTIFY_PASSWORD:
- $message=$this->credentials["password"];
- $this->state=SASL_LOGIN_STATE_DONE;
- break;
- case SASL_LOGIN_STATE_DONE:
- $client->error="LOGIN authentication was finished without success";
- break;
- default:
- $client->error="invalid LOGIN authentication step state";
- return(SASL_FAIL);
- }
- return(SASL_CONTINUE);
- }
-};
-
-?>
Oops, something went wrong.

0 comments on commit 626ff13

Please sign in to comment.