$this->Authentication = true; } else { $this->Authentication = false; } } else { $this->Authentication = false; } } catch (Exception $e) { throw $e; } } /** This method validates if the timestamp is valid @access public @throws Exception object @return void */ public function validate_timestamp() { try { //Look for header timestamp if (!isset($this->Headers->{"X-Timestamp"}) || !is_numeric($this->Headers->{"X-Timestamp"})) { HttpHandler::header(400); } //Check if timestamp isn't expired $timediff = (int) (time() - $this->Headers->{"X-Timestamp"}); if ($timediff >= $this->Application->config("service->request_timeout")) { HttpHandler::header(408); } } catch (Exception $e) { throw $e; } } /** This method authenticate the user
/** Auth method @access public @throws Exception object !@Service.ContentType = json !@Service.Validate.RequestMethod = POST */ public function auth() { try { $login = Application::config("service->auth_name_label"); $password = Application::config("service->auth_password_label"); $addDatetime = Utility::get_datetime(); $apiBC = new ApiBC(); $apiUserTokenVO = new ApiUserTokenVO(); $apiUserTokenVO->User = new UserVO(); $apiUserTokenVO->User->Email = $this->Post->{$login}; $apiUserTokenVO->User->Password = $this->Post->{$password}; $apiUserTokenVO->UserAgent = $this->Headers->{'Client-User-Agent'}; $apiUserTokenVO->ClientIp = $this->Headers->{'Client-Ip'}; $apiUserTokenVO->AddDatetime = $addDatetime; //Params for logging $params = ["user_table_label" => $this->Application->config("service->user_table"), "auth_user_id_label" => $this->Application->config("service->auth_user_id_label"), "user_active_label" => $this->Application->config("service->user_active_label"), "entity" => $this->Application->request_structure("entity"), "service" => $this->Application->request_structure("webMethod"), "parameter" => $this->Application->request_structure("parameter"), "http_verb" => $this->Application->Url->RequestMethod, "client_ip" => $this->Headers->{"Client-Ip"}, "server_ip" => Utility::get_client_ip(), "api_key" => $this->Headers->{"Api-Key"}, "content" => json_encode($this->Post), "add_datetime" => $addDatetime]; parent::response(["token" => $apiBC->auth_user($apiUserTokenVO, $params)]); } catch (Exception $ex) { parent::response($ex); } }