CN118646604B - Method and device for performing network access on application in intelligent terminal equipment - Google Patents
Method and device for performing network access on application in intelligent terminal equipment Download PDFInfo
- Publication number
- CN118646604B CN118646604B CN202411112903.9A CN202411112903A CN118646604B CN 118646604 B CN118646604 B CN 118646604B CN 202411112903 A CN202411112903 A CN 202411112903A CN 118646604 B CN118646604 B CN 118646604B
- Authority
- CN
- China
- Prior art keywords
- network
- configuration information
- application
- network access
- system service
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L63/00—Network architectures or network communication protocols for network security
- H04L63/10—Network architectures or network communication protocols for network security for controlling access to devices or network resources
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/40—Network security protocols
Landscapes
- Engineering & Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer Hardware Design (AREA)
- Computing Systems (AREA)
- General Engineering & Computer Science (AREA)
- Computer And Data Communications (AREA)
Abstract
Description
技术领域Technical Field
本发明涉及智能终端安全领域,尤其涉及一种智能终端设备中应用进行网络访问的方法及装置。The present invention relates to the field of intelligent terminal security, and in particular to a method and device for performing network access by an application in an intelligent terminal device.
背景技术Background Art
智能终端是一类嵌入式计算机系统设备,随着信息技术的快速发展,在支付领域中智能终端的产品也应运而生,比如智能POS设备,智能POS设备是一种集支付、结算、识别、打印等功能于一体的智能终端设备,智能POS设备通过集成各种先进的技术和软件,提供了更高效、更便捷的服务,为商家和消费者带来了全新的体验,其中,集成的软件部分包括系统软件和应用软件。Smart terminals are a type of embedded computer system equipment. With the rapid development of information technology, smart terminal products have also emerged in the payment field, such as smart POS devices. Smart POS devices are a type of smart terminal equipment that integrates payment, settlement, identification, printing and other functions. Smart POS devices provide more efficient and convenient services by integrating various advanced technologies and software, bringing a new experience to merchants and consumers. Among them, the integrated software part includes system software and application software.
现有技术中,智能终端设备中的应用软件通常都需要连接访问到网络才能完成具体操作,这就会存在其他应用(恶意软件或程序)通过网络获取操作数据,导致数据泄露的问题,此外,现有技术中智能终端设备中的应用也没有对待访问的网络进行设置的权限。因此,如何解决智能终端设备中应用软件操作过程中数据的安全性问题成为了当前亟需解决的技术问题。In the prior art, application software in smart terminal devices usually need to connect to the network to complete specific operations, which may cause other applications (malware or programs) to obtain operation data through the network, resulting in data leakage. In addition, in the prior art, applications in smart terminal devices do not have the authority to set the network to be accessed. Therefore, how to solve the data security problem during the operation of application software in smart terminal devices has become a technical problem that needs to be solved urgently.
发明内容Summary of the invention
为了解决上述技术问题,本发明提供了一种智能终端设备中应用进行网络访问的方法及装置。所述技术方案如下:In order to solve the above technical problems, the present invention provides a method and device for an application in a smart terminal device to access a network. The technical solution is as follows:
根据本发明的第一方面,本发明提供了一种智能终端设备中应用进行网络访问的方法,所述方法包括:According to a first aspect of the present invention, the present invention provides a method for an application in an intelligent terminal device to access a network, the method comprising:
步骤S1、所述系统服务根据被调用的接口类型确定应用网络设置类型,若所述应用网络设置类型为第一类型则执行步骤S2;Step S1, the system service determines the application network setting type according to the called interface type, and if the application network setting type is the first type, executes step S2;
步骤S2、所述系统服务获取通过被调用的第一预设接口传入的应用配置信息,根据所述应用配置信息判断是否存在用户防火墙权限信息,是则执行步骤S3,否则结束;Step S2, the system service obtains the application configuration information passed in through the called first preset interface, and determines whether there is user firewall authority information according to the application configuration information, and if yes, executes step S3, otherwise ends;
步骤S3、所述系统服务获取自定义IP地址列表,将所述应用配置信息中的网络访问配置信息保存至所述自定义IP地址列表中,将所述网络访问配置信息作为参数传入所述网络驱动;Step S3, the system service obtains a custom IP address list, saves the network access configuration information in the application configuration information into the custom IP address list, and passes the network access configuration information into the network driver as a parameter;
步骤S4、所述网络驱动通过配置指令将所述网络访问配置信息配置到过滤白名单规则表中,结束;Step S4, the network driver configures the network access configuration information into the filtering whitelist rule table through a configuration instruction, and ends;
所述方法还包括:The method further comprises:
步骤F1、当所述系统服务接收到所述智能终端设备中的应用发起的网络连接请求时,所述系统服务通过所述网络驱动监听网络响应数据包;Step F1: When the system service receives a network connection request initiated by an application in the intelligent terminal device, the system service monitors a network response data packet through the network driver;
步骤F2、当所述网络驱动监听到所述网络响应数据包时,所述网络驱动判断过滤白名单规则表中是否存在网络访问配置信息,若存在则执行步骤F3,否则向所述系统服务返回所述网络响应数据包,执行步骤F4;Step F2, when the network driver monitors the network response data packet, the network driver determines whether there is network access configuration information in the filtering whitelist rule table, if yes, executes step F3, otherwise returns the network response data packet to the system service, and executes step F4;
步骤F3、所述网络驱动判断所述网络响应数据包中响应方的IP地址是否与过滤白名单规则表中的网络访问配置信息相同,若是则向所述系统服务返回所述网络响应数据包,执行步骤F4,否则丢弃所述网络响应数据包,向所述系统服务返回错误,执行步骤F5;Step F3, the network driver determines whether the IP address of the responder in the network response data packet is the same as the network access configuration information in the filtering whitelist rule table, if so, returns the network response data packet to the system service, and executes step F4, otherwise discards the network response data packet, returns an error to the system service, and executes step F5;
步骤F4、所述系统服务向所述应用返回所述网络响应数据包;Step F4, the system service returns the network response data packet to the application;
步骤F5、所述系统服务向所述应用返回错误。Step F5: The system service returns an error to the application.
根据本发明的第二方面,本发明实施例提供了一种智能终端设备中应用访问网络设置装置,其特征在于,所述装置包括:系统服务和网络驱动;According to a second aspect of the present invention, an embodiment of the present invention provides a device for setting application access network in an intelligent terminal device, characterized in that the device includes: a system service and a network driver;
所述系统服务包括:The system services include:
第一确定模块,用于根据被调用的接口类型确定应用网络设置类型,若所述应用网络设置类型为第一类型则触发第一获取判断模块;A first determination module, configured to determine the application network setting type according to the called interface type, and trigger a first acquisition judgment module if the application network setting type is the first type;
所述第一获取判断模块,用于获取通过被调用的接口传入的应用配置信息,根据所述应用配置信息判断是否存在用户防火墙权限信息;The first acquisition and judgment module is used to obtain application configuration information passed in through the called interface, and judge whether there is user firewall permission information according to the application configuration information;
获取保存模块,用于当所述第一获取判断模块判断存在用户防火墙权限信息时,获取自定义IP地址列表,将所述应用配置信息中的网络访问配置信息保存至所述自定义IP地址列表中,将所述网络访问配置信息作为参数传入所述网络驱动;an acquisition and saving module, configured to acquire a custom IP address list when the first acquisition and judgment module determines that there is user firewall permission information, save the network access configuration information in the application configuration information into the custom IP address list, and pass the network access configuration information as a parameter into the network driver;
所述网络驱动包括:配置模块,用于通过配置指令将所述网络访问配置信息配置到过滤白名单规则表中;The network driver includes: a configuration module, configured to configure the network access configuration information into a filtering whitelist rule table through configuration instructions;
所述系统服务还包括:The system services also include:
接收模块,用于接收智能终端设备中的应用发起的网络连接请求,并在接收到请求时,通过所述网络驱动监听网络响应数据包,还用于接收所述网络驱动发送的网络响应数据包;A receiving module, used to receive a network connection request initiated by an application in the intelligent terminal device, and upon receiving the request, monitor a network response data packet through the network driver, and also used to receive a network response data packet sent by the network driver;
发送模块,用于向所述应用返回所述网络响应数据包,还用于向所述应用返回错误;a sending module, used to return the network response data packet to the application, and also used to return an error to the application;
所述网络驱动还包括:The network driver also includes:
第一判断模块,用于监听所述网络响应数据包,当监听到所述网络响应数据包时判断过滤白名单规则表中是否存在网络访问配置信息,是则触发第二判断模块,否则向所述系统服务返回所述网络响应数据包;A first judgment module is used to monitor the network response data packet, and when the network response data packet is monitored, it is determined whether there is network access configuration information in the filtering whitelist rule table, and if yes, the second judgment module is triggered, otherwise, the network response data packet is returned to the system service;
第二判断模块,用于判断所述网络响应数据包中响应方的IP地址是否与过滤白名单规则表中的网络访问配置信息相同,是则向所述系统服务返回所述网络响应数据包,否则丢弃所述网络响应数据包,向所述系统服务返回错误。The second judgment module is used to judge whether the IP address of the responder in the network response data packet is the same as the network access configuration information in the filtering whitelist rule table. If so, the network response data packet is returned to the system service; otherwise, the network response data packet is discarded and an error is returned to the system service.
根据本发明的第三方面,本发明实施例提供了一种计算机设备,包括存储器、处理器及存储在存储器上的计算机程序,所述处理器执行所述计算机程序以实现上述第一方面所述的一种智能终端设备中应用进行网络访问的方法。According to a third aspect of the present invention, an embodiment of the present invention provides a computer device, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement a method for network access by an application in a smart terminal device as described in the first aspect above.
根据本发明的第四方面,本发明实施例提供了计算机可读存储介质,其上存储有计算机程序/指令,所述计算机程序/指令被处理器执行时实现上述第一方面所述的一种智能终端设备中应用进行网络访问的方法。According to a fourth aspect of the present invention, an embodiment of the present invention provides a computer-readable storage medium having a computer program/instruction stored thereon, which, when executed by a processor, implements a method for an application in an intelligent terminal device to access a network as described in the first aspect above.
根据本发明的第五方面,本发明实施例提供了一种计算机程序产品,包括计算机程序/指令,所述计算机程序/指令被处理器执行时实现上述第一方面所述的一种智能终端设备中应用进行网络访问的方法。According to a fifth aspect of the present invention, an embodiment of the present invention provides a computer program product, including a computer program/instruction, which, when executed by a processor, implements a method for network access by an application in a smart terminal device as described in the first aspect above.
本发明实施例提供的技术方案带来的有益效果至少包括:The beneficial effects brought about by the technical solution provided by the embodiment of the present invention include at least:
本发明提供的一种智能终端设备中应用进行网络访问的方法及装置,系统服务和网络驱动根据确定的应用网络设置类型对应用指定的网络访问设置信息进行设置,解决了现有技术中应用没有权限导致的无法设置网络访问的安全问题,实现了应用可以在指定网络环境下进行安全访问并安全操作处理的功能,避免了网络安全问题造成的数据泄露等风险。The present invention provides a method and device for network access by applications in an intelligent terminal device. The system service and the network driver set the network access setting information specified by the application according to the determined application network setting type, thereby solving the security problem of the inability to set network access due to the lack of permission of the application in the prior art, and realizing the function that the application can access and operate securely in a specified network environment, thereby avoiding the risks of data leakage caused by network security problems.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
图1是本发明实施例一提供的一种智能终端设备中应用进行网络访问的方法中网络设置的流程示意图;1 is a schematic diagram of a flow chart of network settings in a method for performing network access by an application in an intelligent terminal device provided in a first embodiment of the present invention;
图2是本发明实施例一提供的一种智能终端设备中应用进行网络访问的方法流程示意图;2 is a schematic diagram of a method for performing network access by an application in a smart terminal device provided in Embodiment 1 of the present invention;
图3是本发明实施例二提供的一种智能终端设备中应用进行网络访问的方法中生成应用待安装APK文件的方法流程示意图;3 is a schematic diagram of a method for generating an APK file to be installed in a method for performing network access by an application in a smart terminal device provided in Embodiment 2 of the present invention;
图4是本发明实施例二提供的应用首次安装时实现的一种智能终端设备中应用进行网络访问的方法的流程示意图;4 is a flowchart of a method for performing network access by an application in a smart terminal device when an application is first installed provided by Embodiment 2 of the present invention;
图5是本发明实施例二提供的应用升级安装时实现的一种智能终端设备中应用进行网络访问的方法的流程示意图;5 is a flowchart of a method for performing network access by an application in a smart terminal device implemented during application upgrade installation provided by Embodiment 2 of the present invention;
图6是本发明实施例三提供的第三方应用调用POS管理服务时实现的一种智能终端设备中应用进行网络访问的方法的流程示意图;6 is a flowchart of a method for an application in a smart terminal device to access a network when a third-party application calls a POS management service provided in Embodiment 3 of the present invention;
图7是本发明实施例四提供的一种智能终端设备中应用进行网络访问的方法的流程示意图。FIG. 7 is a flow chart of a method for performing network access by an application in a smart terminal device provided in a fourth embodiment of the present invention.
具体实施方式DETAILED DESCRIPTION
为使本发明的目的、技术方案和优点更加清楚,下面将结合附图对本发明实施例方式作进一步地详细描述。In order to make the objectives, technical solutions and advantages of the present invention more clear, the embodiments of the present invention will be further described in detail below with reference to the accompanying drawings.
下面的描述涉及附图时,除非另有表示,不同附图中的相同数字表示相同或相似的要素。以下示例性实施例中所描述的实施方式并不代表与本发明相一致的所有实施方式。相反,它们仅是如所附权利要求书中所详述的、本发明的一些方面相一致的设备和方法的例子。When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Instead, they are only examples of devices and methods consistent with some aspects of the present invention as detailed in the attached claims.
为使本发明的目的、技术方案和优点更加清楚,下面将结合附图对本发明实施例提供的一种智能终端设备中应用进行网络访问的方法进行详细介绍。To make the purpose, technical solution and advantages of the present invention more clear, a method for an application in a smart terminal device to access a network provided by an embodiment of the present invention will be described in detail below with reference to the accompanying drawings.
实施例一Embodiment 1
本发明实施例一提供一种智能终端设备中应用进行网络访问的方法,如图1和图2所示,智能终端设备包括系统服务和网络驱动,该方法包括:Embodiment 1 of the present invention provides a method for an application in an intelligent terminal device to access a network. As shown in FIG. 1 and FIG. 2 , the intelligent terminal device includes a system service and a network driver. The method includes:
步骤101、系统服务根据被调用的接口类型确定应用网络设置类型,若应用网络设置类型为第一类型则执行步骤102;Step 101, the system service determines the application network setting type according to the called interface type, and if the application network setting type is the first type, execute step 102;
步骤102、系统服务获取通过被调用的第一预设接口传入的应用配置信息,根据应用配置信息判断是否存在用户防火墙权限信息,是则执行步骤103,否则结束;Step 102: The system service obtains the application configuration information passed in through the called first preset interface, and determines whether there is user firewall permission information according to the application configuration information. If yes, execute step 103; otherwise, terminate;
步骤103、系统服务获取自定义IP地址列表,将应用配置信息中的网络访问配置信息保存至自定义IP地址列表中,将网络访问配置信息作为参数传入网络驱动;Step 103: The system service obtains a custom IP address list, saves the network access configuration information in the application configuration information into the custom IP address list, and passes the network access configuration information as a parameter to the network driver;
步骤104、网络驱动通过配置指令将网络访问配置信息配置到过滤白名单规则表中,结束;Step 104: The network driver configures the network access configuration information into the filtering whitelist rule table through the configuration instruction, and ends;
该方法还包括:The method further includes:
步骤201、当系统服务接收到智能终端设备中的应用发起的网络连接请求时,系统服务通过网络驱动监听网络响应数据包;Step 201: When the system service receives a network connection request initiated by an application in the intelligent terminal device, the system service monitors the network response data packet through the network driver;
步骤202、当网络驱动监听到网络响应数据包时,网络驱动判断过滤白名单规则表中是否存在网络访问配置信息,若是则执行步骤203,否则向系统服务返回网络响应数据包,执行步骤204;Step 202, when the network driver monitors the network response data packet, the network driver determines whether there is network access configuration information in the filtering whitelist rule table, if yes, execute step 203, otherwise return the network response data packet to the system service, execute step 204;
步骤203、网络驱动判断网络响应数据包中响应方的IP地址是否与过滤白名单规则表中的网络访问配置信息相同,若是则向系统服务返回网络响应数据包,执行步骤204,否则丢弃网络响应数据包,向系统服务返回错误,执行步骤205;Step 203, the network driver determines whether the IP address of the responder in the network response data packet is the same as the network access configuration information in the filtering whitelist rule table. If so, the network response data packet is returned to the system service and step 204 is executed. Otherwise, the network response data packet is discarded, an error is returned to the system service, and step 205 is executed.
步骤204、系统服务向应用返回网络响应数据包;Step 204: The system service returns a network response data packet to the application;
步骤205、系统服务向应用返回错误。Step 205: The system service returns an error to the application.
一种可实施的方式,该方法还包括系统服务根据被调用的接口类型确定应用网络设置类型为第二类型时,执行以下步骤:In an practicable manner, the method further includes, when the system service determines that the application network setting type is the second type according to the called interface type, executing the following steps:
步骤105、系统服务获取通过被调用的第二预设接口传入的应用配置信息,根据应用配置信息判断是否存在用户防火墙权限信息,是则执行步骤106,否则结束;Step 105, the system service obtains the application configuration information transmitted through the called second preset interface, and determines whether there is user firewall permission information according to the application configuration information, and if yes, executes step 106, otherwise ends;
步骤106、系统服务获取自定义IP地址列表,判断自定义IP地址列表中是否存在网络访问配置信息,是则将自定义IP地址列表中的网络访问配置信息删除,将网络访问配置信息作为参数传入网络驱动,执行步骤107,否则结束;Step 106, the system service obtains the custom IP address list, determines whether there is network access configuration information in the custom IP address list, if yes, deletes the network access configuration information in the custom IP address list, passes the network access configuration information as a parameter to the network driver, and executes step 107, otherwise, ends;
步骤107、网络驱动通过删除指令将网络访问配置信息从过滤白名单规则表中删除,结束;Step 107: The network driver deletes the network access configuration information from the filtering whitelist rule table through a deletion instruction, and the process ends;
具体地,系统服务根据被调用的接口类型确定应用网络设置类型具体为:当系统服务的第一预设接口被调用时,系统服务确定应用网络设置类型为第一类型,当系统服务的第二预设接口被调用时,系统服务确定应用网络设置类型为第二类型。Specifically, the system service determines the application network setting type according to the type of the called interface: when the first preset interface of the system service is called, the system service determines the application network setting type as the first type; when the second preset interface of the system service is called, the system service determines the application network setting type as the second type.
一种可实施的方式,系统服务包括包管理服务,步骤101之前还包括:In one practicable manner, the system service includes a package management service, and before step 101, the following is further included:
步骤1101、包管理服务获取应用待安装APK文件;Step 1101: The package management service obtains the APK file of the application to be installed;
步骤1102、包管理服务调用API接口解析应用待安装APK文件中的清单文件,获取配置启动项信息;Step 1102: The package management service calls an API interface to parse the manifest file in the APK file of the application to be installed, and obtains configuration startup item information;
步骤1103、包管理服务根据配置启动项信息确定网络访问配置类型,根据网络访问配置类型调用系统服务的接口。Step 1103: The package management service determines the network access configuration type according to the configuration startup item information, and calls the interface of the system service according to the network access configuration type.
具体地,一种可实施的方式,步骤1103中,调用系统服务的接口具体为:包管理服务获取清单文件中的用户防火墙权限信息和网络访问配置信息,将网络访问配置信息和用户防火墙权限信息组织得到应用配置信息,调用系统服务的接口将应用配置信息作为参数传入。Specifically, in one implementable method, in step 1103, the interface of calling the system service is as follows: the package management service obtains the user firewall permission information and network access configuration information in the manifest file, organizes the network access configuration information and the user firewall permission information to obtain the application configuration information, and calls the interface of the system service to pass in the application configuration information as a parameter.
具体地,一种可实施的方式,该方法还包括生成应用待安装APK文件;Specifically, in an implementable manner, the method further includes generating an APK file of the application to be installed;
生成应用待安装APK文件具体为:Generate the APK file to be installed as follows:
步骤D1、确定网络访问配置类型;Step D1, determining the network access configuration type;
步骤D2、根据预定格式将网络访问配置类型对应的配置启动项信息、网络访问配置信息和用户防火墙权限信息写入清单文件得到应用待安装APK文件。Step D2: Write the configuration startup item information, network access configuration information and user firewall permission information corresponding to the network access configuration type into the manifest file according to a predetermined format to obtain the application to be installed APK file.
具体地,一种可实施的方式,步骤103中,将应用配置信息中的网络访问配置信息保存至自定义IP地址列表中之前还包括:Specifically, in one practicable manner, in step 103, before the network access configuration information in the application configuration information is saved in the custom IP address list, the following steps are further included:
步骤M21、系统服务判断自定义IP地址列表中是否存在网络访问配置信息,是则执行步骤M22,否则将应用配置信息中的网络访问配置信息保存至自定义IP地址列表中;Step M21, the system service determines whether there is network access configuration information in the custom IP address list, if yes, executes step M22, otherwise, saves the network access configuration information in the application configuration information into the custom IP address list;
步骤M22、系统服务获取应用配置信息中的网络访问配置信息,判断自定义IP地址列表中的网络访问配置信息与应用配置信息中的网络访问配置信息是否相同,若是则结束,若否则执行步骤M23;Step M22: The system service obtains the network access configuration information in the application configuration information, and determines whether the network access configuration information in the custom IP address list is the same as the network access configuration information in the application configuration information. If so, the process ends; otherwise, the process proceeds to step M23.
步骤M23、系统服务将自定义IP地址列表中的网络访问配置信息从自定义IP地址列表中删除,将自定义IP地址列表中的网络访问配置信息作为参数传入网络驱动,执行步骤M24,将应用配置信息中的网络访问配置信息保存至自定义IP地址列表中;Step M23, the system service deletes the network access configuration information in the custom IP address list from the custom IP address list, passes the network access configuration information in the custom IP address list as a parameter to the network driver, and executes step M24 to save the network access configuration information in the application configuration information to the custom IP address list;
步骤M24、网络驱动通过删除指令将自定义IP地址列表中的网络访问配置信息从过滤白名单规则表中删除。Step M24: The network driver deletes the network access configuration information in the custom IP address list from the filtering whitelist rule table through a delete instruction.
一种可实施的方式,智能终端设备包括POS管理服务;In one practicable manner, the intelligent terminal device includes a POS management service;
步骤101之前还包括:POS管理服务根据被第三方应用调用的接口类型确定调用系统服务的接口类型,根据确定的接口类型调用系统服务的接口。The process before step 101 also includes: the POS management service determines the interface type for calling the system service according to the interface type called by the third-party application, and calls the interface of the system service according to the determined interface type.
具体地,一种可实施的方式,根据确定的接口类型调用系统服务的接口具体为:POS管理服务获取应用包名,将网络访问配置信息和应用包名组织得到应用配置信息,调用系统服务的接口将应用配置信息作为参数传入。Specifically, an implementable method is to call the system service interface according to the determined interface type: the POS management service obtains the application package name, organizes the network access configuration information and the application package name to obtain the application configuration information, and calls the system service interface to pass in the application configuration information as a parameter.
一种可实施的方式,根据应用配置信息判断是否存在用户防火墙权限信息具体为:One feasible way to determine whether there is user firewall permission information based on application configuration information is as follows:
系统服务根据应用配置信息中的应用包名判断是否存在用户防火墙权限信息。The system service determines whether there is user firewall permission information based on the application package name in the application configuration information.
一种可实施的方式,当系统服务根据应用配置信息判断存在用户防火墙权限信息时还包括:系统服务获取应用配置信息中的验签数据进行代码验签,如验签通过则获取网络配置权限,执行步骤103,如验签未通过则报错,结束,验签数据包括指定参数、验证密钥及签名数据。An implementable method, when the system service determines that there is user firewall permission information based on the application configuration information, it also includes: the system service obtains the verification data in the application configuration information to perform code verification, if the verification passes, the network configuration permission is obtained, and step 103 is executed. If the verification fails, an error is reported and the process ends. The verification data includes specified parameters, verification keys and signature data.
一种可实施的方式,当智能终端设备关机时,该方法还包括:网络驱动通过删除指令将过滤白名单规则表中的网络访问配置信息全部删除。In an practicable manner, when the intelligent terminal device is turned off, the method further includes: the network driver deletes all network access configuration information in the filtering whitelist rule table through a deletion instruction.
一种可实施的方式,当智能终端设备开机重启时,该方法还包括:系统服务获取保存的自定义IP地址列表,遍历自定义IP地址列表,顺序获取自定义IP地址列表中的网络访问配置信息并将所述网络访问配置信息作为参数传入所述网络驱动,执行步骤104。In an practicable manner, when the smart terminal device is powered on and restarted, the method further includes: the system service obtains a saved custom IP address list, traverses the custom IP address list, sequentially obtains network access configuration information in the custom IP address list and passes the network access configuration information as a parameter into the network driver, and executes step 104.
一种可实施的方式,步骤102中,当根据应用配置信息判断存在用户防火墙权限信息时,还包括:系统服务根据应用配置信息中的用户防火墙信息设置应用对应的防火墙权限组信息;In one practicable manner, in step 102, when it is determined that there is user firewall permission information according to the application configuration information, the method further includes: the system service sets firewall permission group information corresponding to the application according to the user firewall information in the application configuration information;
步骤202中,执行步骤203之前还包括:网络驱动判断网络响应数据包中响应方的IP地址对应的防火墙权限信息是否与过滤白名单规则表中的防火墙权限组信息相同,是则执行步骤203,否则向系统服务返回错误,执行步骤205。In step 202, before executing step 203, it also includes: the network driver determines whether the firewall permission information corresponding to the IP address of the responder in the network response data packet is the same as the firewall permission group information in the filtering whitelist rule table. If so, step 203 is executed; otherwise, an error is returned to the system service and step 205 is executed.
本发明提供的一种智能终端设备中应用进行网络访问的方法,系统服务根据被调用的接口类型确定应用网络设置类型,并根据应用传入的参数验证应用的权限,验证通过则获取网络访问设置权限,通过网络驱动根据确定的应用网络设置类型对应用指定的网络访问设置信息进行设置,解决了现有技术中由于应用没有权限而无法设置安全网络访问的问题,实现了应用可以在指定网络环境下进行安全访问并安全操作处理的功能,避免了网络安全问题造成的数据泄露等风险。The present invention provides a method for network access by an application in an intelligent terminal device. The system service determines the application network setting type according to the type of the called interface, and verifies the application's authority according to the parameters passed by the application. If the verification is passed, the network access setting authority is obtained, and the network access setting information specified by the application is set according to the determined application network setting type through a network driver. This solves the problem in the prior art that secure network access cannot be set due to the application's lack of authority, and implements the function that the application can securely access and operate securely in a specified network environment, thereby avoiding the risk of data leakage caused by network security issues.
实施例二Embodiment 2
本发明实施例二提供一种智能终端设备中应用进行网络访问的方法,其中,本实施方式是第三方应用通过安装应用安装包的方式对网络进行设置的,如图3所示,应用进行网络访问的方法中生成应用待安装APK文件的方法流程具体包括:Embodiment 2 of the present invention provides a method for an application in a smart terminal device to access a network. In this embodiment, a third-party application sets up a network by installing an application installation package. As shown in FIG3 , the method flow for generating an APK file to be installed in the method for an application to access a network specifically includes:
步骤301、确定网络访问配置类型;Step 301: Determine the network access configuration type;
在本实施例中,网络访问配置类型包括配置和取消配置;In this embodiment, the network access configuration types include configuration and deconfiguration;
具体地,网络访问配置类型定义为配置启动项信息的预设值,第一预设值为ture,表示网络访问配置类型为配置,第二预设值为false,表示网络访问配置类型为取消配置;Specifically, the network access configuration type is defined as a preset value of the configuration startup item information, the first preset value is true, indicating that the network access configuration type is configuration, and the second preset value is false, indicating that the network access configuration type is cancellation of configuration;
例如:配置启动项定义为whitelist_enable,配置启动项whitelist_enable对应的值为true。For example, if the startup item is defined as whitelist_enable, the value of the startup item whitelist_enable is true.
步骤302、根据预定格式将网络访问配置类型对应的配置启动项信息、网络访问配置信息和用户防火墙权限信息写入清单文件得到应用待安装APK文件。Step 302: Write the configuration startup item information, network access configuration information and user firewall permission information corresponding to the network access configuration type into the manifest file according to a predetermined format to obtain an APK file of the application to be installed.
在本实施例中,网络访问配置信息包括IP地址和/或域名;用户防火墙权限信息包括用户防火墙级别;首先要在platform.xml和AndroidManifest.xml中增加预设的用户防火墙级别android.permission.CONTROL_FIREWALL_RULED;In this embodiment, the network access configuration information includes an IP address and/or a domain name; the user firewall permission information includes a user firewall level; first, the preset user firewall level android.permission.CONTROL_FIREWALL_RULED must be added in platform.xml and AndroidManifest.xml;
例如,IP地址定义为whitelist_ip,域名定义为whitelist_host;IP地址whitelist_ip对应的值为192.168.8.102,域名whitelist_host对应的值为www.ftsafe.com;用户防火墙权限信息定义为android.permission.CONTROL_FIREWALL_RULED;For example, the IP address is defined as whitelist_ip, the domain name is defined as whitelist_host; the value corresponding to the IP address whitelist_ip is 192.168.8.102, and the value corresponding to the domain name whitelist_host is www.ftsafe.com; the user firewall permission information is defined as android.permission.CONTROL_FIREWALL_RULED;
具体地,APK (Android application package)指 Android 应用包,是 Android系统中的一种文件格式。APK 文件包含了应用的所有文件,包括静态资源文件(assets)、库文件(lib)、签名文件(META-INF)、编译资源文件(res)、清单文件(AndroidManifest.xml)、核心代码文件(classes. Dex)和资源映射文件(resources.arsc)等信息,例如,清单文件为:Specifically, APK (Android application package) refers to the Android application package, which is a file format in the Android system. The APK file contains all the files of the application, including static resource files (assets), library files (lib), signature files (META-INF), compiled resource files (res), manifest files (AndroidManifest.xml), core code files (classes. Dex) and resource mapping files (resources.arsc) and other information. For example, the manifest file is:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"xmlns:tools="http://schemas.android.com/tools"
package="com.ft.myapplication">package="com.ft.myapplication">
<users-permission android:name="android.permission.INTERNET" /><users-permission android:name="android.permission.INTERNET" />
<uses-permission android:name=" CONTROL_FIREWALL_RULED" /><uses-permission android:name=" CONTROL_FIREWALL_RULED" />
<application<application
android:allowBackup="true"android:allowBackup="true"
android: icon="@mipmap/ic_launcher"android: icon="@mipmap/ic_launcher"
android: label="@string/app_name"android: label="@string/app_name"
android: round Icon="@mipmap/ic_launcher_round"android: round Icon="@mipmap/ic_launcher_round"
android: supportsRtl="true"android: supportsRtl="true"
android: theme="@style/AppTheme"android: theme="@style/AppTheme"
android: usesCleartextTraffic="true"android: usesCleartextTraffic="true"
tools: targetApi="m">tools:targetApi="m">
<meta-data android: name="WebView whitelist" android: value="true"/><meta-data android: name="WebView whitelist" android: value="true"/>
<meta-data android: name="hostname_whitelist" android: value="https://rc-odhenpos.teknisa.cloud"/>。<meta-data android: name="hostname_whitelist" android: value="https://rc-odhenpos.teknisa.cloud"/>.
具体地,清单文件(AndroidManifest.xml)是编译过的文件,用来描述应用的清单信息,包括包名、应用名、权限、Android四大组件、版本等重要信息。当打包应用时,AndroidManifest.xml 文件会自动生成,并且会被打包进 APK 文件中。当安装应用时,Android 系统会读取这个文件,以确定应用的基本信息和权限要求。Specifically, the manifest file (AndroidManifest.xml) is a compiled file that describes the application's manifest information, including important information such as package name, application name, permissions, four major components of Android, version, etc. When packaging an application, the AndroidManifest.xml file is automatically generated and packaged into the APK file. When installing an application, the Android system reads this file to determine the application's basic information and permission requirements.
一种可实施的方式,步骤302中预定格式具体为键值对格式;In one practicable manner, the predetermined format in step 302 is specifically a key-value pair format;
例如,配置启动项信息为:For example, configure the startup item information as:
name:whitelist_enabled value: true/falsename: whitelist_enabled value: true/false
网络访问配置信息为:The network access configuration information is:
name:whitelist_ip value: 192.168.8.102name: whitelist_ip value: 192.168.8.102
name:whitelist_host value: www.ftsafe.com;name: whitelist_host value: www.ftsafe.com;
一种可实施的方式,清单文件中还包括验证参数、密钥及签名数据;In an implementable manner, the manifest file also includes verification parameters, keys, and signature data;
其中,验证参数可以是随机数,签名数据具体为通过密钥对验证参数进行MD5计算得到的。The verification parameter may be a random number, and the signature data is specifically obtained by performing MD5 calculation on the verification parameter using a key.
进一步地,本发明实施例提供的一种智能终端设备中应用进行网络访问的方法,如图4、图5所示,该方法包括通过安装包进行安装应用的过程,在执行本方法中应用的安装过程之前还包括将预设接口写入并更新至Android系统中,具体地,Android系统包括系统服务(System Server,简称SS)和网络驱动,进一步的,系统服务包括包管理服务(PackageManagerService,简称PKMS)、第一连接服务;Furthermore, an embodiment of the present invention provides a method for network access by an application in a smart terminal device, as shown in FIG4 and FIG5 , the method includes a process of installing an application through an installation package, and before executing the installation process of the application in the method, it also includes writing and updating a preset interface into an Android system, specifically, the Android system includes a system service (System Server, referred to as SS) and a network driver, and further, the system service includes a package management service (PackageManagerService, referred to as PKMS), a first connection service;
一种可实施的方式,如图4所示,本实施方式中访问网络设置为应用首次安装过程中进行的,所述方法具体包括:One practicable manner is shown in FIG4 . In this embodiment, accessing the network setting is performed during the first installation of the application. The method specifically includes:
步骤401、包管理服务获取应用待安装APK文件;Step 401: The package management service obtains the APK file of the application to be installed;
在Android系统中,系统启动时由系统服务启动包管理服务,包管理服务执行安装应用操作;In the Android system, when the system starts, the system service starts the package management service, and the package management service performs the application installation operation;
具体地,系统通过调用预设方法启动包管理服务的,预设方法为PackageManagerService.installPackage;Specifically, the system starts the package management service by calling a preset method, and the preset method is PackageManagerService.installPackage;
一种可实施的方式,安装应用可通过adb install的方式安装。An implementable method is to install the application through adb install.
步骤402、包管理服务调用第一API接口解析应用待安装APK文件中的清单文件,获取配置启动项信息;Step 402: The package management service calls the first API interface to parse the manifest file in the APK file of the application to be installed, and obtains configuration startup item information;
具体地,第一API接口为install Package();Specifically, the first API interface is install Package();
一种可实施的方式,调用第一API接口解析应用待安装APK文件中的清单文件具体为:通过函数对象解析应用待安装APK文件中的清单文件,获取清单文件中的配置启动项信息;In an practicable manner, calling the first API interface to parse the manifest file in the APK file to be installed of the application is specifically as follows: parsing the manifest file in the APK file to be installed of the application through a function object, and obtaining configuration startup item information in the manifest file;
具体地,函数对象为PackageParser。Specifically, the function object is PackageParser.
步骤403、包管理服务根据配置启动项信息确定网络访问配置类型,若网络访问配置类型为配置则执行步骤404;Step 403: The package management service determines the network access configuration type according to the configuration startup item information. If the network access configuration type is configuration, step 404 is executed.
一种可实施的方式,配置启动项信息为whitelist_enabled,第一预设值为true;In an implementable manner, the startup item information is configured as whitelist_enabled, and the first preset value is true;
具体地,配置启动项信息为第一预设值则表示对终端设备中应用访问的网络进行配置,配置完成后只允许访问网络访问配置信息中指定的IP和/或域名,其他未指定的网络均不可访问。Specifically, configuring the startup item information to be the first preset value means configuring the network accessed by the application in the terminal device. After the configuration is completed, only the IP and/or domain name specified in the network access configuration information is allowed to be accessed, and other unspecified networks are inaccessible.
步骤404、包管理服务获取清单文件中的用户防火墙权限信息和网络访问配置信息,将网络访问配置信息和用户防火墙权限信息组织得到应用配置信息,调用第一预设接口将应用配置信息作为参数传入第一连接服务;Step 404: The package management service obtains the user firewall permission information and the network access configuration information in the manifest file, organizes the network access configuration information and the user firewall permission information to obtain the application configuration information, and calls the first preset interface to pass the application configuration information as a parameter to the first connection service;
在本实施例中,包管理服务获取网络访问配置信息具体包括:包管理服务判断清单文件中是否存在IP地址,是则将IP地址作为网络访问配置信息,否则获取清单文件中的域名,对域名进行解析得到IP地址,将IP地址作为网络访问配置信息;In this embodiment, the package management service obtains the network access configuration information specifically including: the package management service determines whether the IP address exists in the list file, and if so, uses the IP address as the network access configuration information; otherwise, obtains the domain name in the list file, resolves the domain name to obtain the IP address, and uses the IP address as the network access configuration information;
一种可实施的方式,步骤404之前还包括包管理服务判断清单文件是否存在用户防火墙权限信息,若是则将应用待安装APK文件对应的应用添加到预设权限组,执行步骤404,若否则结束;In one practicable manner, before step 404, the package management service also includes determining whether the manifest file contains user firewall permission information, if so, adding the application corresponding to the APK file to be installed to the preset permission group, and executing step 404, if not, ending;
具体地,将应用待安装APK文件对应的应用添加到预设权限组具体为:在UIDMap和Android_filesystem_config.h中增加AID_CONTROL_FIREWALL 1098。Specifically, adding the application corresponding to the APK file to be installed to the preset permission group is as follows: adding AID_CONTROL_FIREWALL 1098 in UIDMap and Android_filesystem_config.h.
具体的,第一预设接口为CS.addWhitelist。Specifically, the first preset interface is CS.addWhitelist.
步骤405、第一连接服务根据被调用的接口类型确定应用网络设置类型为第一类型,获取应用配置信息,根据应用配置信息判断是否存在用户防火墙权限信息,是则执行步骤406,否则结束;Step 405: The first connection service determines that the application network setting type is the first type according to the called interface type, obtains application configuration information, and determines whether there is user firewall permission information according to the application configuration information. If yes, execute step 406, otherwise terminate;
一种可实施的方式,第一连接服务包括网络连接服务(ConnectivityService,简称CS)和网络管理服务(NetworkManagementService,简称NMS),步骤404中,包管理服务调用第一预设接口将应用配置信息作为参数传入第一连接服务具体为:包管理服务调用第一预设接口将应用配置信息作为参数传入网络连接服务;In one practicable manner, the first connection service includes a network connection service (Connectivity Service, CS for short) and a network management service (Network Management Service, NMS for short). In step 404, the package management service calls the first preset interface to pass the application configuration information as a parameter to the first connection service. Specifically, the package management service calls the first preset interface to pass the application configuration information as a parameter to the network connection service.
具体地,步骤405具体为:网络连接服务根据被调用的接口类型确定应用网络设置类型为第一类型,获取应用配置信息,判断应用配置信息中是否存在用户防火墙权限信息,是则执行步骤406,否则结束;Specifically, step 405 is as follows: the network connection service determines that the application network setting type is the first type according to the called interface type, obtains the application configuration information, and determines whether there is user firewall permission information in the application configuration information. If yes, step 406 is executed, otherwise, the process ends;
进一步地,判断是否存在用户防火墙权限信息具体为:判断应用配置信息中android.permission.CONTROL_FIREWALL_RULED是否存在对应的值,若存在则表示存在用户防火墙权限信息,否则不存在用户防火墙权限信息;Further, judging whether there is user firewall permission information is specifically as follows: judging whether there is a corresponding value of android.permission.CONTROL_FIREWALL_RULED in the application configuration information, if so, it indicates that there is user firewall permission information, otherwise, there is no user firewall permission information;
一种可实施的方式,当根据应用配置信息判断存在用户防火墙权限信息时还包括:系统服务获取应用配置信息中的验签数据进行代码验签,验签通过则获取网络配置权限,执行步骤406,验签未通过则报错,结束,验签数据包括指定参数、验证密钥及签名数据;In an practicable manner, when it is determined that there is user firewall permission information according to the application configuration information, the system service obtains the verification data in the application configuration information to perform code verification, and if the verification passes, the network configuration permission is obtained, and step 406 is executed; if the verification fails, an error is reported, and the process ends, and the verification data includes the specified parameters, the verification key, and the signature data;
具体地,系统服务获取应用配置信息中的验签数据进行代码验签具体为:系统服务获取指定参数、验证密钥及签名数据,通过验证密钥对指定参数进行计算得到第一数据,判断第一数据与签名数据是否一致,是则验签通过,否则验签未通过。Specifically, the system service obtains the verification data in the application configuration information to perform code verification as follows: the system service obtains the specified parameters, the verification key and the signature data, calculates the specified parameters through the verification key to obtain the first data, and determines whether the first data is consistent with the signature data. If so, the verification passes, otherwise the verification fails.
步骤406、第一连接服务获取自定义IP地址列表,将应用配置信息中的网络访问配置信息保存至自定义IP地址列表中,将网络访问配置信息作为参数传入网络驱动;Step 406: The first connection service obtains a custom IP address list, saves the network access configuration information in the application configuration information into the custom IP address list, and passes the network access configuration information as a parameter to the network driver;
具体地,步骤406具体为:网络连接服务获取自定义IP地址列表,将应用配置信息中的网络访问配置信息保存至自定义IP地址列表中,调用第一预设方法将网络访问配置信息作为参数传入网络管理服务,网络管理服务调用第二预设方法将网络访问配置信息作为参数传入网络驱动;Specifically, step 406 is as follows: the network connection service obtains the custom IP address list, saves the network access configuration information in the application configuration information into the custom IP address list, calls the first preset method to pass the network access configuration information as a parameter to the network management service, and the network management service calls the second preset method to pass the network access configuration information as a parameter to the network driver;
具体地,第一预设方法为NMS.enableWhitelist,第二预设方法为INetd.enableWhitelist。Specifically, the first preset method is NMS.enableWhitelist, and the second preset method is INetd.enableWhitelist.
步骤407、网络驱动通过配置指令将网络访问配置信息配置到过滤白名单规则表中,结束。Step 407: The network driver configures the network access configuration information into the filtering whitelist rule table through the configuration instruction, and ends.
一种可实施的方式,步骤407具体为网络驱动向网络防火墙工具发送配置指令,网络防火墙工具接收到配置指令后将传入的网络访问配置信息配置到过滤白名单规则表中;In one practicable manner, step 407 is specifically that the network driver sends a configuration instruction to the network firewall tool, and after receiving the configuration instruction, the network firewall tool configures the incoming network access configuration information into the filtering whitelist rule table;
具体的,网络驱动包括Netd本地服务和防火墙控制器;Specifically, the network drivers include Netd local service and firewall controller;
进一步地,网络管理服务调用第二预设方法将网络访问配置信息作为参数传入网络驱动具体为:网络管理服务调用第二预设方法将网络访问配置信息作为参数传入Netd本地服务;Furthermore, the network management service calls the second preset method to pass the network access configuration information as a parameter to the network driver specifically: the network management service calls the second preset method to pass the network access configuration information as a parameter to the Netd local service;
进一步地,步骤407具体为:Netd本地服务通过调用第三预设方法将网络访问配置信息作为参数传入防火墙控制器,防火墙控制器向网络防火墙工具发送配置指令,网络防火墙工具接收到配置指令后将传入的网络访问配置信息配置到过滤白名单规则表中;Further, step 407 is specifically as follows: the Netd local service passes the network access configuration information as a parameter to the firewall controller by calling the third preset method, the firewall controller sends a configuration instruction to the network firewall tool, and the network firewall tool configures the passed-in network access configuration information into the filtering whitelist rule table after receiving the configuration instruction;
具体地,Netd本地服务为NetdNativeService(简称NNS),第三预设方法为FC.enableWhitelist;防火墙控制器为Firewall Controller(简称FC);配置指令具体为将传入的网络访问配置信息添加到过滤白名单规则表中。Specifically, the Netd local service is NetdNativeService (NNS for short), the third preset method is FC.enableWhitelist; the firewall controller is Firewall Controller (FC for short); and the configuration instruction is specifically to add the incoming network access configuration information to the filtering whitelist rule table.
一种可实施的方式,网络防火墙工具执行配置指令具体用到了Linux网络驱动的技术,具体为:执行Linux iptables指令可以将网络访问配置信息添加至过滤白名单规则表;In one practicable manner, the network firewall tool executes configuration instructions using the Linux network driver technology, specifically: executing Linux iptables instructions can add network access configuration information to the filtering whitelist rule table;
具体地,网络防火墙工具维护4张表和5个链,所有涉及到防火墙规则的数据均会被写入这些表和链,其中,4张表分别是fitler表(过滤白名单规则表)、nat表(地址转化规则表)、mangle表(修改数据标记位规则表)、raw表(跟踪数据规则表),5个链分别是INPUT(入站数据过滤)、OUT(出站数据过滤)、FORWARD(转发数据过滤)、PREROUTING(路由前规则)和POSTROUNTING(路由后规则);Specifically, the network firewall tool maintains 4 tables and 5 chains. All data related to firewall rules will be written into these tables and chains. The 4 tables are fitler table (filter whitelist rule table), nat table (address conversion rule table), mangle table (modify data mark bit rule table), and raw table (track data rule table). The 5 chains are INPUT (inbound data filtering), OUT (outbound data filtering), FORWARD (forwarding data filtering), PREROUTING (pre-routing rules) and POSTROUNTING (post-routing rules).
例如,防火墙控制器发送iptables -P OUTPUT DROP指令,网络防火墙工具将输出数据全部放弃掉,发送iptables -P INPUT DROP指令,网络防火墙工具将输入数据全部放弃掉;For example, the firewall controller sends the iptables -P OUTPUT DROP command, and the network firewall tool discards all output data. It sends the iptables -P INPUT DROP command, and the network firewall tool discards all input data.
防火墙控制器发送iptables -I OUTPUT -s 192.168.8.102 -j ACCEPT指令,网络防火墙工具就可以将IP地址192.168.8.102写入fitler表,表示只接受IP地址为192.168.8.102的输出数据,发送iptables -I INPUT -s 192.168.8.102 -j ACCEPT指令,表示只接受IP地址为192.168.8.102的输入数据,其中-I为插入;The firewall controller sends the iptables -I OUTPUT -s 192.168.8.102 -j ACCEPT command, and the network firewall tool can write the IP address 192.168.8.102 into the fitler table, indicating that only the output data with the IP address 192.168.8.102 is accepted, and sends the iptables -I INPUT -s 192.168.8.102 -j ACCEPT command, indicating that only the input data with the IP address 192.168.8.102 is accepted, where -I means insert;
一种可实施的方式,网络驱动发送的配置指令中包括用户防火墙权限组信息,例如配置指令为:iptables -I OUTPUT -s 192.168.8.102 -uid-owner=1098-j ACCEPT。In one practicable manner, the configuration instruction sent by the network driver includes user firewall permission group information, for example, the configuration instruction is: iptables -I OUTPUT -s 192.168.8.102 -uid-owner=1098-j ACCEPT.
在本实施例中,一种可实施的方式,如图5所示,提供了又一种智能终端设备中应用进行网络访问的方法,具体地,本实施方式中访问网络设置为应用安装后在升级过程中进行的,所述方法具体包括:In this embodiment, an implementable manner, as shown in FIG. 5 , provides another method for an application in a smart terminal device to access a network. Specifically, in this embodiment, access to the network is set to be performed during an upgrade process after the application is installed. The method specifically includes:
步骤501、包管理服务获取应用待安装APK文件;Step 501: The package management service obtains the APK file of the application to be installed;
在Android系统中,系统启动包管理服务(PackageManagerService,简称PKMS),通过包管理服务执行升级安装应用的过程;In the Android system, the system starts the Package Manager Service (PKMS) and executes the process of upgrading and installing applications through the package manager service.
具体地,系统通过调用预设方法启动包管理服务的,预设方法为PackageManagerService.updatePackage;Specifically, the system starts the package management service by calling a preset method, and the preset method is PackageManagerService.updatePackage;
一种可实施的方式,可通过远程推送APK文件的方式安装或升级应用。An implementable method is to install or upgrade an application by remotely pushing an APK file.
步骤502、包管理服务调用第二API接口解析应用待安装APK文件中的清单文件,获取配置启动项信息;Step 502: The package management service calls the second API interface to parse the manifest file in the APK file of the application to be installed, and obtains configuration startup item information;
具体地,第二API接口为updatePackage();Specifically, the second API interface is updatePackage();
一种可实施的方式,调用第二API接口解析应用待安装APK文件中的清单文件具体为:通过函数对象解析应用待安装APK文件中的清单文件,获取清单文件中的配置启动项信息;In an practicable manner, calling the second API interface to parse the manifest file in the APK file to be installed of the application is specifically as follows: parsing the manifest file in the APK file to be installed of the application through a function object, and obtaining configuration startup item information in the manifest file;
具体地,函数对象为Package Parser。Specifically, the function object is Package Parser.
步骤503、包管理服务根据配置启动项信息确定网络访问配置类型,若网络访问配置类型为配置则执行步骤504,若网络访问配置类型为取消配置则执行步骤512;Step 503, the package management service determines the network access configuration type according to the configuration startup item information, and if the network access configuration type is configuration, execute step 504; if the network access configuration type is cancellation of configuration, execute step 512;
一种可实施的方式,配置启动项信息为whitelist_enabled,第一预设值为true;In an implementable manner, the startup item information is configured as whitelist_enabled, and the first preset value is true;
具体地,如配置启动项信息为第一预设值则表示对终端设备中应用访问的网络进行配置,配置完成后只允许应用访问网络访问配置信息中指定的IP/域名,其他未指定的网络均不可访问;Specifically, if the configuration startup item information is the first preset value, it means that the network accessed by the application in the terminal device is configured. After the configuration is completed, the application is only allowed to access the IP/domain name specified in the network access configuration information, and other unspecified networks are inaccessible;
一种可实施的方式,配置启动项信息还可具体为第二预设值;其中,第二预设值为false;In an practicable manner, the configuration startup item information may further be specifically a second preset value; wherein the second preset value is false;
具体地,如配置启动项信息为第二预设值则表示对终端设备中应用访问的网络取消配置,即允许应用访问所有网络。Specifically, if the configuration startup item information is the second preset value, it means that the network accessed by the application in the terminal device is canceled, that is, the application is allowed to access all networks.
步骤504、包管理服务获取清单文件中的用户防火墙权限信息和网络访问配置信息,将网络访问配置信息和用户防火墙权限信息组织得到应用配置信息,调用第一预设接口将应用配置信息作为参数传入第一连接服务;Step 504: The package management service obtains the user firewall permission information and the network access configuration information in the manifest file, organizes the network access configuration information and the user firewall permission information to obtain the application configuration information, and calls the first preset interface to pass the application configuration information as a parameter to the first connection service;
在本实施例中,包管理服务获取网络访问配置信息具体包括:包管理服务判断清单文件中是否存在IP地址,是则将IP地址作为网络访问配置信息,否则获取清单文件中的域名,对域名进行解析得到IP地址,将IP地址作为网络访问配置信息;In this embodiment, the package management service obtains the network access configuration information specifically including: the package management service determines whether the IP address exists in the list file, and if so, uses the IP address as the network access configuration information; otherwise, obtains the domain name in the list file, resolves the domain name to obtain the IP address, and uses the IP address as the network access configuration information;
一种可实施的方式,步骤504之前还包括包管理服务判断清单文件是否存在用户防火墙权限信息,若是则将应用待安装APK文件对应的应用添加到预设权限组,执行步骤504,若否则结束;In one practicable manner, before step 504, the package management service also includes determining whether the manifest file contains user firewall permission information, if so, adding the application corresponding to the APK file to be installed to the preset permission group, executing step 504, and if not, ending;
具体地,将应用待安装APK文件对应的应用添加到预设权限组具体为:在UIDMap和Android_filesystem_config.h中增加AID_CONTROL_FIREWALL 1098。Specifically, adding the application corresponding to the APK file to be installed to the preset permission group specifically includes: adding AID_CONTROL_FIREWALL 1098 in UIDMap and Android_filesystem_config.h.
具体的,第一预设接口为CS.addWhitelist;Specifically, the first preset interface is CS.addWhitelist;
在本实施例中,第一连接服务包括:网络连接服务和网络管理服务;In this embodiment, the first connection service includes: a network connection service and a network management service;
具体地,步骤504中包管理服务调用第一预设接口将应用配置信息作为参数传入第一连接服务具体为:包管理服务调用第一预设接口将应用配置信息作为参数传入网络连接服务。Specifically, in step 504, the package management service calls the first preset interface to pass the application configuration information as a parameter to the first connection service. Specifically, the package management service calls the first preset interface to pass the application configuration information as a parameter to the network connection service.
步骤505、第一连接服务根据被调用的接口类型确定应用网络设置类型为第一类型,获取应用配置信息,根据应用配置信息判断是否存在用户防火墙权限信息,是则执行步骤506,否则结束;Step 505: The first connection service determines that the application network setting type is the first type according to the called interface type, obtains the application configuration information, and determines whether there is user firewall authority information according to the application configuration information. If yes, execute step 506, otherwise terminate;
在本实施例中,第一连接服务包括:网络连接服务和网络管理服务;In this embodiment, the first connection service includes: a network connection service and a network management service;
具体地,步骤505具体为:网络连接服务根据被调用的接口类型确定应用网络设置类型为第一类型,获取应用配置信息,判断是否存在用户防火墙权限信息,是则执行步骤506,否则结束;Specifically, step 505 is as follows: the network connection service determines that the application network setting type is the first type according to the called interface type, obtains the application configuration information, and determines whether there is user firewall permission information. If yes, step 506 is executed, otherwise, the process ends;
步骤506、第一连接服务获取自定义IP地址列表,判断自定义IP地址列表中是否存在网络访问配置信息,是则执行步骤507,否则执行步骤510;Step 506: The first connection service obtains a custom IP address list and determines whether there is network access configuration information in the custom IP address list. If yes, execute step 507; otherwise, execute step 510.
具体地,步骤506具体为:网络连接服务获取自定义IP地址列表,判断列表中是否存在网络访问配置信息,是则执行步骤507,否则执行步骤510;Specifically, step 506 is as follows: the network connection service obtains a custom IP address list, and determines whether there is network access configuration information in the list, if yes, executes step 507, otherwise executes step 510;
步骤507、第一连接服务获取应用配置信息中的网络访问配置信息,判断自定义IP地址列表中的网络访问配置信息与应用配置信息中的网络访问配置信息是否相同,若是则结束,若否则执行步骤508;Step 507: The first connection service obtains the network access configuration information in the application configuration information, and determines whether the network access configuration information in the custom IP address list is the same as the network access configuration information in the application configuration information. If yes, the process ends; otherwise, the process proceeds to step 508.
具体地,步骤507具体为:网络连接服务获取应用配置信息中的网络访问配置信息,判断自定义IP地址列表中的网络访问配置信息与应用配置信息中的网络访问配置信息是否相同,若是则结束,若否则执行步骤508;Specifically, step 507 is as follows: the network connection service obtains the network access configuration information in the application configuration information, and determines whether the network access configuration information in the custom IP address list is the same as the network access configuration information in the application configuration information. If so, the process ends; otherwise, the process executes step 508;
步骤508、第一连接服务将自定义IP地址列表中的网络访问配置信息从自定义IP地址列表中删除,将自定义IP地址列表中的网络访问配置信息作为参数传入网络驱动,执行步骤509;Step 508: The first connection service deletes the network access configuration information in the custom IP address list from the custom IP address list, and passes the network access configuration information in the custom IP address list as a parameter to the network driver, and executes step 509;
具体地,步骤508具体为:网络连接服务将自定义IP地址列表中的网络访问配置信息从自定义IP地址列表中删除,调用第四预设方法将自定义IP地址列表中的网络访问配置信息作为参数传入网络管理服务,网络管理服务调用第五预设方法将自定义IP地址列表中的网络访问配置信息作为参数传入网络驱动;Specifically, step 508 is as follows: the network connection service deletes the network access configuration information in the custom IP address list from the custom IP address list, calls the fourth preset method to pass the network access configuration information in the custom IP address list as a parameter to the network management service, and the network management service calls the fifth preset method to pass the network access configuration information in the custom IP address list as a parameter to the network driver;
具体地,第四预设方法为NMS.disableWhitelist,第五预设方法为INetd.disableWhitelist。Specifically, the fourth preset method is NMS.disableWhitelist, and the fifth preset method is INetd.disableWhitelist.
步骤509、网络驱动通过删除指令将自定义IP地址列表中的网络访问配置信息从过滤白名单规则表中删除,执行步骤510;Step 509: The network driver deletes the network access configuration information in the custom IP address list from the filtering whitelist rule table through a delete instruction, and then executes step 510;
一种可实施的方式,步骤509具体为网络驱动向网络防火墙工具发送删除指令,网络防火墙工具接收到删除指令后将传入的自定义IP地址列表中的网络访问配置信息从过滤白名单规则表中删除;In one practicable manner, step 509 is specifically that the network driver sends a deletion instruction to the network firewall tool, and after receiving the deletion instruction, the network firewall tool deletes the network access configuration information in the input custom IP address list from the filtering whitelist rule table;
具体的,网络驱动包括Netd本地服务和防火墙控制器;Specifically, the network drivers include Netd local service and firewall controller;
进一步地,网络管理服务调用第六预设方法将自定义IP地址列表中的网络访问配置信息作为参数传入网络驱动具体为:网络管理服务调用第六预设方法将自定义IP地址列表中的网络访问配置信息作为参数传入Netd本地服务;Further, the network management service calls the sixth preset method to pass the network access configuration information in the custom IP address list as a parameter to the network driver. Specifically, the network management service calls the sixth preset method to pass the network access configuration information in the custom IP address list as a parameter to the Netd local service;
进一步地,步骤509具体为:Netd本地服务通过调用第六预设方法将自定义IP地址列表中的网络访问配置信息作为参数传入防火墙控制器,防火墙控制器向网络防火墙工具发送删除指令,网络防火墙工具接收到删除指令后将传入的自定义IP地址列表中的网络访问配置信息从过滤白名单规则表中删除;Further, step 509 is specifically as follows: the Netd local service passes the network access configuration information in the custom IP address list as a parameter to the firewall controller by calling the sixth preset method, and the firewall controller sends a delete instruction to the network firewall tool, and after receiving the delete instruction, the network firewall tool deletes the network access configuration information in the custom IP address list passed in from the filtering whitelist rule table;
步骤510、第一连接服务将应用配置信息中的网络访问配置信息保存至自定义IP地址列表中,将应用配置信息中的网络访问配置信息作为参数传入网络驱动,执行步骤511;Step 510: The first connection service saves the network access configuration information in the application configuration information into the custom IP address list, and passes the network access configuration information in the application configuration information as a parameter to the network driver, and executes step 511;
具体地,步骤510具体为:网络连接服务将应用配置信息中的网络访问配置信息保存至自定义IP地址列表中,调用第一预设方法将网络访问配置信息作为参数传入网络管理服务,网络管理服务调用第二预设方法将网络访问配置信息作为参数传入网络驱动;Specifically, step 510 is as follows: the network connection service saves the network access configuration information in the application configuration information into the custom IP address list, calls the first preset method to pass the network access configuration information as a parameter to the network management service, and the network management service calls the second preset method to pass the network access configuration information as a parameter to the network driver;
其中,第一预设方法为NMS.enableWhitelist,第二预设方法为INetd.enableWhitelist。Among them, the first preset method is NMS.enableWhitelist, and the second preset method is INetd.enableWhitelist.
步骤511、网络驱动通过配置指令将应用配置信息中的网络访问配置信息配置到过滤白名单规则表中,结束;Step 511: The network driver configures the network access configuration information in the application configuration information into the filtering whitelist rule table through the configuration instruction, and ends;
一种可实施的方式,步骤511具体为网络驱动向网络防火墙工具发送配置指令,网络防火墙工具接收到配置指令后将传入的网络访问配置信息配置到过滤白名单规则表中;In one practicable manner, step 511 is specifically that the network driver sends a configuration instruction to the network firewall tool, and after receiving the configuration instruction, the network firewall tool configures the incoming network access configuration information into a filtering whitelist rule table;
具体的,网络驱动包括Netd本地服务和防火墙控制器;Specifically, the network drivers include Netd local service and firewall controller;
进一步地,网络管理服务调用第二预设方法将网络访问配置信息作为参数传入网络驱动具体为:网络管理服务调用第二预设方法将网络访问配置信息作为参数传入Netd本地服务;Furthermore, the network management service calls the second preset method to pass the network access configuration information as a parameter to the network driver specifically: the network management service calls the second preset method to pass the network access configuration information as a parameter to the Netd local service;
进一步地,步骤511具体为:Netd本地服务通过调用第三预设方法将网络访问配置信息作为参数传入防火墙控制器,防火墙控制器向网络防火墙工具发送配置指令,网络防火墙工具接收到配置指令后将传入的网络访问配置信息配置到过滤白名单规则表中;Further, step 511 is specifically as follows: the Netd local service passes the network access configuration information as a parameter to the firewall controller by calling the third preset method, the firewall controller sends a configuration instruction to the network firewall tool, and the network firewall tool configures the passed-in network access configuration information into the filtering whitelist rule table after receiving the configuration instruction;
具体地,Netd本地服务为NetdNativeService(简称NNS),第三预设方法为FC.enableWhitelist;防火墙控制器为Firewall Controller(简称FC);配置指令具体为将传入的网络访问配置信息添加到过滤白名单规则表中。Specifically, the Netd local service is NetdNativeService (NNS for short), the third preset method is FC.enableWhitelist; the firewall controller is Firewall Controller (FC for short); and the configuration instruction is specifically to add the incoming network access configuration information to the filtering whitelist rule table.
步骤512、包管理服务获取清单文件中的用户防火墙权限信息和网络访问配置信息,将网络访问配置信息和用户防火墙权限信息组织得到应用配置信息,调用第二预设接口将应用配置信息作为参数传入第一连接服务;Step 512: The package management service obtains the user firewall permission information and the network access configuration information in the manifest file, organizes the network access configuration information and the user firewall permission information to obtain the application configuration information, and calls the second preset interface to pass the application configuration information as a parameter to the first connection service;
具体的,第二预设接口为CS.RemoveWhitelist。Specifically, the second preset interface is CS.RemoveWhitelist.
步骤513、第一连接服务根据被调用的接口类型确定应用网络设置类型为第二类型,获取应用配置信息,根据应用配置信息判断是否存在用户防火墙权限信息,是则执行步骤514,否则结束;Step 513: The first connection service determines that the application network setting type is the second type according to the called interface type, obtains application configuration information, and determines whether there is user firewall permission information according to the application configuration information. If yes, execute step 514, otherwise terminate.
一种可实施的方式,第一连接服务包括网络连接服务和网络管理服务,步骤512中,包管理服务调用第二预设接口将应用配置信息作为参数传入第一连接服务具体为:包管理服务调用第二预设接口将应用配置信息作为参数传入网络连接服务;In one practicable manner, the first connection service includes a network connection service and a network management service, and in step 512, the package management service calls the second preset interface to pass the application configuration information as a parameter to the first connection service, specifically: the package management service calls the second preset interface to pass the application configuration information as a parameter to the network connection service;
具体地,步骤513为:网络连接服务根据被调用的接口类型确定应用网络设置类型为第二类型,获取应用配置信息,判断应用配置信息中是否存在用户防火墙权限信息,是则执行步骤514,否则结束;Specifically, step 513 is: the network connection service determines that the application network setting type is the second type according to the called interface type, obtains the application configuration information, and determines whether there is user firewall permission information in the application configuration information. If yes, step 514 is executed, otherwise, the process ends;
进一步地,判断应用配置信息中是否存在用户防火墙权限信息具体为:判断应用配置信息中android.permission.CONTROL_FIREWALL_RULED是否存在对应的值,若存在则表示存在用户防火墙权限信息,否则不存在用户防火墙权限信息;Further, judging whether there is user firewall permission information in the application configuration information is specifically as follows: judging whether there is a corresponding value of android.permission.CONTROL_FIREWALL_RULED in the application configuration information, if so, it indicates that there is user firewall permission information, otherwise, there is no user firewall permission information;
步骤514、第一连接服务获取自定义IP地址列表,判断自定义IP地址列表中是否存在网络访问配置信息,是则将自定义IP地址列表中的网络访问配置信息删除,将网络访问配置信息作为参数传入网络驱动,执行步骤515,否则结束;Step 514: The first connection service obtains a custom IP address list, determines whether there is network access configuration information in the custom IP address list, and if so, deletes the network access configuration information in the custom IP address list, and passes the network access configuration information as a parameter to the network driver, and executes step 515; otherwise, the process ends;
一种可实施的方式,步骤514具体包括:第一连接服务获取应用配置信息中的网络访问配置信息,获取自定义IP地址列表,判断自定义IP列表中是否存在网络访问配置信息,是则将网络访问配置信息从自定义IP地址列表中删除,将网络访问配置信息作为参数传入网络驱动,执行步骤515,否则结束;In an practicable manner, step 514 specifically includes: the first connection service obtains the network access configuration information in the application configuration information, obtains the custom IP address list, determines whether the network access configuration information exists in the custom IP address list, and if so, deletes the network access configuration information from the custom IP address list, passes the network access configuration information as a parameter to the network driver, and executes step 515, otherwise, ends;
或者,步骤514具体为:网络连接服务获取自定义IP地址列表,将自定义IP地址列表中的网络访问配置信息删除,调用第四预设方法将网络访问配置信息作为参数传入网络管理服务,网络管理服务调用第五预设方法将网络访问配置信息作为参数传入网络驱动;Alternatively, step 514 is specifically as follows: the network connection service obtains a custom IP address list, deletes the network access configuration information in the custom IP address list, calls the fourth preset method to pass the network access configuration information as a parameter to the network management service, and the network management service calls the fifth preset method to pass the network access configuration information as a parameter to the network driver;
具体地,第四预设方法为NMS.disableWhitelist,第五预设方法为INetd.disableWhitelist。Specifically, the fourth preset method is NMS.disableWhitelist, and the fifth preset method is INetd.disableWhitelist.
步骤515、网络驱动通过删除指令将网络访问配置信息从过滤白名单规则表中删除,结束。Step 515: The network driver deletes the network access configuration information from the filtering whitelist rule table through a delete instruction, and the process ends.
一种可实施的方式,步骤515具体为网络驱动向网络防火墙工具发送删除指令,网络防火墙工具接收到删除指令后将传入的网络访问配置信息从过滤白名单规则表中删除;In one practicable manner, step 515 is specifically that the network driver sends a deletion instruction to the network firewall tool, and the network firewall tool deletes the incoming network access configuration information from the filtering whitelist rule table after receiving the deletion instruction;
具体的,网络驱动包括Netd本地服务和防火墙控制器;Specifically, the network drivers include Netd local service and firewall controller;
进一步地,网络管理服务调用第六预设方法将网络访问配置信息作为参数传入网络驱动具体为:网络管理服务调用第六预设方法将网络访问配置信息作为参数传入Netd本地服务;Further, the network management service calls the sixth preset method to pass the network access configuration information as a parameter to the network driver specifically: the network management service calls the sixth preset method to pass the network access configuration information as a parameter to the Netd local service;
进一步地,步骤515具体为:Netd本地服务通过调用第六预设方法将网络访问配置信息作为参数传入防火墙控制器,防火墙控制器向网络防火墙工具发送删除指令,网络防火墙工具接收到删除指令后将传入的网络访问配置信息从过滤白名单规则表中删除。Further, step 515 is specifically as follows: the Netd local service passes the network access configuration information as a parameter to the firewall controller by calling the sixth preset method, the firewall controller sends a deletion instruction to the network firewall tool, and after receiving the deletion instruction, the network firewall tool deletes the passed network access configuration information from the filtering whitelist rule table.
一种可实施的方式,当自定义IP地址列表中存在多个IP地址时,步骤514中将网络访问配置信息作为参数传入网络驱动具体为:遍历获取IP地址,依次将网络访问配置信息作为参数传入网络驱动,依次执行步骤515,直至列表为空。An implementable method is that when there are multiple IP addresses in the custom IP address list, the network access configuration information is passed as a parameter to the network driver in step 514 as follows: traverse and obtain the IP addresses, pass the network access configuration information as a parameter to the network driver in turn, and execute step 515 in turn until the list is empty.
一种可实施的方式,当根据应用配置信息判断存在用户防火墙权限信息时还包括:系统服务获取应用配置信息中的验签数据进行代码验签,验签通过则获取网络配置权限,执行步骤510-511,验签未通过则报错,结束,验签数据包括指定参数、验证密钥及签名数据;In an practicable manner, when it is determined that there is user firewall permission information according to the application configuration information, the method further includes: the system service obtains the verification data in the application configuration information to perform code verification, and if the verification passes, the network configuration permission is obtained, and steps 510-511 are executed; if the verification fails, an error is reported, and the process ends, and the verification data includes the specified parameters, the verification key, and the signature data;
具体地,系统服务获取应用配置信息中的验签数据进行代码验签具体为:系统服务获取指定参数、验证密钥及签名数据,通过验证密钥对指定参数进行计算得到第一数据,判断第一数据与签名数据是否一致,是则验签通过,获取网络配置权限,否则验签未通过,报错,结束。Specifically, the system service obtains the verification data in the application configuration information to perform code verification as follows: the system service obtains the specified parameters, verification key and signature data, calculates the specified parameters through the verification key to obtain the first data, and determines whether the first data is consistent with the signature data. If so, the verification passes and the network configuration permission is obtained. Otherwise, the verification fails, an error is reported, and the process ends.
本实施例中,一种可实施的方式,当所述智能终端设备关机时,网络驱动通过网络防火墙工具将过滤白名单规则表中添加的网络访问配置信息全部删除;In this embodiment, in one practicable manner, when the intelligent terminal device is turned off, the network driver deletes all the network access configuration information added to the filtering whitelist rule table through the network firewall tool;
本实施例中,一种可实施的方式,当所述智能终端设备开机重启时,所述系统服务通过调用CS.systemReady()方法获取保存的自定义IP地址列表,遍历自定义IP地址列表,顺序获取自定义IP地址列表中的网络访问配置信息并执行步骤510至步骤511。In this embodiment, an implementable method is that when the smart terminal device is powered on and restarted, the system service obtains the saved custom IP address list by calling the CS.systemReady() method, traverses the custom IP address list, sequentially obtains the network access configuration information in the custom IP address list and executes steps 510 to 511.
本发明实施例提供的一种智能终端设备中应用进行网络访问的方法,适用于安装了Android系统的智能终端设备,在本实施例中,智能终端设备包括应用,智能终端设备中的应用通过连接网络完成用户具体操作。本方案通过在安装应用或升级应用过程中根据网络访问配置信息对访问信息进行设置,实现了应用可以在指定网络环境下进行安全操作处理的功能,避免了网络安全问题造成的数据泄露等风险。The embodiment of the present invention provides a method for an application in a smart terminal device to access a network, which is applicable to a smart terminal device installed with an Android system. In this embodiment, the smart terminal device includes an application, and the application in the smart terminal device completes a specific user operation by connecting to a network. This solution sets access information according to network access configuration information during the installation or upgrade of an application, thereby realizing a function in which an application can perform secure operation processing in a specified network environment, thereby avoiding risks such as data leakage caused by network security issues.
实施例三Embodiment 3
本发明实施例三提供一种智能终端设备中应用进行网络访问的方法,其中,本实施方式是第三方应用通过接口函数的方式进行实现的,本发明实施例提供的一种智能终端设备中应用进行网络访问的方法,在执行本方法之前包括提供接口函数SDK供第三方应用调用,以及将预设接口写入并更新至智能终端设备Android系统中,具体地,智能终端设备包括系统服务和网络驱动,智能终端设备还包括POS管理服务(应用进程),进一步的,系统服务包括连接服务(Connectivity Service,简称CS)和网络管理服务(NetworkManagementService,简称NMS),进一步的,预先在POS管理服务中定义ICM接口,ICM接口包括第一ICM接口和第二ICM接口,其中,第一ICM接口表示配置白名单,第二ICM接口表示清除白名单;Embodiment 3 of the present invention provides a method for an application in a smart terminal device to access a network, wherein the present embodiment is implemented by a third-party application through an interface function. The embodiment of the present invention provides a method for an application in a smart terminal device to access a network, which includes providing an interface function SDK for a third-party application to call before executing the method, and writing and updating a preset interface into an Android system of the smart terminal device. Specifically, the smart terminal device includes a system service and a network driver, and the smart terminal device also includes a POS management service (application process). Further, the system service includes a connectivity service (CS) and a network management service (NMS). Further, an ICM interface is pre-defined in the POS management service, and the ICM interface includes a first ICM interface and a second ICM interface, wherein the first ICM interface represents configuring a whitelist, and the second ICM interface represents clearing a whitelist.
如图6所示,本发明实施例提供的一种智能终端设备中应用进行网络访问的方法,具体包括:As shown in FIG6 , a method for an application in a smart terminal device to access a network is provided in an embodiment of the present invention, and specifically includes:
当POS管理服务被第三方应用通过第一ICM接口调用时,POS管理服务调用系统服务的第一接口,执行步骤601,当POS管理服务被第三方应用通过第二ICM接口调用时,POS管理服务调用系统服务的第二接口,执行步骤605;When the POS management service is called by the third-party application through the first ICM interface, the POS management service calls the first interface of the system service and executes step 601. When the POS management service is called by the third-party application through the second ICM interface, the POS management service calls the second interface of the system service and executes step 605.
在本实施例中,该方法还包括:生成接口函数SDK,第三方应用通过AIDL方式绑定POSsever,建立一个连接和初始化的操作,并通过SDK中的接口调用POSsever,并将待配置的IP地址和应用信息作为参数传入;例如,调用第一接口时传入的参数为:enableWhitelist(String IP, String packageName),调用第二接口时传入的参数为:disableWhitelist(String IP, String packageName);In this embodiment, the method further includes: generating an interface function SDK, the third-party application binds POSsever through AIDL, establishing a connection and initialization operation, and calling POSsever through the interface in the SDK, and passing the IP address to be configured and the application information as parameters; for example, the parameters passed in when calling the first interface are: enableWhitelist(String IP, String packageName), and the parameters passed in when calling the second interface are: disableWhitelist(String IP, String packageName);
具体地,第一ICM接口为:enable.whitelistFromCustomer;第二ICM接口为:disable.whitelistFromCustomer。Specifically, the first ICM interface is: enable.whitelistFromCustomer; the second ICM interface is: disable.whitelistFromCustomer.
步骤601、POS管理服务调用第一接口, 并将第三方应用传入的网络访问配置信息和应用信息作为应用配置信息传入系统服务;Step 601: The POS management service calls the first interface and transmits the network access configuration information and application information transmitted by the third-party application to the system service as application configuration information;
本实施例中,应用信息具体为应用包名,例如String packageName;In this embodiment, the application information is specifically an application package name, such as String packageName;
步骤602、系统服务根据被调用的接口类型确定应用网络设置类型为第一类型,执行步骤603;Step 602: The system service determines that the application network setting type is the first type according to the called interface type, and executes step 603;
一种可实施的方式,系统服务包括网络连接服务和网络管理服务,步骤601具体为:POS管理服务调用第一接口,将第三方应用传入的网络访问配置信息和应用信息作为应用配置信息传入网络连接服务;In one practicable manner, the system service includes a network connection service and a network management service, and step 601 specifically includes: the POS management service calls the first interface, and transmits the network access configuration information and application information transmitted by the third-party application as application configuration information to the network connection service;
具体地,步骤602具体为:网络连接服务根据被调用的接口类型确定应用网络设置类型为第一类型;Specifically, step 602 is specifically: the network connection service determines that the application network setting type is the first type according to the called interface type;
第一预设接口为CS.addWhitelis。The first default interface is CS.addWhitelis.
步骤603、系统服务根据应用信息判断应用是否存在用户防火墙权限信息,若是则获取自定义IP地址列表,将应用配置信息中的网络访问配置信息保存至自定义IP地址列表中,将网络访问配置信息作为参数传入网络驱动,执行步骤604,若否则结束;Step 603: The system service determines whether the application has user firewall permission information according to the application information. If yes, the system service obtains the custom IP address list, saves the network access configuration information in the application configuration information to the custom IP address list, and passes the network access configuration information as a parameter to the network driver, and executes step 604. If no, the system service ends.
一种可实施的方式,系统服务根据应用信息判断应用是否存在用户防火墙权限信息具体为:系统服务根据应用信息中的应用包名判断应用是否存在对应的用户防火墙权限信息;In one practicable manner, the system service determines whether the application has user firewall permission information according to the application information: the system service determines whether the application has corresponding user firewall permission information according to the application package name in the application information;
具体地,步骤603具体为:网络连接服务根据应用信息判断应用是否存在用户防火墙权限信息,若是则获取自定义IP地址列表,将应用配置信息中的网络访问配置信息保存至自定义IP地址列表中,调用第一预设方法将网络访问配置信息作为参数传入网络管理服务,网络管理服务调用第二预设方法将网络访问配置信息作为参数传入网络驱动;Specifically, step 603 is as follows: the network connection service determines whether the application has user firewall permission information according to the application information, and if so, obtains a custom IP address list, saves the network access configuration information in the application configuration information to the custom IP address list, calls a first preset method to pass the network access configuration information as a parameter to the network management service, and the network management service calls a second preset method to pass the network access configuration information as a parameter to the network driver;
具体地,第一预设方法为NMS.enableWhitelist,第二预设方法为INetd.enableWhitelist。Specifically, the first preset method is NMS.enableWhitelist, and the second preset method is INetd.enableWhitelist.
步骤604、网络驱动通过配置指令将传入的网络访问配置信息配置到过滤白名单规则表中,结束;Step 604: The network driver configures the incoming network access configuration information into the filtering whitelist rule table through the configuration instruction, and ends;
一种可实施的方式,步骤604具体为:网络驱动向网络防火墙工具发送配置指令,网络防火墙工具接收到配置指令后将传入的网络访问配置信息配置到过滤白名单规则表中;In one practicable manner, step 604 is specifically as follows: the network driver sends a configuration instruction to the network firewall tool, and after receiving the configuration instruction, the network firewall tool configures the incoming network access configuration information into a filtering whitelist rule table;
具体地,网络驱动包括Netd本地服务和防火墙控制器,进一步的,网络管理服务调用第二预设方法将网络访问配置信息作为参数传入网络驱动具体为:网络管理服务调用第二预设方法将网络访问配置信息作为参数传入Netd本地服务;Specifically, the network driver includes a Netd local service and a firewall controller. Further, the network management service calls the second preset method to pass the network access configuration information as a parameter to the network driver. Specifically, the network management service calls the second preset method to pass the network access configuration information as a parameter to the Netd local service.
进一步地,步骤604具体为:Netd本地服务通过调用第三预设方法将网络访问配置信息作为参数传入防火墙控制器,防火墙控制器向网络防火墙工具发送配置指令,网络防火墙工具接收到配置指令后将传入的网络访问配置信息配置到过滤白名单规则表中;Further, step 604 is specifically as follows: the Netd local service passes the network access configuration information as a parameter to the firewall controller by calling the third preset method, the firewall controller sends a configuration instruction to the network firewall tool, and the network firewall tool configures the passed-in network access configuration information into the filtering whitelist rule table after receiving the configuration instruction;
具体地,Netd本地服务为NetdNativeService(简称NNS),第三预设方法为FC.enableWhitelist;防火墙控制器为Firewall Controller(简称FC);配置指令具体为将传入的网络访问配置信息添加到过滤白名单规则表中。Specifically, the Netd local service is NetdNativeService (NNS for short), the third preset method is FC.enableWhitelist; the firewall controller is Firewall Controller (FC for short); and the configuration instruction is specifically to add the incoming network access configuration information to the filtering whitelist rule table.
步骤605、POS管理服务调用第二接口, 并将第三方应用传入的应用信息作为应用配置信息传入系统服务;Step 605: The POS management service calls the second interface and transmits the application information transmitted by the third-party application to the system service as application configuration information;
一种可实施的方式,步骤605具体为: POS管理服务获取应用包名,将应用包名组织得到应用配置信息,调用系统服务的第二预设接口将应用配置信息作为参数传入系统服务;In one practicable manner, step 605 is specifically as follows: the POS management service obtains the application package name, organizes the application package name to obtain application configuration information, and calls the second preset interface of the system service to pass the application configuration information as a parameter to the system service;
可选地,步骤605具体为:POS管理服务获取应用包名和网络访问配置信息,将应用包名和网络访问配置信息组织得到应用配置信息,调用系统服务的第二接口将应用配置信息作为参数传入系统服务。Optionally, step 605 is specifically as follows: the POS management service obtains the application package name and network access configuration information, organizes the application package name and network access configuration information to obtain application configuration information, and calls the second interface of the system service to pass the application configuration information as a parameter to the system service.
步骤606、系统服务根据被调用的接口类型确定应用网络设置类型为第二类型,执行步骤607;Step 606: The system service determines that the application network setting type is the second type according to the called interface type, and executes step 607;
一种可实施的方式,系统服务包括网络连接服务和网络管理服务,步骤605具体为:POS管理服务调用第二接口,将第三方应用传入的应用信息作为应用配置信息传入网络连接服务;In one practicable manner, the system service includes a network connection service and a network management service, and step 605 is specifically as follows: the POS management service calls the second interface to pass the application information passed in by the third-party application as application configuration information to the network connection service;
具体地,步骤606具体为:网络连接服务根据被调用的接口类型确定应用网络设置类型为第二类型;Specifically, step 606 is as follows: the network connection service determines that the application network setting type is the second type according to the called interface type;
第二预设接口为CS.RemoveWhitelis。The second preset interface is CS.RemoveWhitelis.
步骤607、系统服务根据应用信息判断该应用是否存在用户防火墙权限信息,若是则执行步骤608,若否则结束;Step 607: The system service determines whether the application has user firewall permission information based on the application information. If yes, execute step 608; otherwise, end;
一种可实施的方式,系统服务根据应用信息判断应用是否存在用户防火墙权限信息具体为:系统服务根据应用信息中的应用包名判断应用是否存在对应的用户防火墙权限信息;In one practicable manner, the system service determines whether the application has user firewall permission information according to the application information: the system service determines whether the application has corresponding user firewall permission information according to the application package name in the application information;
具体地,步骤607具体为:网络连接服务根据应用信息判断应用是否存在用户防火墙权限信息,若是则执行步骤608,若否则结束。Specifically, step 607 is as follows: the network connection service determines whether the application has user firewall permission information based on the application information, and if so, executes step 608, otherwise ends.
步骤608、系统服务获取自定义IP地址列表,判断自定义IP地址列表中是否存在网络访问配置信息,是则执行步骤609,否则结束;Step 608: The system service obtains a custom IP address list and determines whether there is network access configuration information in the custom IP address list. If yes, execute step 609; otherwise, terminate.
一种可实施的方式,判断自定义IP地址列表中是否存在网络访问配置信息具体为:系统服务判断自定义IP地址列表中是否存在应用已配置完成的网络访问配置信息,若是则执行步骤609,否则结束;In one practicable manner, determining whether there is network access configuration information in the custom IP address list is as follows: the system service determines whether there is network access configuration information that has been configured by the application in the custom IP address list, and if so, executes step 609, otherwise ends;
具体地,步骤608具体为:网络连接服务获取自定义IP地址列表,判断自定义IP地址列表中是否存在IP地址,是则执行步骤609,否则结束。Specifically, step 608 is as follows: the network connection service obtains a custom IP address list, and determines whether there is an IP address in the custom IP address list. If yes, step 609 is executed, otherwise, the process ends.
步骤609、系统服务将自定义IP地址列表中的网络访问配置信息删除,将网络访问配置信息作为参数传入网络驱动,执行步骤610;Step 609: The system service deletes the network access configuration information in the custom IP address list, and passes the network access configuration information as a parameter to the network driver, and then executes step 610;
具体地,步骤609具体为:网络连接服务将自定义IP地址列表中的网络访问配置信息删除,调用第四预设方法将网络访问配置信息作为参数传入网络管理服务,网络管理服务调用第五预设方法将网络访问配置信息作为参数传入网络驱动;Specifically, step 609 is as follows: the network connection service deletes the network access configuration information in the custom IP address list, calls the fourth preset method to pass the network access configuration information as a parameter to the network management service, and the network management service calls the fifth preset method to pass the network access configuration information as a parameter to the network driver;
步骤610、网络驱动通过删除指令将网络访问配置信息从过滤白名单规则表中删除,结束。Step 610: The network driver deletes the network access configuration information from the filtering whitelist rule table through a delete instruction, and the process ends.
在本实施例中,一种可实施的方式,步骤610具体为:网络驱动向网络防火墙工具发送删除指令,网络防火墙工具接收到删除指令后将传入的网络访问配置信息从过滤白名单规则表中删除;In this embodiment, in an implementable manner, step 610 is specifically as follows: the network driver sends a deletion instruction to the network firewall tool, and the network firewall tool deletes the incoming network access configuration information from the filtering whitelist rule table after receiving the deletion instruction;
具体地,网络驱动包括Netd本地服务和防火墙控制器,网络管理服务调用第五预设方法将网络访问配置信息作为参数传入网络驱动具体为:网络管理服务调用第五预设方法将网络访问配置信息作为参数传入Netd本地服务;Specifically, the network driver includes a Netd local service and a firewall controller, and the network management service calls the fifth preset method to pass the network access configuration information as a parameter to the network driver. Specifically: the network management service calls the fifth preset method to pass the network access configuration information as a parameter to the Netd local service;
进一步的,步骤610具体为:Netd本地服务通过调用第六预设方法将网络访问配置信息作为参数传入防火墙控制器;防火墙控制器向网络防火墙工具发送删除指令,网络防火墙工具接收到删除指令后将传入的网络访问配置信息从过滤白名单规则表中删除;Further, step 610 is specifically as follows: the Netd local service passes the network access configuration information as a parameter to the firewall controller by calling the sixth preset method; the firewall controller sends a delete instruction to the network firewall tool, and the network firewall tool deletes the passed network access configuration information from the filtering whitelist rule table after receiving the delete instruction;
具体地,Netd本地服务为NetdNativeService;第六预设方法为FC.disableWhitelist;防火墙控制器为Firewall Controller。Specifically, the Netd local service is NetdNativeService; the sixth preset method is FC.disableWhitelist; and the firewall controller is Firewall Controller.
一种可实施的方式,网络防火墙工具执行删除指令具体用到了Linux网络驱动的技术,具体为:执行Linux iptables指令可以将网络访问配置信息从过滤白名单规则表中删除;In one practicable manner, the network firewall tool executes the deletion command using the Linux network driver technology, specifically: executing the Linux iptables command can delete the network access configuration information from the filtering whitelist rule table;
例如,防火墙控制器发送iptables -D OUTPUT -s 192.168.8.102 -j ACCEPT,就可以删除过滤白名单规则表中的IP地址访问权限,其中-D为删除;For example, the firewall controller sends iptables -D OUTPUT -s 192.168.8.102 -j ACCEPT to delete the IP address access rights in the filtering whitelist rule table, where -D means delete.
一种可实施的方式,网络驱动发送的执行指令中包括用户防火墙权限信息,例如执行指令为:iptables -I OUTPUT -s 192.168.8.102 -uid-owner=1098-j ACCEPT。In one practicable manner, the execution instruction sent by the network driver includes user firewall permission information, for example, the execution instruction is: iptables -I OUTPUT -s 192.168.8.102 -uid-owner=1098 -j ACCEPT.
一种可实施的方式,应用配置信息还包括验签数据,验签数据包括指定参数、验证密钥及签名数据,系统服务根据应用配置信息判断存在用户防火墙权限信息时还包括:系统服务获取应用配置信息中的验签数据进行代码验签,验签通过则获取网络配置权限,验签未通过则报错,结束。In an implementable manner, the application configuration information also includes verification data, the verification data includes specified parameters, verification key and signature data, and when the system service determines that there is user firewall permission information based on the application configuration information, it also includes: the system service obtains the verification data in the application configuration information to perform code verification, and if the verification passes, the network configuration permission is obtained, and if the verification fails, an error is reported and the process ends.
具体地,系统服务获取应用配置信息中的验签数据进行代码验签具体为:系统服务获取指定参数、验证密钥及签名数据,通过验证密钥对指定参数进行计算得到第一数据,判断第一数据与签名数据是否一致,是则验签通过,获取网络配置权限,否则验签未通过,报错,结束。Specifically, the system service obtains the verification data in the application configuration information to perform code verification as follows: the system service obtains the specified parameters, verification key and signature data, calculates the specified parameters through the verification key to obtain the first data, and determines whether the first data is consistent with the signature data. If so, the verification passes and the network configuration permission is obtained. Otherwise, the verification fails, an error is reported, and the process ends.
本发明实施例提供的一种智能终端设备中应用进行网络访问的方法,适用于安装了Android系统的智能终端设备,在本实施例中,智能终端设备包括第三方应用,智能终端设备中的第三方应用通过接口函数SDK调用智能终端设备中的POS管理服务以此来完成应用访问网络的设置操作,通过系统服务和网络驱动根据确定的应用网络设置类型对应用指定的网络访问设置信息进行设置,解决了现有技术中应用没有权限导致的无法设置安全网络访问的问题,实现了应用可以在指定网络环境下进行安全操作处理的功能,避免了网络安全问题造成的数据泄露等风险。A method for network access by an application in a smart terminal device provided by an embodiment of the present invention is applicable to a smart terminal device installed with an Android system. In this embodiment, the smart terminal device includes a third-party application. The third-party application in the smart terminal device calls a POS management service in the smart terminal device through an interface function SDK to complete the setting operation of the application accessing the network. The network access setting information specified by the application is set according to the determined application network setting type through system services and network drivers, thereby solving the problem in the prior art that the application cannot set secure network access due to lack of permission, realizing the function that the application can perform secure operation processing in a specified network environment, and avoiding the risks of data leakage caused by network security problems.
实施例四Embodiment 4
本发明实施例四在实施例一的基础上提供一种智能终端设备中应用进行网络访问的方法,现有技术中,当Android应用使用WebView或者Chrome浏览器键入一个域名来上网,或者应用直接使用http请求一个域名来获取服务器的响应时,Android系统会执行以下步骤:Embodiment 4 of the present invention provides a method for an application in a smart terminal device to access the network based on Embodiment 1. In the prior art, when an Android application uses WebView or Chrome browser to type a domain name to access the Internet, or the application directly uses http to request a domain name to obtain a response from the server, the Android system will perform the following steps:
1.Android系统会使用DNS解析这段域名,1. The Android system will use DNS to resolve this domain name.
2.TCP建立连接,2.TCP establishes a connection,
3.客户端发送http请求,3. The client sends an http request.
4.服务器处理http请求并返回http数据包,4. The server processes the http request and returns the http data packet.
5.浏览器解析http数据包,将结果返回给应用程序,渲染并刷新页面。5. The browser parses the http data packet, returns the result to the application, renders and refreshes the page.
为了适应本发明方案,如图7所示,本发明实施例四提供了一种智能终端设备中应用进行网络访问的方法,该方法包括:In order to adapt to the solution of the present invention, as shown in FIG. 7 , a fourth embodiment of the present invention provides a method for an application in a smart terminal device to access a network, the method comprising:
步骤701、应用发起网络连接请求;Step 701: The application initiates a network connection request;
具体地,应用使用WebView或者Chrome浏览器键入一个域名来上网,或者直接发起http请求,该应用可以是智能终端设备中的任一应用。Specifically, the application uses WebView or Chrome browser to type in a domain name to access the Internet, or directly initiates an http request. The application can be any application in the smart terminal device.
步骤702、系统服务接收到网络连接请求时,通过网络驱动监听网络响应数据包;Step 702: When the system service receives a network connection request, it monitors the network response data packet through the network driver;
步骤703、网络驱动监听到网络响应数据包时,获取网络响应数据包中接收方和响应方的IP地址;Step 703: When the network driver monitors the network response data packet, it obtains the IP addresses of the receiver and the responder in the network response data packet;
步骤704、网络驱动判断过滤白名单规则表中是否存在网络访问配置信息,若是则执行步骤705,否则向系统服务返回网络响应数据包,执行步骤706;Step 704: The network driver determines whether there is network access configuration information in the filtering whitelist rule table. If yes, execute step 705; otherwise, return a network response data packet to the system service and execute step 706;
步骤705、网络驱动判断网络响应数据包中响应方的IP地址是否与过滤白名单规则表中的网络访问配置信息相同,若是则向系统服务返回网络响应数据包,执行步骤706,否则丢弃网络响应数据包,向系统服务返回错误,执行步骤707;Step 705, the network driver determines whether the IP address of the responder in the network response data packet is the same as the network access configuration information in the filtering whitelist rule table. If so, the network response data packet is returned to the system service and step 706 is executed. Otherwise, the network response data packet is discarded, an error is returned to the system service, and step 707 is executed.
步骤706、系统服务向应用返回网络响应数据包;Step 706: The system service returns a network response data packet to the application;
步骤707、系统服务向应用返回错误。Step 707: The system service returns an error to the application.
具体地,网络驱动是通过网络防火墙工具监听网络响应数据包,网络防火墙工具Android iptables的主要作用是实现对网络数据包进出设备和转发的控制,当数据包需要进入设备、或者从设备中转出时由网络驱动转发、路由;iptables网络防火墙工具维护着过滤白名单规则表,根据过滤白名单规则表确定网络响应数据包中接收方的IP地址是否与过滤白名单规则表中的网络访问配置信息相同;Specifically, the network driver monitors the network response data packets through the network firewall tool. The main function of the network firewall tool Android iptables is to control the entry and exit of network data packets and forwarding. When the data packets need to enter the device or transfer out of the device, they are forwarded and routed by the network driver; the iptables network firewall tool maintains a filtering whitelist rule table, and determines whether the IP address of the recipient in the network response data packet is the same as the network access configuration information in the filtering whitelist rule table according to the filtering whitelist rule table;
例如,通过网络防火墙工具向过滤白名单规则表中配置一条IP地址,IP地址为192.168.1.131;网络防火墙工具监听网络响应数据包,获取网络响应数据包中响应方的IP地址,确定响应方的IP地址是否存在于过滤白名单规则表中,存在则响应,不存在则丢弃数据包;For example, an IP address 192.168.1.131 is configured in the filtering whitelist rule table through a network firewall tool; the network firewall tool monitors the network response data packet, obtains the IP address of the responder in the network response data packet, and determines whether the IP address of the responder exists in the filtering whitelist rule table. If it exists, it responds, otherwise it discards the data packet;
一种可实施的方式,实施例一步骤102还包括:系统服务根据应用配置信息中的用户防火墙信息设置应用对应的防火墙权限组信息;In an implementable manner, step 102 of the first embodiment further includes: the system service sets firewall permission group information corresponding to the application according to the user firewall information in the application configuration information;
具体地,本实施例中,通过网络驱动监听网络响应数据包具体包括:系统服务通过网络驱动监听设置有防火墙权限组信息的应用对应的网络响应数据包。Specifically, in this embodiment, monitoring the network response data packet through the network driver specifically includes: the system service monitors the network response data packet corresponding to the application set with the firewall permission group information through the network driver.
具体的,一种可实施的方式,应用在预设时长内未接收到响应,提示错误,结束。Specifically, in one implementable manner, if the application does not receive a response within a preset time period, an error message is displayed and the application ends.
本发明提供的一种智能终端设备中应用进行网络访问的方法,本方案通过系统服务和网络驱动根据确定的应用网络设置类型对应用指定的网络访问设置信息进行设置,解决了现有技术中应用没有权限导致的无法设置安全网络访问的问题,实现了应用可以在指定网络环境下进行安全访问并安全操作处理的功能,避免了网络安全问题造成的数据泄露等风险。The present invention provides a method for an application in an intelligent terminal device to access the network. The solution sets the network access setting information specified by the application according to a determined application network setting type through system services and network drivers, thereby solving the problem in the prior art that the application cannot set up secure network access due to lack of permission, and realizes the function that the application can access securely and operate securely in a specified network environment, thereby avoiding the risk of data leakage caused by network security issues.
下述为本发明装置实施例,可以用于执行本发明方法实施例。对于本发明装置实施例中未披露的细节,可参照本发明方法实施例。The following are embodiments of the apparatus of the present invention, which can be used to implement the embodiments of the method of the present invention. For details not disclosed in the embodiments of the apparatus of the present invention, reference can be made to the embodiments of the method of the present invention.
本发明一个示例性实施例提供的一种智能终端设备中应用进行网络访问的装置,所述装置包括系统服务和网络驱动,An exemplary embodiment of the present invention provides a device for an application in an intelligent terminal device to access a network, the device comprising a system service and a network driver.
其中,系统服务包括:Among them, system services include:
第一确定模块,用于根据被调用的接口类型确定应用网络设置类型,若应用网络设置类型为第一类型则触发第一获取判断模块;A first determination module, configured to determine the application network setting type according to the called interface type, and trigger a first acquisition judgment module if the application network setting type is the first type;
第一获取判断模块,用于获取通过被调用的接口传入的应用配置信息,根据应用配置信息判断是否存在用户防火墙权限信息;The first acquisition and judgment module is used to obtain the application configuration information passed in through the called interface, and judge whether there is user firewall permission information according to the application configuration information;
获取保存模块,用于当第一获取判断模块判断存在用户防火墙权限信息时,获取自定义IP地址列表,将应用配置信息中的网络访问配置信息保存至自定义IP地址列表中,将网络访问配置信息作为参数传入网络驱动;An acquisition and saving module, used for acquiring a custom IP address list when the first acquisition and judgment module determines that there is user firewall permission information, saving the network access configuration information in the application configuration information to the custom IP address list, and passing the network access configuration information as a parameter to the network driver;
其中,网络驱动包括:配置模块,用于通过配置指令将网络访问配置信息配置到过滤白名单规则表中;Wherein, the network driver includes: a configuration module, which is used to configure the network access configuration information into the filtering whitelist rule table through configuration instructions;
在该装置中,系统服务还包括:In this device, the system services also include:
接收模块,用于接收智能终端设备中任一应用发起的网络连接请求,并在接收到请求时,通过网络驱动监听网络响应数据包,还用于接收网络驱动发送的网络响应数据包;A receiving module is used to receive a network connection request initiated by any application in the intelligent terminal device, and when receiving the request, monitors the network response data packet through the network driver, and is also used to receive the network response data packet sent by the network driver;
发送模块,用于向应用返回网络响应数据包,还用于向应用返回错误;The sending module is used to return network response data packets to the application and also to return errors to the application;
在该装置中,网络驱动还包括:In the device, the network driver also includes:
第一判断模块,用于监听网络响应数据包,当监听到网络响应数据包时判断过滤白名单规则表中是否存在IP地址,是则触发第二判断模块,否则向系统服务返回网络响应数据包;The first judgment module is used to monitor the network response data packet, and when the network response data packet is monitored, it is determined whether the IP address exists in the filtering whitelist rule table, and if so, the second judgment module is triggered, otherwise the network response data packet is returned to the system service;
第二判断模块,用于判断网络响应数据包中响应方的IP地址是否与过滤白名单规则表中的网络访问配置信息相同,若是则向系统服务返回网络响应数据包,否则丢弃网络响应数据包,向系统服务返回错误。The second judgment module is used to judge whether the IP address of the responder in the network response data packet is the same as the network access configuration information in the filtering whitelist rule table. If so, the network response data packet is returned to the system service; otherwise, the network response data packet is discarded and an error is returned to the system service.
可选地,系统服务还包括第二获取判断模块和获取删除模块;Optionally, the system service further includes a second acquisition judgment module and an acquisition deletion module;
第一确定模块还用于若应用网络设置类型为第二类型则触发第二获取判断模块;The first determination module is further configured to trigger the second acquisition judgment module if the application network setting type is the second type;
第二获取判断模块,用于获取通过被调用的接口传入的应用配置信息,根据应用配置信息判断是否存在用户防火墙权限信息;The second acquisition and judgment module is used to obtain the application configuration information passed in through the called interface, and judge whether there is user firewall permission information according to the application configuration information;
获取删除模块,用于当第二获取判断模块判断存在用户防火墙权限信息时,获取自定义IP地址列表,将自定义IP地址列表中的网络访问配置信息删除,将网络访问配置信息作为参数传入网络驱动;An acquisition and deletion module, used for acquiring a custom IP address list, deleting the network access configuration information in the custom IP address list, and passing the network access configuration information as a parameter to the network driver when the second acquisition and judgment module determines that the user firewall authority information exists;
网络驱动还包括删除模块,用于通过删除指令将网络访问配置信息从过滤白名单规则表中删除。The network driver also includes a deletion module, which is used to delete the network access configuration information from the filtering whitelist rule table through a deletion instruction.
进一步可选地,第一确定模块具体用于当第一预设接口被调用时确定应用网络设置类型为第一类型,当第二预设接口被调用时确定应用网络设置类型为第二类型。Further optionally, the first determining module is specifically configured to determine that the application network setting type is the first type when the first preset interface is called, and to determine that the application network setting type is the second type when the second preset interface is called.
可选地,系统服务包括包管理服务,包管理服务包括获取单元、确定单元和调用单元;Optionally, the system service includes a package management service, and the package management service includes an acquisition unit, a determination unit, and a calling unit;
获取单元用于获取应用待安装APK文件,调用API接口解析应用待安装APK文件中的清单文件,获取配置启动项信息;The acquisition unit is used to acquire the APK file of the application to be installed, call the API interface to parse the manifest file in the APK file of the application to be installed, and acquire the configuration startup item information;
确定单元用于根据配置启动项信息确定网络访问配置类型;The determination unit is used to determine the network access configuration type according to the configuration startup item information;
调用单元用于根据网络访问配置类型调用接口。The calling unit is used to call the interface according to the network access configuration type.
进一步地,调用单元具体用于获取清单文件中的用户防火墙权限信息和网络访问配置信息,将网络访问配置信息和用户防火墙权限信息组织得到应用配置信息,调用接口将应用配置信息作为参数传入。Furthermore, the calling unit is specifically used to obtain the user firewall permission information and network access configuration information in the manifest file, organize the network access configuration information and the user firewall permission information to obtain the application configuration information, and the calling interface passes the application configuration information as a parameter.
进一步地,该装置包括生成模块,用于生成应用待安装APK文件;Furthermore, the device includes a generation module for generating an APK file of an application to be installed;
生成模块具体用于确定网络访问配置类型,根据预定格式将网络访问配置类型对应的配置启动项信息、网络访问配置信息和用户防火墙权限信息写入清单文件得到应用待安装APK文件。The generation module is specifically used to determine the network access configuration type, and write the configuration startup item information, network access configuration information and user firewall permission information corresponding to the network access configuration type into the manifest file according to a predetermined format to obtain the application APK file to be installed.
可选地,系统服务还包括判断删除模块,判断删除模块具体包括第一判断单元、第一获取判断单元和处理单元;Optionally, the system service further includes a deletion judgment module, which specifically includes a first judgment unit, a first acquisition judgment unit and a processing unit;
第一判断单元,用于判断自定义IP地址列表中是否存在网络访问配置信息,若是则触发第一获取单元,否则触发获取保存模块;A first judging unit, used for judging whether there is network access configuration information in the custom IP address list, and if so, triggering the first acquiring unit, otherwise triggering the acquiring and saving module;
第一获取判断单元,用于获取应用配置信息中的网络访问配置信息,判断自定义IP地址列表中的网络访问配置信息与应用配置信息中的网络访问配置信息是否相同,是则结束,否则触发处理单元;A first acquisition and judgment unit is used to acquire the network access configuration information in the application configuration information, and judge whether the network access configuration information in the custom IP address list is the same as the network access configuration information in the application configuration information, and if so, the process ends, otherwise, the processing unit is triggered;
处理单元,用于将自定义IP地址列表中的网络访问配置信息从自定义IP地址列表中删除,将自定义IP地址列表中的网络访问配置信息作为参数传入网络驱动,将应用配置信息中的网络访问配置信息保存至自定义IP地址列表中,触发删除模块。The processing unit is used to delete the network access configuration information in the custom IP address list from the custom IP address list, pass the network access configuration information in the custom IP address list as a parameter to the network driver, save the network access configuration information in the application configuration information to the custom IP address list, and trigger the deletion module.
可选地,该装置还包括POS管理服务;POS管理服务包括第二确定模块和调用模块;Optionally, the device further includes a POS management service; the POS management service includes a second determination module and a calling module;
第二确定模块用于根据被第三方应用调用的接口类型确定调用系统服务的接口类型,根据确定的接口类型调用接口;The second determination module is used to determine the interface type for calling the system service according to the interface type called by the third-party application, and call the interface according to the determined interface type;
调用模块用于调用系统服务的接口。The calling module is used to call the interface of system services.
进一步地,调用模块具体用于获取应用包名,将网络访问配置信息和应用包名组织得到应用配置信息,调用系统服务的接口将应用配置信息作为参数传入。Furthermore, the calling module is specifically used to obtain the application package name, organize the network access configuration information and the application package name to obtain the application configuration information, and call the interface of the system service to pass the application configuration information as a parameter.
进一步地,第一获取判断模块或第二获取判断模块具体用于根据应用配置信息中的应用包名判断是否存在用户防火墙权限信息。Furthermore, the first acquisition and determination module or the second acquisition and determination module is specifically used to determine whether there is user firewall permission information according to the application package name in the application configuration information.
可选地,系统服务还包括验签模块,用于获取应用配置信息中的验签数据进行代码验签,验签通过则获取网络配置权限,触发获取保存模块,验签未通过则结束。Optionally, the system service also includes a signature verification module, which is used to obtain the signature verification data in the application configuration information to perform code signature verification. If the signature verification passes, the network configuration permission is obtained, triggering the acquisition and saving module, and the process ends if the signature verification fails.
可选地,删除模块具体用于当智能终端设备关机时,通过删除指令将过滤白名单规则表中的网络访问配置信息全部删除。Optionally, the deletion module is specifically used to delete all network access configuration information in the filtering whitelist rule table through a deletion instruction when the intelligent terminal device is turned off.
可选地,系统服务还包括重新配置模块,用于当智能终端设备开机重启时,获取保存的自定义IP地址列表,遍历自定义IP地址列表,顺序获取自定义IP地址列表中的网络访问配置信息并将网络访问配置信息作为参数传入网络驱动。Optionally, the system service also includes a reconfiguration module, which is used to obtain the saved custom IP address list, traverse the custom IP address list, sequentially obtain the network access configuration information in the custom IP address list and pass the network access configuration information as a parameter to the network driver when the smart terminal device is turned on and restarted.
可选地,系统服务还包括设置模块,用于当第一获取判断模块或第二获取判断模块根据应用配置信息判断存在用户防火墙权限信息时,根据应用配置信息中的用户防火墙信息设置应用对应的防火墙权限组信息;Optionally, the system service further includes a setting module, which is used to set firewall permission group information corresponding to the application according to the user firewall information in the application configuration information when the first acquisition judgment module or the second acquisition judgment module determines that there is user firewall permission information according to the application configuration information;
可选地,接收模块具体包括监听单元,监听单元用于监听网络响应数据包;Optionally, the receiving module specifically includes a monitoring unit, and the monitoring unit is used to monitor the network response data packet;
监听单元具体用于监听设置有防火墙权限组信息的应用对应的网络响应数据包。The monitoring unit is specifically used to monitor the network response data packet corresponding to the application set with the firewall permission group information.
需要说明的是,上述实施例提供的智能终端设备中应用进行网络访问的装置在执行智能终端设备中应用进行网络访问的方法时,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要将上述功能进行分配并由不同的功能模块完成,即将设备的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。另外,上述实施例提供的智能终端设备中应用进行访问网络的装置与智能终端设备中应用进行网络访问的方法实施例属于同一构思,其体现实现过程详见方法实施例,这里不再赘述。It should be noted that the apparatus for accessing a network by an application in a smart terminal device provided in the above embodiment only uses the division of the above functional modules as an example when executing the method for accessing a network by an application in a smart terminal device. In actual applications, the above functions can be allocated and completed by different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the apparatus for accessing a network by an application in a smart terminal device provided in the above embodiment and the method for accessing a network by an application in a smart terminal device belong to the same concept, and the implementation process thereof is detailed in the method embodiment, which will not be repeated here.
上述本发明实施例序号仅仅为了描述,不代表实施例的优劣。The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
本发明提供的一种智能终端设备中应用进行网络访问的方法及装置,通过系统服务和网络驱动根据确定的应用网络设置类型对应用指定的网络访问设置信息进行设置,解决了现有技术中应用没有权限导致的无法设置安全网络访问的问题,实现了应用可以在指定网络环境下进行安全访问并安全操作处理的功能,避免了网络安全问题造成的数据泄露等风险。The present invention provides a method and device for network access by applications in an intelligent terminal device, which sets the network access setting information specified by the application according to a determined application network setting type through system services and network drivers, thereby solving the problem in the prior art that secure network access cannot be set due to the application having no authority, and realizing the function that the application can securely access and operate securely in a specified network environment, thereby avoiding the risks of data leakage caused by network security issues.
本发明实施例还提供了一种计算机设备,包括存储器、处理器及存储在存储器上的计算机程序,其中,处理器执行计算机程序以实现前述任一实施例公开的智能终端设备中应用进行网络访问的方法。An embodiment of the present invention further provides a computer device, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the method for network access by an application in an intelligent terminal device disclosed in any of the aforementioned embodiments.
本发明实施例还提供了一种计算机可读存储介质,其上存储有计算机程序/指令,该程序/指令被处理器执行时实现前述任一实施例公开的智能终端设备中应用进行网络访问的方法。其中,计算机可读存储介质可以包括但不限于任何类型的盘,包括软盘、光盘、DVD、CD-ROM、微型驱动器以及磁光盘、ROM、RAM、EPROM、EEPROM、DRAM、VRAM、闪速存储器设备、磁卡或光卡、纳米系统(包括分子存储器IC),或适合于存储指令和/或数据的任何类型的媒介或设备。The embodiment of the present invention also provides a computer-readable storage medium, on which a computer program/instruction is stored, and when the program/instruction is executed by a processor, the method for network access by an application in an intelligent terminal device disclosed in any of the above embodiments is implemented. The computer-readable storage medium may include, but is not limited to, any type of disk, including a floppy disk, an optical disk, a DVD, a CD-ROM, a micro drive, and a magneto-optical disk, a ROM, a RAM, an EPROM, an EEPROM, a DRAM, a VRAM, a flash memory device, a magnetic card or an optical card, a nanosystem (including a molecular memory IC), or any type of medium or device suitable for storing instructions and/or data.
本发明实施例提供了一种计算机程序产品,包括计算机程序/指令,其中,该计算机程序/指令被处理器执行时实现前述任一实施例公开的智能终端设备中应用进行网络访问的方法。An embodiment of the present invention provides a computer program product, including a computer program/instruction, wherein the computer program/instruction, when executed by a processor, implements the method for network access by an application in an intelligent terminal device disclosed in any of the aforementioned embodiments.
在本发明中,术语“第一”、“第二”等仅用于描述的目的,而不能理解为指示或暗示相对重要性或顺序;术语“多个”则指两个或两个以上,除非另有明确的限定。“和/或”,描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。字符“/”一般表示前后关联对象是一种“或”的关系。术语“安装”、“相连”、“连接”、“固定”等术语均应做广义理解,例如,“连接”可以是固定连接,也可以是可拆卸连接,或一体地连接;“相连”可以是直接相连,也可以通过中间媒介间接相连。对于本领域的普通技术人员而言,可以根据具体情况理解上述术语在本发明中的具体含义。In the present invention, the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or order; the term "plurality" refers to two or more, unless otherwise clearly defined. "And/or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and/or B can represent: the existence of A alone, the existence of A and B at the same time, and the existence of B alone. The character "/" generally indicates that the objects associated with each other are in an "or" relationship. Terms such as "install", "connect", "connect", and "fix" should be understood in a broad sense. For example, "connection" can be a fixed connection, a detachable connection, or an integral connection; "connection" can be a direct connection or an indirect connection through an intermediate medium. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
本发明的描述中,需要理解的是,术语“上”、“下”等指示的方位或位置关系为基于附图所示的方位或位置关系,仅是为了便于描述本发明和简化描述,而不是指示或暗示所指的装置或单元必须具有特定的方向、以特定的方位构造和操作,因此,不能理解为对本发明的限制。In the description of the present invention, it is necessary to understand that the directions or positional relationships indicated by the terms "upper" and "lower" etc. are based on the directions or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or unit referred to must have a specific direction, be constructed and operated in a specific orientation. Therefore, it cannot be understood as a limitation on the present invention.
以上所述,仅为本发明的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本发明的保护范围之内。因此,依本发明权利要求所作的等同变化,仍属本发明所涵盖的范围。The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, equivalent changes made according to the claims of the present invention are still within the scope covered by the present invention.
Claims (16)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202411112903.9A CN118646604B (en) | 2024-08-14 | 2024-08-14 | Method and device for performing network access on application in intelligent terminal equipment |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202411112903.9A CN118646604B (en) | 2024-08-14 | 2024-08-14 | Method and device for performing network access on application in intelligent terminal equipment |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN118646604A CN118646604A (en) | 2024-09-13 |
| CN118646604B true CN118646604B (en) | 2024-10-22 |
Family
ID=92663512
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202411112903.9A Active CN118646604B (en) | 2024-08-14 | 2024-08-14 | Method and device for performing network access on application in intelligent terminal equipment |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN118646604B (en) |
Citations (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN108390944A (en) * | 2018-03-28 | 2018-08-10 | 北京小米移动软件有限公司 | Information interacting method and device |
| CN109922030A (en) * | 2017-12-13 | 2019-06-21 | 南京领创信息科技有限公司 | Global network access control system and method based on Android device |
Family Cites Families (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN103973700A (en) * | 2014-05-21 | 2014-08-06 | 成都达信通通讯设备有限公司 | Mobile terminal preset networking address firewall isolation application system |
| CN115550059A (en) * | 2022-11-17 | 2022-12-30 | 北京首信科技股份有限公司 | WEB access control and redirection system, method and storage medium |
-
2024
- 2024-08-14 CN CN202411112903.9A patent/CN118646604B/en active Active
Patent Citations (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN109922030A (en) * | 2017-12-13 | 2019-06-21 | 南京领创信息科技有限公司 | Global network access control system and method based on Android device |
| CN108390944A (en) * | 2018-03-28 | 2018-08-10 | 北京小米移动软件有限公司 | Information interacting method and device |
Also Published As
| Publication number | Publication date |
|---|---|
| CN118646604A (en) | 2024-09-13 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| JP6130460B2 (en) | Software update system and method, automatic deployment method, and automatic deployment method | |
| US8266685B2 (en) | Firewall installer | |
| US9270782B2 (en) | System and method for managing network communications between server plug-ins and clients | |
| JP6335945B2 (en) | Computer program, apparatus and method for providing access to an external web service to a multifunction peripheral device | |
| US8832680B2 (en) | Installation event counting apparatus and package creation method | |
| CN114531945B (en) | Method, system and medium for template-based loading of internet-enabled devices | |
| US20130332524A1 (en) | Data service on a mobile device | |
| JP7097958B2 (en) | Systems and methods for integrating cloud applications into cloud service broker platforms using the Automatic Universal Connector Package | |
| JP5106625B2 (en) | Method, system, and computer program for configuring a firewall | |
| EP3337219A1 (en) | Carrier configuration processing method, device and system, and computer storage medium | |
| CN110096424B (en) | Test processing method and device, electronic equipment and storage medium | |
| EP2863281B1 (en) | System and method to configure a field device | |
| CN110945504A (en) | Delivering configuration-based workflows | |
| US11113357B2 (en) | Method and system for onboarding a virtual network function package utilized by one or more network services | |
| CN105162667B (en) | Virtual machine configuration method and apparatus | |
| KR20220152222A (en) | Security management of devices | |
| JP7513678B2 (en) | COMMUNICATION MODULE, COMMUNICATION SYSTEM, AND COMMUNICATION METHOD | |
| CN110597662B (en) | Backup data automatic verification method and device, user equipment and storage medium | |
| US10735937B2 (en) | Management apparatus, mobile terminal, and methods thereof | |
| CN118646604B (en) | Method and device for performing network access on application in intelligent terminal equipment | |
| CN109218415B (en) | A method, node and storage medium for distributed node management | |
| CN111447273A (en) | Cloud processing system and data processing method based on cloud processing system | |
| CN118646605B (en) | Method and device for performing network access on application in intelligent terminal equipment | |
| CN116627595A (en) | Virtual machine creation method and related components | |
| CN113590271A (en) | Database deployment method and device, electronic equipment and storage medium |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |