A method and device for network access by application in intelligent terminal device
Configuring filtering whitelist rules in smart terminal devices through system services and network drivers solves the problem of data leakage caused by application software's lack of permissions during network access, achieves secure network access, and ensures the security of applications in designated network environments. operate.
Patent Information
- Application Number
- CN202411112903.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-14
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2044-08-14
AI Technical Summary
Application software in smart terminal devices lacks permission settings during network access, leading to the risk of data leakage. Existing technologies cannot effectively ensure the security of network access.
Through system services and network drivers, determine and configure filtering whitelist rules according to the type of network settings applied, monitor and filter network response packets, ensure that only packets with specified IP addresses are allowed to pass, and other packets are discarded or rejected to achieve security. Network access.
It effectively solves the problem of data leakage caused by application software's lack of permissions in network access, ensures safe access and operation of applications in designated network environments, and avoids network security risks.
Smart Images

Figure CN118646604B_ABST
Abstract
Description
Technical Field
[0001] 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
[0002] 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.
[0003] 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
[0004] 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:
[0005] 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:
[0006] 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;
[0007] 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;
[0008] 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;
[0009] Step S4, the network driver configures the network access configuration information into the filtering whitelist rule table through a configuration instruction, and ends;
[0010] The method further comprises:
[0011] 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;
[0012] 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;
[0013] 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;
[0014] Step F4, the system service returns the network response data packet to the application;
[0015] Step F5: The system service returns an error to the application.
[0016] 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;
[0017] The system services include:
[0018] A first determination module, configured to determine an application network setting type according to the called interface type, and trigger a first acquisition judgment module if the application network setting type is a first type;
[0019] 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;
[0020] 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;
[0021] The network driver includes: a configuration module, which is used to configure the network access configuration information into a filtering whitelist rule table through a configuration instruction;
[0022] The system services also include:
[0023] 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;
[0024] a sending module, used to return the network response data packet to the application, and also used to return an error to the application;
[0025] The network driver also includes:
[0026] 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;
[0027] 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.
[0028] 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.
[0029] 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.
[0030] 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.
[0031] The beneficial effects brought about by the technical solution provided by the embodiment of the present invention include at least:
[0032] 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
[0033] 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.
[0034] Figure 1 It is a flowchart of network settings in a method for performing network access by an application in an intelligent terminal device provided in the first embodiment of the present invention;
[0035] Figure 2 This is a flowchart of a method for an application in a smart terminal device to access a network provided in a first embodiment of the present invention;
[0036] Figure 3 This is a flow chart 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;
[0037] Figure 4 This is a flow chart of a method for an application in a smart terminal device to access a network when the application is first installed, as provided in the second embodiment of the present invention;
[0038] Figure 5 This is a flow chart of a method for an application in a smart terminal device to access a network when an application upgrade is installed, as provided in the second embodiment of the present invention;
[0039] Figure 6 It 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;
[0040] Figure 7 It is a flowchart of a method for an application in a smart terminal device to access a network provided in a fourth embodiment of the present invention. DETAILED DESCRIPTION
[0041] 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.
[0042] 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.
[0043] To make the purpose, technical solutions 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.
[0044] Embodiment 1
[0045] Embodiment 1 of the present invention provides a method for an application in an intelligent terminal device to access a network, such as Figure 1 and Figure 2 As shown, the intelligent terminal device includes a system service and a network driver, and the method includes:
[0046] 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;
[0047] 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 end;
[0048] 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;
[0049] Step 104: The network driver configures the network access configuration information into the filtering whitelist rule table through the configuration instruction, and ends;
[0050] The method further includes:
[0051] 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;
[0052] 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, executes step 203, otherwise returns the network response data packet to the system service, and executes step 204;
[0053] 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.
[0054] Step 204: The system service returns a network response data packet to the application;
[0055] Step 205: The system service returns an error to the application.
[0056] 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:
[0057] 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;
[0058] 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;
[0059] 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;
[0060] 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.
[0061] In one practicable manner, the system service includes a package management service, and before step 101, the following is further included:
[0062] Step 1101: The package management service obtains the APK file of the application to be installed;
[0063] 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;
[0064] Step 1103: The package management service determines the network access configuration type according to the configuration startup item information, and calls the system service interface according to the network access configuration type.
[0065] 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.
[0066] Specifically, in an implementable manner, the method further includes generating an APK file of the application to be installed;
[0067] Generate the APK file to be installed as follows:
[0068] Step D1, determining the network access configuration type;
[0069] 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.
[0070] 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:
[0071] 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;
[0072] 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.
[0073] 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;
[0074] 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.
[0075] In one practicable manner, the intelligent terminal device includes a POS management service;
[0076] 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.
[0077] 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.
[0078] One feasible way to determine whether there is user firewall permission information based on application configuration information is as follows:
[0079] The system service determines whether there is user firewall permission information based on the application package name in the application configuration information.
[0080] 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.
[0081] 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.
[0082] 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.
[0083] 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;
[0084] 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.
[0085] 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.
[0086] Embodiment 2
[0087] Embodiment 2 of the present invention provides a method for an application in a smart terminal device to access a network, wherein in this embodiment, a third-party application sets up a network by installing an application installation package, such as Figure 3 As shown, the method flow of generating an APK file to be installed in the method of network access by an application specifically includes:
[0088] Step 301: Determine the network access configuration type;
[0089] In this embodiment, the network access configuration types include configuration and deconfiguration;
[0090] 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;
[0091] For example, if the startup item is defined as whitelist_enable, the value of the startup item whitelist_enable is true.
[0092] 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.
[0093] 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;
[0094] 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;
[0095] 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:
[0096] <manifest xmlns:android="http: / / schemas.android.com / apk / res / android"
[0097] xmlns:tools="http: / / schemas.android.com / tools"
[0098] package="com.ft.myapplication">
[0099] <users-permission android:name="android.permission.INTERNET" / >
[0100] <uses-permission android:name=" CONTROL_FIREWALL_RULED" / >
[0101] <application
[0102] android:allowBackup="true"
[0103] android: icon="@mipmap / ic_launcher"
[0104] android: label="@string / app_name"
[0105] android: round Icon="@mipmap / ic_launcher_round"
[0106] android: supportsRtl="true"
[0107] android: theme="@style / AppTheme"
[0108] android: usesCleartextTraffic="true"
[0109] tools:targetApi="m">
[0110] <meta-data android: name="WebView whitelist" value="true" / >
[0111] <meta-data android: name="hostname_whitelist" value="https: / / rc-odhenpos.teknisa.cloud" / > .
[0112] 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.
[0113] In one practicable manner, the predetermined format in step 302 is specifically a key-value pair format;
[0114] For example, configure the startup item information as:
[0115] name: whitelist_enabled value: true / false
[0116] The network access configuration information is:
[0117] name: whitelist_ip value: 192.168.8.102
[0118] name: whitelist_host value: www.ftsafe.com;
[0119] In an implementable manner, the manifest file also includes verification parameters, keys, and signature data;
[0120] 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.
[0121] Furthermore, an embodiment of the present invention provides a method for an application in an intelligent terminal device to access a network, such as Figure 4 , Figure 5 As shown, 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 the Android system. Specifically, the Android system includes a system service (System Server, referred to as SS) and a network driver. Further, the system service includes a package management service (PackageManagerService, referred to as PKMS) and a first connection service;
[0122] One possible way is to Figure 4 As shown, in this implementation, accessing the network setting is performed during the first installation of the application, and the method specifically includes:
[0123] Step 401: The package management service obtains the APK file of the application to be installed;
[0124] 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;
[0125] Specifically, the system starts the package management service by calling a preset method, and the preset method is PackageManagerService.installPackage;
[0126] An implementable method is to install the application through adb install.
[0127] 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;
[0128] Specifically, the first API interface is install Package();
[0129] 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;
[0130] Specifically, the function object is PackageParser.
[0131] 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.
[0132] In an implementable manner, the startup item information is configured as whitelist_enabled, and the first preset value is true;
[0133] 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.
[0134] 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;
[0135] 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;
[0136] 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;
[0137] 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.
[0138] Specifically, the first preset interface is CS.addWhitelist.
[0139] 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;
[0140] 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.
[0141] 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;
[0142] 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;
[0143] 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;
[0144] 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.
[0145] 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;
[0146] 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;
[0147] Specifically, the first preset method is NMS.enableWhitelist, and the second preset method is INetd.enableWhitelist.
[0148] Step 407: The network driver configures the network access configuration information into the filtering whitelist rule table through the configuration instruction, and ends.
[0149] 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;
[0150] Specifically, the network drivers include Netd local service and firewall controller;
[0151] 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;
[0152] 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;
[0153] 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.
[0154] 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;
[0155] 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).
[0156] 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.
[0157] 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;
[0158] 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.
[0159] In this embodiment, an practicable method is as follows: Figure 5 As shown, another method for an application in a smart terminal device to access a network is provided. Specifically, in this embodiment, the network access setting is performed during the upgrade process after the application is installed. The method specifically includes:
[0160] Step 501: The package management service obtains the APK file of the application to be installed;
[0161] 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.
[0162] Specifically, the system starts the package management service by calling a preset method, and the preset method is PackageManagerService.updatePackage;
[0163] An implementable method is to install or upgrade an application by remotely pushing an APK file.
[0164] 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;
[0165] Specifically, the second API interface is updatePackage();
[0166] 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;
[0167] Specifically, the function object is Package Parser.
[0168] 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;
[0169] In an implementable manner, the startup item information is configured as whitelist_enabled, and the first preset value is true;
[0170] 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;
[0171] In an practicable manner, the configuration startup item information may further be specifically a second preset value; wherein the second preset value is false;
[0172] 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.
[0173] 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;
[0174] 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;
[0175] 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;
[0176] 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.
[0177] Specifically, the first preset interface is CS.addWhitelist;
[0178] In this embodiment, the first connection service includes: a network connection service and a network management service;
[0179] 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.
[0180] Step 505: 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 506, otherwise terminate;
[0181] In this embodiment, the first connection service includes: a network connection service and a network management service;
[0182] 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;
[0183] 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.
[0184] 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;
[0185] 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.
[0186] 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;
[0187] 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;
[0188] 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;
[0189] Specifically, the fourth preset method is NMS.disableWhitelist, and the fifth preset method is INetd.disableWhitelist.
[0190] 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;
[0191] 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;
[0192] Specifically, the network drivers include Netd local service and firewall controller;
[0193] 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;
[0194] 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;
[0195] 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;
[0196] 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;
[0197] Among them, the first preset method is NMS.enableWhitelist, and the second preset method is INetd.enableWhitelist.
[0198] 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;
[0199] 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;
[0200] Specifically, the network drivers include Netd local service and firewall controller;
[0201] 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;
[0202] 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;
[0203] 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.
[0204] 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;
[0205] Specifically, the second preset interface is CS.RemoveWhitelist.
[0206] 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.
[0207] 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;
[0208] 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;
[0209] 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;
[0210] 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;
[0211] 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;
[0212] 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;
[0213] Specifically, the fourth preset method is NMS.disableWhitelist, and the fifth preset method is INetd.disableWhitelist.
[0214] 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.
[0215] 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;
[0216] Specifically, the network drivers include Netd local service and firewall controller;
[0217] 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;
[0218] 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.
[0219] 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.
[0220] 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;
[0221] 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.
[0222] 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;
[0223] 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.
[0224] 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.
[0225] Embodiment 3
[0226] 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.
[0227] like Figure 6 As shown, a method for an application in a smart terminal device to access a network provided by an embodiment of the present invention specifically includes:
[0228] 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.
[0229] 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);
[0230] Specifically, the first ICM interface is: enable.whitelistFromCustomer; the second ICM interface is: disable.whitelistFromCustomer.
[0231] 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;
[0232] In this embodiment, the application information is specifically an application package name, such as String packageName;
[0233] 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;
[0234] 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;
[0235] 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;
[0236] The first default interface is CS.addWhitelis.
[0237] 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.
[0238] 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;
[0239] 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;
[0240] Specifically, the first preset method is NMS.enableWhitelist, and the second preset method is INetd.enableWhitelist.
[0241] Step 604: The network driver configures the incoming network access configuration information into the filtering whitelist rule table through the configuration instruction, and ends;
[0242] 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;
[0243] 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.
[0244] 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;
[0245] 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.
[0246] 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;
[0247] 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;
[0248] 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.
[0249] 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;
[0250] 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;
[0251] 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;
[0252] The second preset interface is CS.RemoveWhitelis.
[0253] 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;
[0254] 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;
[0255] 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.
[0256] 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.
[0257] 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;
[0258] 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.
[0259] 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;
[0260] 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;
[0261] 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.
[0262] 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;
[0263] 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;
[0264] 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;
[0265] Specifically, the Netd local service is NetdNativeService; the sixth preset method is FC.disableWhitelist; and the firewall controller is Firewall Controller.
[0266] 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;
[0267] 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.
[0268] 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.
[0269] 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.
[0270] 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.
[0271] 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.
[0272] Embodiment 4
[0273] 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:
[0274] 1. The Android system will use DNS to resolve this domain name.
[0275] 2.TCP establishes a connection,
[0276] 3. The client sends an http request.
[0277] 4. The server processes the http request and returns the http data packet.
[0278] 5. The browser parses the http data packet, returns the result to the application, renders and refreshes the page.
[0279] In order to adapt to the scheme of the present invention, Figure 7 As shown, Embodiment 4 of the present invention provides a method for an application in a smart terminal device to access a network, the method comprising:
[0280] Step 701: The application initiates a network connection request;
[0281] 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.
[0282] Step 702: When the system service receives a network connection request, it monitors the network response data packet through the network driver;
[0283] 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;
[0284] 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;
[0285] 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.
[0286] Step 706: The system service returns a network response data packet to the application;
[0287] Step 707: The system service returns an error to the application.
[0288] 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;
[0289] 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;
[0290] In an practicable 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;
[0291] 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.
[0292] 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.
[0293] 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.
[0294] 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.
[0295] 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.
[0296] Among them, system services include:
[0297] 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;
[0298] 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;
[0299] 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;
[0300] 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;
[0301] In this device, the system services also include:
[0302] 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;
[0303] The sending module is used to return network response data packets to the application and also to return errors to the application;
[0304] In the device, the network driver also includes:
[0305] 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;
[0306] 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.
[0307] Optionally, the system service further includes a second acquisition judgment module and an acquisition deletion module;
[0308] The first determination module is further configured to trigger the second acquisition judgment module if the application network setting type is the second type;
[0309] 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;
[0310] 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;
[0311] 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.
[0312] 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.
[0313] 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;
[0314] 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;
[0315] The determination unit is used to determine the network access configuration type according to the configuration startup item information;
[0316] The calling unit is used to call the interface according to the network access configuration type.
[0317] 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.
[0318] Furthermore, the device includes a generation module for generating an APK file of an application to be installed;
[0319] 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.
[0320] 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;
[0321] 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;
[0322] 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;
[0323] 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.
[0324] Optionally, the device further includes a POS management service; the POS management service includes a second determination module and a calling module;
[0325] 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;
[0326] The calling module is used to call the interface of system services.
[0327] 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.
[0328] 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.
[0329] 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.
[0330] 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.
[0331] 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.
[0332] 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;
[0333] Optionally, the receiving module specifically includes a monitoring unit, and the monitoring unit is used to monitor the network response data packet;
[0334] The monitoring unit is specifically used to monitor the network response data packet corresponding to the application set with the firewall permission group information.
[0335] 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.
[0336] 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.
[0337] 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.
[0338] 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.
[0339] 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.
[0340] 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.
[0341] 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.
[0342] 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.
[0343] 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
1. A method for network access by an application in an intelligent terminal device, wherein the intelligent terminal device includes a system service and a network driver, characterized in that: The method comprises: 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; 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; 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; 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: 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; 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; 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; Step F4, the system service returns the network response data packet to the application; Step F5: the system service returns an error to the application; In the step S3, before the network access configuration information in the application configuration information is saved in the custom IP address list, the step further includes: Step M21, the system service determines whether there is network access configuration information in the custom IP address list, and if so, executes step M22, otherwise, saves the network access configuration information in the application configuration information into the custom IP address list; 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 goes to step M23; 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; 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 deletion instruction; In the step S2, when it is determined that there is user firewall permission information according to the application configuration information, the step 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; The system service monitoring the network response data packet through the network driver specifically includes: the system service monitoring the network response data packet corresponding to the application set with the firewall permission group information through the network driver.
2. The method according to claim 1, characterized in that 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: Step S5, the system service obtains the application configuration information transmitted through the called second preset interface, and determines whether there is user firewall authority information according to the application configuration information, and if yes, executes step S6, otherwise ends; Step S6, the system service obtains a custom IP address list, determines whether there is network access configuration information in the custom IP address list, 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 S7, otherwise ends; Step S7: The network driver deletes the network access configuration information from the filtering whitelist rule table through a deletion instruction, and the process ends.
3. The method according to claim 2, characterized in that 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.
4. The method according to claim 1, characterized in that: The system service includes a package management service, and before step S1, the following steps are also included: Step P1, the package management service obtains the APK file of the application to be installed; Step P2: The package management service calls an API interface to parse the manifest file in the APK file to be installed, and obtains configuration startup item information; Step P3: 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.
5. The method according to claim 4, characterized in that In the step P3, the interface for calling the system service is specifically as follows: 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 interface of the system service to pass in the application configuration information as a parameter.
6. The method according to claim 4, characterized in that The method further comprises generating an APK file to be installed for the application; The specific steps of generating the APK file to be installed are as follows: Step D1, determining the network access configuration type; 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 APK file to be installed for the application.
7. The method according to claim 2, characterized in that The intelligent terminal device also includes POS management services; The method before step S1 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.
8. The method according to claim 7, characterized in that The interface for calling the system service according to the determined interface type is specifically as follows: the POS management service obtains the application package name, organizes the network access configuration information and the application package name to obtain application configuration information, and calls the interface of the system service to pass in the application configuration information as a parameter.
9. The method according to claim 8, characterized in that The determining whether there is user firewall permission information according to the application configuration information is specifically: The system service determines whether there is user firewall permission information according to the application package name in the application configuration information.
10. The method according to claim 1, characterized in that When it is determined according to the application configuration information that user firewall authority information exists, the method further includes: The system service obtains the verification data in the application configuration information to perform code verification. If the verification is successful, the network configuration authority is obtained and step S3 is executed. If the verification is not successful, the process ends.
11. The method according to claim 1, characterized in that When the intelligent terminal device is turned off, the method further includes: the network driver deletes all the network access configuration information in the filtering whitelist rule table through a deletion instruction.
12. The method according to claim 1, characterized in that 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 S4.
13. A device for an application in an intelligent terminal device to access a network, characterized in that: The device is implemented by using the method for network access by application in a smart terminal device according to any one of claims 1 to 12, and the device includes a system service and a network driver, and the system service includes: A first determination module, configured to determine an application network setting type according to the called interface type, and trigger a first acquisition judgment module if the application network setting type is a 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; 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, which is used to configure the network access configuration information into a filtering whitelist rule table through a configuration instruction; 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; 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.
14. A computer device comprising a memory, a processor and a computer program stored in the memory, characterized in that: The processor executes the computer program to implement the method according to any one of claims 1 to 12.
15. A computer-readable storage medium having a computer program / instruction stored thereon, characterized in that: When the computer program / instructions are executed by a processor, the method according to any one of claims 1 to 12 is implemented.
16. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the method according to any one of claims 1 to 12 is implemented.
