From 89b7a21d679fdecfb0660facdb798b85834d677c Mon Sep 17 00:00:00 2001 From: Renato Botelho Date: Fri, 15 Jan 2016 11:14:36 -0200 Subject: Update sasl classes to last version and remove all style customizations - http://www.phpclasses.org/package/1888-PHP-Single-API-for-standard-authentication-mechanisms.html --- src/etc/inc/basic_sasl_client.inc | 8 +++----- src/etc/inc/login_sasl_client.inc | 6 +++--- src/etc/inc/ntlm_sasl_client.inc | 26 +++++++++++++------------- src/etc/inc/plain_sasl_client.inc | 10 +++++----- src/etc/inc/sasl.inc | 4 ++-- 5 files changed, 26 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/etc/inc/basic_sasl_client.inc b/src/etc/inc/basic_sasl_client.inc index c817664..b2972b5 100644 --- a/src/etc/inc/basic_sasl_client.inc +++ b/src/etc/inc/basic_sasl_client.inc @@ -21,7 +21,7 @@ class basic_sasl_client_class Function Start(&$client, &$message, &$interactions) { - if ($this->state!=SASL_BASIC_STATE_START) + if($this->state!=SASL_BASIC_STATE_START) { $client->error="Basic authentication state is not at the start"; return(SASL_FAIL); @@ -33,21 +33,19 @@ class basic_sasl_client_class $defaults=array( ); $status=$client->GetCredentials($this->credentials,$defaults,$interactions); - if ($status==SASL_CONTINUE) + 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) + switch($this->state) { case SASL_BASIC_STATE_DONE: $client->error="Basic authentication was finished without success"; diff --git a/src/etc/inc/login_sasl_client.inc b/src/etc/inc/login_sasl_client.inc index f5cc050..923d16e 100644 --- a/src/etc/inc/login_sasl_client.inc +++ b/src/etc/inc/login_sasl_client.inc @@ -23,7 +23,7 @@ class login_sasl_client_class Function Start(&$client, &$message, &$interactions) { - if ($this->state!=SASL_LOGIN_STATE_START) + if($this->state!=SASL_LOGIN_STATE_START) { $client->error="LOGIN authentication state is not at the start"; return(SASL_FAIL); @@ -37,7 +37,7 @@ class login_sasl_client_class "realm"=>"" ); $status=$client->GetCredentials($this->credentials,$defaults,$interactions); - if ($status==SASL_CONTINUE) + if($status==SASL_CONTINUE) $this->state=SASL_LOGIN_STATE_IDENTIFY_USER; Unset($message); return($status); @@ -45,7 +45,7 @@ class login_sasl_client_class Function Step(&$client, $response, &$message, &$interactions) { - switch ($this->state) + switch($this->state) { case SASL_LOGIN_STATE_IDENTIFY_USER: $message=$this->credentials["user"].(strlen($this->credentials["realm"]) ? "@".$this->credentials["realm"] : ""); diff --git a/src/etc/inc/ntlm_sasl_client.inc b/src/etc/inc/ntlm_sasl_client.inc index 18e5658..406edf2 100644 --- a/src/etc/inc/ntlm_sasl_client.inc +++ b/src/etc/inc/ntlm_sasl_client.inc @@ -18,12 +18,12 @@ class ntlm_sasl_client_class Function Initialize(&$client) { - if (!function_exists($function="mcrypt_encrypt") || - !function_exists($function="hash")) + if(!function_exists($function="mcrypt_encrypt") + || !function_exists($function="mhash")) { $extensions=array( "mcrypt_encrypt"=>"mcrypt", - "hash"=>"hash" + "mhash"=>"mhash" ); $client->error="the extension ".$extensions[$function]." required by the NTLM SASL client class is not available in this PHP configuration"; return(0); @@ -33,7 +33,7 @@ class ntlm_sasl_client_class Function ASCIIToUnicode($ascii) { - for ($unicode="",$a=0;$aASCIIToUnicode($password); - $md4=hash("md4", $unicode); + $md4=mhash(MHASH_MD4,$unicode); $padded=$md4.str_repeat(chr(0),21-strlen($md4)); $iv_size=mcrypt_get_iv_size(MCRYPT_DES,MCRYPT_MODE_ECB); $iv=mcrypt_create_iv($iv_size,MCRYPT_RAND); - for ($response="",$third=0;$third<21;$third+=7) + for($response="",$third=0;$third<21;$third+=7) { - for ($packed="",$p=$third;$p<$third+7;$p++) - $packed.=str_pad(decbin(ord(substr($padded,$p,1))),8,"0",STR_PAD_LEFT); - for ($key="",$p=0;$pstate!=SASL_NTLM_STATE_START) + if($this->state!=SASL_NTLM_STATE_START) { $client->error="NTLM authentication state is not at the start"; return(SASL_FAIL); @@ -147,7 +147,7 @@ class ntlm_sasl_client_class ); $defaults=array(); $status=$client->GetCredentials($this->credentials,$defaults,$interactions); - if ($status==SASL_CONTINUE) + if($status==SASL_CONTINUE) $this->state=SASL_NTLM_STATE_IDENTIFY_DOMAIN; Unset($message); return($status); @@ -155,7 +155,7 @@ class ntlm_sasl_client_class Function Step(&$client, $response, &$message, &$interactions) { - switch ($this->state) + switch($this->state) { case SASL_NTLM_STATE_IDENTIFY_DOMAIN: $message=$this->TypeMsg1($this->credentials["realm"],$this->credentials["workstation"]); @@ -177,4 +177,4 @@ class ntlm_sasl_client_class } }; -?> +?> \ No newline at end of file diff --git a/src/etc/inc/plain_sasl_client.inc b/src/etc/inc/plain_sasl_client.inc index 691580c..c7feed0 100644 --- a/src/etc/inc/plain_sasl_client.inc +++ b/src/etc/inc/plain_sasl_client.inc @@ -26,7 +26,7 @@ class plain_sasl_client_class Function Start(&$client, &$message, &$interactions) { - if ($this->state!=SASL_PLAIN_STATE_START) + if($this->state!=SASL_PLAIN_STATE_START) { $client->error="PLAIN authentication state is not at the start"; return(SASL_FAIL); @@ -42,9 +42,9 @@ class plain_sasl_client_class "mode"=>"" ); $status=$client->GetCredentials($this->credentials,$defaults,$interactions); - if ($status==SASL_CONTINUE) + if($status==SASL_CONTINUE) { - switch ($this->credentials["mode"]) + switch($this->credentials["mode"]) { case SASL_PLAIN_EXIM_MODE: $message=$this->credentials["user"]."\0".$this->credentials["password"]."\0"; @@ -65,11 +65,11 @@ class plain_sasl_client_class Function Step(&$client, $response, &$message, &$interactions) { - switch ($this->state) + switch($this->state) { /* case SASL_PLAIN_STATE_IDENTIFY: - switch ($this->credentials["mode"]) + switch($this->credentials["mode"]) { case SASL_PLAIN_EXIM_MODE: $message=$this->credentials["user"]."\0".$this->credentials["password"]."\0"; diff --git a/src/etc/inc/sasl.inc b/src/etc/inc/sasl.inc index a9582da..f6a8d0b 100644 --- a/src/etc/inc/sasl.inc +++ b/src/etc/inc/sasl.inc @@ -178,7 +178,7 @@ class sasl_client_class Retrieve the values of one or more credentials to be used by the authentication mechanism classes. This is meant to be used by authentication mechanism driver - classes to retrieve the credentials that may be needed. + classes to retrieve the credentials that may be neede. The function may return SASL_CONTINUE if it succeeded, or SASL_NOMECH if it was not possible to retrieve one of the requested credentials. @@ -359,7 +359,7 @@ class sasl_client_class INTEGER Process the authentication steps after the initial step, - until the authentication iteration dialog is complete. + until the authetication iteration dialog is complete. Call this function iteratively after a successful initial step calling the Start function. The function returns SASL_CONTINUE if step was -- cgit v1.1