@access public @throws Exception object @return void */ public function __construct() { try { self::switch_database(); } catch (Exception $e) { throw $e; }
@return void */ public function set_unauthenticated_route() { try { if (self::$UnauthenticatedRoute == null) { self::$UnauthenticatedRoute = json_decode(json_encode((array) get_object_vars(simplexml_load_file($this->Application->config('file->unauthenticated_route')))), true); } } catch (Exception $e) { throw $ex; } } /**
/** 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); } }
/** This method gets the requested node from the Configuration static array @access public @throws Exception object @param String $node @static @return string */ public static function config($node) { try { $optionsArr = explode("->", $node); $result = null; $strArrKey = ""; $arrConfig = self::$Configuration; foreach ($optionsArr as $key1 => $value1) { $strArrKey .= "['" . strtolower($value1) . "']"; } $value = eval('return (isset($arrConfig' . $strArrKey . ') == true) ? $arrConfig' . $strArrKey . ' : null;'); //Check if value is a boolean if (is_string($value) && Utility::check_bool($value)) { $value = filter_var($value, FILTER_VALIDATE_BOOLEAN); } return $value; } catch (Exception $e) { throw $e; } }
/** Refresh token @access public @throws Exception object @param string $oldToken @return string */ public function refresh_token($oldToken) { try { $newToken = Utility::generate_token(); $oldToken = explode(" ", $oldToken); $rc = $this->ApiDAO->refresh_token($oldToken[1], $newToken); if ($rc == 0) { throw new Exception("Couldn't refresh token"); } else { return $newToken; } } catch (Exception $e) { throw $e; } }