Processing method and device for docking equipment
The method and apparatus streamline the integration of third-party devices by using a pre-configured interceptor and uniform interface, addressing the lack of unified authorization and interface configuration in existing systems, thereby simplifying and optimizing the docking process.
Patent Information
- Application Number
- CN202010828119.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-08-17
- Publication Date
- 2024-12-10
- Estimated Expiration
- 2040-08-17
AI Technical Summary
Existing technologies lack a unified configuration for authorization and calling interface when connecting to third-party devices, leading to increased development workload and repetitive tasks.
A method and apparatus that utilize a pre-configured interceptor to authenticate third-party devices and a uniformly configured request calling interface for seamless integration, reducing the need for repetitive development and simplifying the docking process.
Provides a unified authorization and calling interface for third-party devices, reducing development workload and enhancing efficiency in the docking process.
Smart Images

Figure CN111966992B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method and device for processing a docking device. Background Art
[0002] Since the disaster prevention and control system (for example, the fire hazard prevention and control system) needs to be connected with different third-party identifications, it will encounter API interfaces of third-party devices in different scenarios, such as third-party account login, third-party services, etc. There are some optimized third-party connection methods in the existing technology, which can reduce the development error rate to a certain extent.
[0003] However, the existing technology does not provide a unified configuration for authorization when connecting to third-party devices, there is no optimized way to call the interface, and there is no simple idea for convenient development, which increases the workload of R&D personnel and causes tedious repetitive development.
[0004] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0005] The embodiment of the present invention provides a method and apparatus for processing a docking device, so as to at least solve the technical problem of the prior art that there is a lack of unified configuration authorization and calling interface when docking a third-party device.
[0006] According to one aspect of an embodiment of the present invention, a method for processing a docking device is provided, comprising: upon receiving a docking request from a third-party device, calling an interceptor to perform authentication processing on the access rights of the third-party device to obtain an authentication processing result, wherein the interceptor is pre-configured with authentication permissions corresponding to each third-party device; if the authentication processing result is authentication passed, a uniformly configured request calling interface is used to dock the third-party device.
[0007] Optionally, before calling the interceptor to authenticate the access rights of the third-party device, the method further includes: pre-configuring the interceptor, and configuring the authentication authority corresponding to each of the plurality of third-party devices in the interceptor.
[0008] Optionally, after connecting to the third-party device using a uniformly configured request calling interface, the method further includes: receiving an access request from the third-party device; sending the access request to a remote server using the request calling interface, wherein the remote server is used to determine response data corresponding to the access request; and forwarding the response data received and returned by the remote server to the third-party device.
[0009] Optionally, the call interceptor performs authentication processing on the access rights of the third-party device to obtain an authentication processing result, including: obtaining the authentication authority corresponding to the third-party device; using the authentication authority to perform authentication processing on the access rights of the third-party device to obtain the authentication processing result.
[0010] Optionally, the method further includes: if the authentication processing result is that the authentication fails, rejecting the docking request of the third-party device, and returning a prompt message to the third-party device, wherein the prompt message is used to prompt that the docking fails.
[0011] According to another aspect of an embodiment of the present invention, a processing device for a docking device is also provided, including: a calling module, which is used to call an interceptor to perform authentication processing on the access rights of the third-party device when a docking request is received from the third-party device, and obtain an authentication processing result, wherein the interceptor is pre-configured with authentication permissions corresponding to each third-party device; and a docking module, which is used to use a uniformly configured request calling interface to dock the third-party device if the authentication processing result is that the authentication is passed.
[0012] Optionally, the apparatus further includes: a configuration module, configured to pre-configure the interceptor, and configure in the interceptor the authentication authority corresponding to each of the plurality of third-party devices.
[0013] Optionally, the above-mentioned device also includes: a receiving module, used to receive an access request from the above-mentioned third-party device; a first sending module, used to send the above-mentioned access request to a remote server using the above-mentioned request calling interface, wherein the above-mentioned remote server is used to determine the response data corresponding to the above-mentioned access request; a second sending module, used to forward the above-mentioned response data returned by the above-mentioned remote server to the above-mentioned third-party device.
[0014] According to another aspect of an embodiment of the present invention, a non-volatile storage medium is provided. The non-volatile storage medium stores a plurality of instructions. The instructions are suitable for being loaded by a processor and executing any one of the above-mentioned processing methods for the docking device.
[0015] According to another aspect of an embodiment of the present invention, there is further provided an electronic device, comprising: a processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing any one of the above-mentioned processing methods for the docking device.
[0016] In an embodiment of the present invention, when a docking request is received from a third-party device, an interceptor is called to perform authentication processing on the access rights of the third-party device to obtain an authentication processing result, wherein the interceptor is pre-configured with authentication permissions corresponding to each third-party device; if the authentication processing result is that the authentication is passed, a uniformly configured request calling interface is used to dock the third-party device, thereby achieving the purpose of providing a uniformly configured authorization and calling interface when docking with a third-party device and simplifying the docking process, thereby achieving the technical effect of reducing the docking workload and more efficiently docking third-party devices, thereby solving the technical problem of the prior art lacking a uniformly configured authorization and calling interface when docking with a third-party device. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0018] Figure 1 is a flow chart of a processing method for docking a device according to an embodiment of the present invention;
[0019] Figure 2 is a schematic diagram of an optional processing method of a docking device according to an embodiment of the present invention;
[0020] Figure 3 It is a structural schematic diagram of a processing device of a docking device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0021] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0022] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0023] First, to facilitate understanding of the embodiments of the present invention, some terms or nouns involved in the present invention are explained below:
[0024] Interceptor: An interceptor in Java is an object that dynamically intercepts action calls. It provides a mechanism for developers to define code to be executed before and after an action is executed, and to prevent an action from being executed before it is executed. It also provides a way to extract reusable parts of an action. In AOP (Aspect-Oriented Programming), interceptors are used to intercept a method or field before it is accessed and then add certain operations before or after it.
[0025] RestTemplate: It is a client provided by Spring for accessing Rest services. RestTemplate provides a variety of convenient methods for accessing remote Http services, which can greatly improve the efficiency of client writing.
[0026] OpenFeign: A declarative client, OpenFeign creates dynamic implementations of interfaces decorated with JAX-RS or Spring MVC annotations, simplifying the way to interact with other services.
[0027] Example 1
[0028] According to an embodiment of the present invention, an embodiment of a processing method for a docking device is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0029] Figure 1 is a flow chart of a processing method for docking a device according to an embodiment of the present invention. Figure 1As shown, the method comprises the following steps:
[0030] Step S102, upon receiving a connection request from a third-party device, calling an interceptor to authenticate the access rights of the third-party device to obtain an authentication result, wherein the interceptor is pre-configured with authentication rights corresponding to each third-party device;
[0031] Step S104: If the authentication processing result is that the authentication is passed, a uniformly configured request calling interface is used to connect to the third-party device.
[0032] In an embodiment of the present invention, when a docking request is received from a third-party device, an interceptor is called to perform authentication processing on the access rights of the third-party device to obtain an authentication processing result, wherein the interceptor is pre-configured with authentication permissions corresponding to each third-party device; if the authentication processing result is that the authentication is passed, a uniformly configured request calling interface is used to dock the third-party device, thereby achieving the purpose of providing a uniformly configured authorization and calling interface when docking with a third-party device and simplifying the docking process, thereby achieving the technical effect of reducing the docking workload and more efficiently docking third-party devices, thereby solving the technical problem of the prior art lacking a uniformly configured authorization and calling interface when docking with a third-party device.
[0033] In the above optional embodiment, when a docking request is received from a third-party device, since the interceptor is pre-configured with authentication permissions corresponding to each third-party device, the access permissions of the above-mentioned third-party device can be authenticated by calling the interceptor to obtain an authentication result. Moreover, since a request calling interface is uniformly configured for all third-party devices in advance, if the authentication result of the above-mentioned third-party device is authentication passed, the uniformly configured request calling interface is used to dock the above-mentioned third-party device, which can simplify the docking process, reduce the docking workload, and dock third-party devices more efficiently.
[0034] Through the embodiments of the present application, the defects of repeated development in the prior art can be overcome, and interceptors can be used to dynamically configure different authentication permissions for each third-party device, and the request calling interface with the third-party device can be uniformly configured to facilitate the unified management of the docking permissions of the third-party devices. When providing the request calling interface, in order to facilitate development, a new interface class is also created, and the API is called using OpenFeign and the extracted configuration method.
[0035] Through the embodiment of the present application, it is realized that when connecting to various third-party devices, the authentication authority can be uniformly managed, and when parsing the return results of calling third-party devices, it can be simplified and does not need to parse the complex JSONObject class, reducing the errors that are easy to occur during development. In addition, the embodiment of the present application does not need to use URL splicing when calling the interface, and can use an interface class to uniformly manage the methods that need to be called, which is more standardized and conforms to the object-oriented development method, and can realize load-balanced calling of http clients.
[0036] In an optional embodiment, the method further includes: if the authentication processing result is that the authentication fails, rejecting the docking request of the third-party device, and returning a prompt message to the third-party device, wherein the prompt message is used to prompt the docking failure.
[0037] In an optional embodiment, before calling the above-mentioned interceptor to authenticate the access rights of the above-mentioned third-party device, the above-mentioned method also includes: pre-configuring the above-mentioned interceptor, and configuring the above-mentioned authentication authority corresponding to each of the above-mentioned third-party devices in the above-mentioned interceptor.
[0038] In an optional embodiment, Figure 2 is a flow chart of an optional processing method for docking a device according to an embodiment of the present invention. Figure 2 As shown, after the third-party device is connected using a uniformly configured request calling interface, the method further includes:
[0039] Step S202, receiving an access request from the third-party device;
[0040] Step S204, sending the access request to a remote server using the request calling interface, wherein the remote server is used to determine response data corresponding to the access request;
[0041] Step S206: forward the response data received from the remote server to the third-party device.
[0042] In the above optional embodiment, after the above-mentioned third-party device is connected using a uniformly configured request calling interface, that is, after the third-party device is successfully connected, an access request from the above-mentioned third-party device can also be received, and the above-mentioned access request can be sent to the remote server using the above-mentioned request calling interface, and the above-mentioned response data returned by the above-mentioned remote server can be forwarded to the above-mentioned third-party device.
[0043] In an optional embodiment, the call interceptor performs authentication processing on the access rights of the third-party device to obtain an authentication processing result, including:
[0044] Step S302, obtaining the authentication authority corresponding to the third-party device;
[0045] Step S304: Use the authentication authority to authenticate the access rights of the third-party device to obtain the authentication result.
[0046] In the above optional embodiment, since the interceptor is pre-configured with the authentication authority corresponding to each third-party device, the access authority of the third-party device can be authenticated by calling the interceptor to obtain the authentication result.
[0047] The embodiment of the present application implements a unified development method for obtaining access rights of third-party devices by writing a public interceptor, which can realize unified authorization management of access rights. The public interceptor can be used for development each time a third-party device is connected, effectively avoiding the repeated development phenomenon in the prior art. In addition, the embodiment of the present application reduces development errors by using RestTemplate, avoids parsing cumbersome JSONObject classes, and adopts OpenFeign to configure API interfaces, thereby simplifying development and making docking easier.
[0048] Since the token authentication and authorization will be performed first when connecting to a third-party device, a unified interceptor is pre-configured, and the authentication permissions corresponding to each third-party device are set in the interceptor. Since the interceptor can be reused, the interceptor can be used for authentication and authorization each time a third-party device is connected.
[0049] It should be noted that, for example, configuration information such as application ID and application key needs to be extracted into the configuration file and then written into the interceptor, rather than being injected into the interceptor in a hard-coded manner.
[0050] In the embodiment of the present application, the request calling interface is implemented by RestTemplate calling, and SpringBoot is used to encapsulate RestTemplate. Compared with the native JDK initiating HTTP request method, the HTTP request can be simplified, and the JDK is used internally by default to construct the HTTP client. GetForObject can be used to encapsulate the corresponding data into an object, without relying on cumbersome JSON format conversion to obtain data.
[0051] By using OpenFeign and extracting configuration to call the API, the problem of too many docking interfaces can be solved by using OpenFeign in SrpingCloud. Due to its powerful functions, OpenFeign can provide solutions for calls between services under the microservice architecture. At the same time, it can also be combined with other components to implement a load-balanced HTTP client. There is no Url splicing. You only need to define a request call interface. By defining all methods in the request call interface, you can directly call the method.
[0052] Example 2
[0053] According to an embodiment of the present invention, there is also provided an apparatus embodiment for implementing the above-mentioned processing method of the docking device. Figure 3 is a schematic diagram of the structure of a processing device of a docking device according to an embodiment of the present invention. Figure 3 As shown, the processing device of the docking device includes: a calling module 30 and a docking module 32, wherein:
[0054] The calling module 30 is used to call the interceptor to authenticate the access rights of the third-party device when receiving a docking request from the third-party device, and obtain the authentication processing result, wherein the above-mentioned interceptor is pre-configured with the authentication authority corresponding to each third-party device; the docking module 32 is used to use a uniformly configured request calling interface to dock the above-mentioned third-party device if the above-mentioned authentication processing result is that the authentication is passed.
[0055] Optionally, the apparatus further includes: a configuration module, configured to pre-configure the interceptor, and configure in the interceptor the authentication authority corresponding to each of the plurality of third-party devices.
[0056] Optionally, the above-mentioned device also includes: a receiving module, used to receive an access request from the above-mentioned third-party device; a first sending module, used to send the above-mentioned access request to a remote server using the above-mentioned request calling interface, wherein the above-mentioned remote server is used to determine the response data corresponding to the above-mentioned access request; a second sending module, used to forward the above-mentioned response data returned by the above-mentioned remote server to the above-mentioned third-party device.
[0057] It should be noted that the above modules can be implemented by software or hardware. For example, for the latter, it can be implemented in the following ways: the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.
[0058] It should be noted that the calling module 30 and the docking module 32 correspond to steps S102 to S104 in Example 1, and the examples and application scenarios implemented by the modules and the corresponding steps are the same, but are not limited to the contents disclosed in the above-mentioned Example 1. It should be noted that the modules as part of the device can be run in a computer terminal.
[0059] It should be noted that the optional or preferred implementation of this embodiment can refer to the relevant description in Example 1, which will not be repeated here.
[0060] The processing device of the docking device may further include a processor and a memory. The calling module 30, docking module 32, etc. are stored in the memory as program units, and the processor executes the program units stored in the memory to implement corresponding functions.
[0061] The processor includes a kernel, which retrieves the corresponding program unit from the memory. The kernel may be one or more. The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. The memory includes at least one memory chip.
[0062] According to an embodiment of the present application, a non-volatile storage medium embodiment is also provided. Optionally, in this embodiment, the non-volatile storage medium includes a stored program, wherein when the program is executed, the device where the non-volatile storage medium is located is controlled to execute any of the above-mentioned processing methods for docking devices.
[0063] Optionally, in this embodiment, the non-volatile storage medium may be located in any computer terminal in a computer terminal group in a computer network, or in any mobile terminal in a mobile terminal group, and the non-volatile storage medium includes a stored program.
[0064] Optionally, when the program is running, the device where the non-volatile storage medium is located is controlled to perform the following functions: when a docking request is received from a third-party device, an interceptor is called to authenticate the access rights of the third-party device to obtain an authentication result, wherein the interceptor is pre-configured with authentication permissions corresponding to each third-party device; if the authentication result is that the authentication is passed, a uniformly configured request call interface is used to dock the third-party device.
[0065] According to an embodiment of the present application, a processor embodiment is also provided. Optionally, in this embodiment, the processor is used to run a program, wherein when the program is run, any one of the processing methods for docking a device is executed.
[0066] An embodiment of the present application provides an electronic device, which includes a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, the following steps are implemented: upon receiving a docking request from a third-party device, an interceptor is called to perform authentication processing on the access rights of the third-party device to obtain an authentication processing result, wherein the interceptor is pre-configured with authentication permissions corresponding to each third-party device; if the authentication processing result is that the authentication is passed, a uniformly configured request calling interface is used to dock the third-party device.
[0067] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing an initialization program having the following method steps: upon receiving a docking request from a third-party device, calling an interceptor to perform authentication processing on the access rights of the above-mentioned third-party device to obtain an authentication processing result, wherein the above-mentioned interceptor is pre-configured with authentication permissions corresponding to each third-party device; if the above-mentioned authentication processing result is that the authentication is passed, a uniformly configured request call interface is used to dock the above-mentioned third-party device.
[0068] 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.
[0069] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0070] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0071] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0072] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0073] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable non-volatile storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a non-volatile storage medium, including a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned non-volatile storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.
[0074] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A method for processing a docking device, characterized in that: include: Upon receiving a connection request from a third-party device, calling an interceptor to authenticate the access rights of the third-party device and obtaining an authentication result, wherein the interceptor is pre-configured with authentication rights corresponding to each third-party device; If the authentication processing result is authentication passed, the third-party device is connected using the request calling interface configured by RestTemplate, wherein the RestTemplate is encapsulated by SpringBoot; Before calling the interceptor to authenticate the access rights of the third-party device, the method further includes: The interceptor is pre-configured, and the authentication authority corresponding to each of the plurality of third-party devices is configured in the interceptor, wherein the interceptor is a reusable interceptor, and the configuration of the interceptor is obtained by extracting configuration information into a configuration file and then writing it into the interceptor.
2. The method according to claim 1, characterized in that After connecting to the third-party device using a uniformly configured request calling interface, the method further includes: receiving an access request from the third-party device; Using the request calling interface to send the access request to a remote server, wherein the remote server is used to determine response data corresponding to the access request; The response data returned by the remote server is forwarded to the third-party device.
3. The method according to claim 1, characterized in that The call interceptor performs authentication processing on the access rights of the third-party device to obtain an authentication processing result, including: Obtaining the authentication authority corresponding to the third-party device; The authentication authority is used to perform authentication processing on the access authority of the third-party device to obtain the authentication processing result.
4. The method according to claim 1, characterized in that: The method further comprises: If the authentication processing result is that the authentication fails, the docking request of the third-party device is rejected, and a prompt message is returned to the third-party device, wherein the prompt message is used to prompt that the docking fails.
5. A processing device for a docking device, characterized in that: include: A calling module, configured to, upon receiving a connection request from a third-party device, call an interceptor to perform authentication processing on the access rights of the third-party device to obtain an authentication processing result, wherein the interceptor is pre-configured with authentication rights corresponding to each third-party device; A docking module, used for docking the third-party device by using the request calling interface configured by RestTemplate if the authentication processing result is authentication passed, wherein the RestTemplate is encapsulated by SpringBoot; The device further includes: a configuration module, used to pre-configure the interceptor, and configure the authentication authority corresponding to each of the multiple third-party devices in the interceptor, wherein the interceptor is a reusable interceptor, and the configuration of the interceptor is obtained by extracting the configuration information into a configuration file and then writing it into the interceptor.
6. The device according to claim 5, characterized in that The device also includes: A receiving module, used for receiving an access request from the third-party device; A first sending module, configured to send the access request to a remote server using the request calling interface, wherein the remote server is configured to determine response data corresponding to the access request; The second sending module is used to forward the response data returned by the remote server to the third-party device.
7. A non-volatile storage medium, characterized in that: The non-volatile storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing the processing method of the docking device according to any one of claims 1 to 4.
8. An electronic device, characterized in that: include: A processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the processing method of the docking device as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Access method and device for application system
CN107277049A
Authentication and authorization method and system based on Kubernetes
CN110995450A
Authorization authentication configuration method and device, authorization authentication method and device and electronic equipment
CN111064708A
Service calling legality detection method and device, computer equipment and computer storage medium
CN111274046A
Methods and systems for authorizing web service requests
US20150350212A1
