00001 <?php
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
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 ?>