• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List

E:/E/GEAMP/www/openbiz/openbiz/bin/service/authService.php

00001 <?php
00017 /*
00018  * modified by Jixian 2009-07-12
00019  * for suport password encryption storage 
00020  * supported algos:
00021  * Algos                                                Speed (number smaller is better)
00022  * 1.  md4                          5307.912
00023    2.  md5                           6890.058
00024    3.  crc32b                        7298.946
00025    4.  crc32                         7561.922
00026    5.  sha1                          8886.098
00027    6.  tiger128,3                    11054.992
00028    7.  haval192,3                    11132.955
00029    8.  haval224,3                    11160.135
00030    9.  tiger160,3                    11162.996
00031   10.  haval160,3                    11242.151
00032   11.  haval256,3                    11327.981
00033   12.  tiger192,3                    11630.058
00034   13.  haval128,3                    11880.874
00035   14.  tiger192,4                    14776.945
00036   15.  tiger128,4                    14871.12
00037   16.  tiger160,4                    14946.937
00038   17.  haval160,4                    15661.954
00039   18.  haval192,4                    15717.029
00040   19.  haval256,4                    15759.944
00041   20.  adler32                       15796.184
00042   21.  haval128,4                    15887.022
00043   22.  haval224,4                    16047.954
00044   23.  ripemd256                     16245.126
00045   24.  haval160,5                    17818.927
00046   25.  haval128,5                    17887.115
00047   26.  haval224,5                    18085.002
00048   27.  haval192,5                    18135.07
00049   28.  haval256,5                    18678.903
00050   29.  sha256                        19020.08
00051   30.  ripemd128                     20671.844
00052   31.  ripemd160                     21853.923
00053   32.  ripemd320                     22425.889
00054   33.  sha384                        45102.119
00055   34.  sha512                        45655.965
00056   35.  gost                          57237.148
00057   36.  whirlpool                     64682.96
00058   37.  snefru                        80352.783
00059   38.  md2 * 
00060 */
00061 
00070 class authService
00071 {
00072     public $m_AuthticationType ;
00073     public $m_AuthticationDataObj;
00074 
00081     function __construct(&$xmlArr)
00082     {
00083         $this->readMetadata($xmlArr);
00084     }
00085 
00092     protected function readMetadata(&$xmlArr)
00093     {
00094         $this->m_AuthticationType  = $xmlArr["PLUGINSERVICE"]["ATTRIBUTES"]["AUTHTYPE"];
00095         $this->m_AuthticationDataObj      = $xmlArr["PLUGINSERVICE"]["ATTRIBUTES"]["BIZDATAOBJ"];
00096     }
00097 
00105     public function authenticateUser($userName, $password)
00106     {
00107         if ($this->m_AuthticationType == "database")
00108             return $this->authDBUser($userName, $password);
00109         return false;
00110     }
00111 
00119     protected function authDBUser($userName, $password)
00120     {
00121         $boAuth = BizSystem::getObject($this->m_AuthticationDataObj);
00122         if (!$boAuth)
00123             return false;
00124         $searchRule = "[login]='$userName'";
00125         $recordList = array();
00126         $boAuth->fetchRecords($searchRule, $recordList, 1);
00127 
00128         $encType      = $recordList[0]["enctype"];
00129         $realPassword = $recordList[0]["password"];
00130         if ($this->checkPassword($encType,$password,$realPassword))
00131             return true;
00132 
00133         return false;
00134     }
00135 
00144     protected function checkPassword($encType,$password,$realPassword)
00145     {
00146         foreach(hash_algos() as $algos)
00147         {
00148             if(strtoupper($encType)==strtoupper($algos))
00149             {
00150                 $password=hash($algos, $password);
00151             }
00152         }
00153         if($password==$realPassword)
00154         {
00155             return true;
00156         }
00157         else
00158         {
00159             return false;
00160         }
00161     }
00162 }
00163 
00164 ?>

Generated on Thu Apr 19 2012 17:09:13 for openbiz by  doxygen 1.7.2