Esempio n. 1
0
 public function login()
 {
     $params = $this->AuthInfo;
     $username = $params['user'];
     $passhash = $params['passhash'];
     $token = $params['token'];
     $app_type = $params['appType'];
     $session_id = $params['session'];
     $ip = $_SERVER['REMOTE_ADDR'];
     $language = isset($params['language']) ? $params['language'] : 'en';
     $this->Response->setDebug('parameters', $params);
     setcookie("kt_language", $language, 2147483647, '/');
     $kt =& $this->KT;
     if ($username != 'admin') {
         require_once KT_DIR . '/plugins/wintools/baobabkeyutil.inc.php';
         if (!BaobabKeyUtil::checkIfLicensed(true)) {
             return array('authenticated' => false, 'message' => 'license_expired');
         }
     }
     $user = $kt->get_user_object_by_username($username);
     if (!PEAR::isError($user)) {
         $password = $user->getPassword();
         $localPassHash = md5($password . $token);
         if ($localPassHash == $passhash) {
             $session = new stdClass();
             $this->Response->setDebug('trying to start session with', array('username' => $username, 'password' => $password));
             $session = $kt->start_session($username, $params['pass'], NULL, $app_type);
             if (!PEAR::isError($session)) {
                 $this->Response->setStatus('session_id', $session->get_session());
             } else {
                 $this->Response->setDebug('failed login', print_r($session, true));
                 throw new Exception('Unknown Login Error');
                 return false;
             }
         } else {
             throw new Exception('Incorrect Credentials');
             return false;
         }
     } else {
         throw new Exception('Unrecognized User');
         return false;
     }
     return true;
 }
Esempio n. 2
0
 public function login()
 {
     $params = $this->AuthInfo;
     $username = $params['user'];
     $passhash = $params['passhash'];
     $token = $params['token'];
     $app_type = $params['appType'];
     $session_id = $params['session'];
     $ip = $_SERVER['REMOTE_ADDR'];
     $language = isset($params['language']) ? $params['language'] : 'en';
     $this->Response->setDebug('parameters', $params);
     setcookie("kt_language", $language, 2147483647, '/');
     $kt =& $this->KT;
     if ($username != 'admin') {
         //$this->addDebug('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@','');
         try {
             if (class_exists('BaobabKeyUtil')) {
                 if (!BaobabKeyUtil::checkIfLicensed(true)) {
                     $this->setResponse(array('authenticated' => false, 'message' => 'license_expired'));
                     $this->addError('Licence Expired');
                     return false;
                 }
             } else {
                 $this->addError('Licence Utility could not be loaded. Appears to be a Community version.');
                 $this->setResponse(array('authenticated' => false, 'message' => 'Licence Utility could not be loaded. Appears to be a Community version.'));
                 return false;
             }
         } catch (Exception $e) {
             $this->addError('could not execute BaobabKeyUtil::checkIfLicensed');
             $this->setResponse(array('authenticated' => false, 'message' => 'BaobabKeyUtil::checkIfLicensed error'));
             return;
         }
     }
     $user = $kt->get_user_object_by_username($username);
     if (!PEAR::isError($user)) {
         $password = $user->getPassword();
         $localPassHash = md5($password . $token);
         if ($localPassHash == $passhash) {
             $session = new stdClass();
             $this->Response->setDebug('trying to start session with', array('username' => $username, 'password' => $password));
             $session = $kt->start_session($username, $params['pass'], NULL, $app_type);
             if (!PEAR::isError($session)) {
                 $this->Response->setStatus('session_id', $session->get_session());
             } else {
                 $this->setResponse(array('authenticated' => false, 'message' => 'Invalid username and/or password.'));
                 $this->addDebug('failed login', print_r($session, true));
                 $this->addError('Unknown Login Error');
                 return false;
             }
         } else {
             $this->addError('Incorrect Credentials');
             //throw new Exception('Incorrect Credentials');
             return false;
         }
     } else {
         $this->addError('Incorrect Credentials');
         //throw new Exception('Unrecognized User');
         return false;
     }
     return true;
 }
Esempio n. 3
0
 protected function checkCredentials()
 {
     $user = $this->auth['user'];
     $passHash = $this->auth['passhash'];
     $kt = $this->kt;
     /*
      * User Check
      */
     $o_user = $kt->get_user_object_by_username($user);
     if (PEAR::isError($o_user)) {
         if (!isset($this->errors['usernotfound'])) {
             $this->ret->addError('User ' . $user . ' not found');
         }
         $this->errors['usernotfound'] = true;
         return false;
     }
     /*
      * BAOBAB Licence Check
      */
     if ($user != 'admin') {
         try {
             if (class_exists('BaobabKeyUtil')) {
                 if (!BaobabKeyUtil::checkIfLicensed(true)) {
                     $this->ret->setResponse(array('authenticated' => false, 'message' => 'license_expired'));
                     $this->ret->addError('Licence Expired');
                     return false;
                 }
             } else {
                 $this->ret->addError('Licence Utility could not be loaded. Appears to be a Community version.');
                 $this->ret->setResponse(array('authenticated' => false, 'message' => 'Licence Utility could not be loaded. Appears to be a Community version.'));
                 return false;
             }
         } catch (Exception $e) {
             $this->ret->addError('could not execute BaobabKeyUtil::checkIfLicensed');
             $this->ret->setResponse(array('authenticated' => false, 'message' => 'BaobabKeyUtil::checkIfLicensed error'));
             return;
         }
     }
     /*
      * Password Check
      */
     try {
         $l_pass = $o_user->getPassword();
         $l_passHash = md5($l_pass . $this->auth['token']);
         $passed = $passHash == $l_passHash;
         $this->ret->setDebug('Auth', array('User Real Password' => $l_pass, 'User Real Password Hash' => $l_passHash, 'Received Password Hash' => $passHash, 'passed' => $passed));
         return $passed;
     } catch (Exception $e) {
         throw new Exception('Unknown credentialCheck error encountered');
         return false;
     }
     return ture;
 }