A method and system for implementing WEB component token timing update based on NIFI interface

By setting up Controller Service and creating a new Controller Service interface definition in the NIFI interface, the timed update of the WEB component token is implemented, solving the problem of interface call failure caused by token expiration, reducing development costs and improving user experience.

CN113535205BActive Publication Date: 2025-02-18SHANDONG LANGCHAO YUNTOU INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110828623.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-07-22
Publication Date
2025-02-18
Estimated Expiration
2041-07-22

AI Technical Summary

Technical Problem

In the prior art, if token verification is required when WEB components call the interface, timed update cannot be achieved if the token expires, resulting in the interface call failure.

Method used

By setting the parameter definition configuration of Controller Service in the NIFI interface, creating a new Controller Service interface definition, obtaining the request header information, request body information and expiration time parameters of the token interface, and determining whether the cache needs to be updated in the system. If it expires, get the latest token and update the cache.

Benefits of technology

The timed update of tokens is implemented, which avoids interface call failures caused by token expiration, simplifies the steps to obtain tokens, reduces development costs, and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113535205B_ABST
    Figure CN113535205B_ABST
Patent Text Reader

Abstract

The invention discloses a method and system for implementing regular update of WEB component token based on NIFI interface, belonging to the field of computer. The method comprises the following specific steps: S1 sets parameter definition configuration of Controller Service; S2 determines whether cache needs to be updated; S3 directly obtains StateManager from context ProcessContext according to NIFI, obtains corresponding Map data in Key / Value form according to getState method in the interface, and obtains token according to key of corresponding token. At present, if the interface call of WEB component is a call without interface verification, the information required by the corresponding interface can be directly filled in the component to obtain the return parameter. If token verification is required, there is a situation that token expires and cannot be updated regularly. The method of the invention wraps a layer of interface outside, requests token interface first and then puts in corresponding parameters, which increases the cost of interface development. For the convenience of component use, the step of obtaining token is omitted, and the step of obtaining token is integrated into WEB component, which reduces development cost and improves user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention discloses a method and a system for realizing the regular update of a WEB component token based on a NIFI interface, and relates to the technical field of computers. Background Art

[0002] Apache NiFi is an easy-to-use, powerful and reliable data processing and distribution system. Apache NiFi is designed for data flow. It supports highly configurable data routing, conversion and system mediation logic of indicator diagrams, and supports dynamic data pulling from multiple data sources. Simply put, NiFi is born for data flow between automated systems. The data flow here represents the automated and managed information flow between systems. Based on the WEB graphical interface, process-based programming is completed by dragging, connecting and configuring to realize data collection, processing and other functions.

[0003] The basic design concept of NiFi is Flow-Based Programming (FBP). The application is a network composed of processor black boxes and connectors. Data enters a node, which processes the data and routes the data to other subsequent nodes for processing based on different processing results.

[0004] At present, for the interface call of the WEB component, if it is a call without verification, the information required by the corresponding interface can be directly filled in the component to obtain the return parameters. If token verification is required, there is a situation where the token expires and cannot be updated regularly. Therefore, a method and system for implementing regular update of WEB component token based on NIFI interface is invented to solve the above problem. Summary of the invention

[0005] In view of the problems of the prior art, the present invention provides a method and system for implementing the timed update of a WEB component token based on a NIFI interface. The technical solution adopted is: a method for implementing the timed update of a WEB component token based on a NIFI interface, wherein the specific steps of the method include:

[0006] S1 sets the parameter definition configuration of the Controller Service;

[0007] S2 determines whether the cache needs to be updated;

[0008] S3 obtains StateManager directly from the context ProcessContext according to NIFI, obtains the corresponding Map data in Key / Value format according to the getState method in the interface, and obtains the token according to the key of the corresponding token.

[0009] The specific steps of setting the parameter definition configuration of the Controller Service in S1 include:

[0010] S101 creates a new NIFI Controller Service interface definition;

[0011] S102 obtains the request header information, request body information and expiration time parameter of the token interface.

[0012] The step S2 of determining whether the cache needs to be updated includes:

[0013] S201 compares the magnitude relationship between the current event of the system and the sum of the last initialization time and the expiration time;

[0014] If S202 is greater than, the latest token is obtained and stored in the cache;

[0015] If S212 is less than , the token is obtained from the interface and stored in the cache.

[0016] If S202 is greater than, the specific steps of obtaining the latest token and storing it in the cache include:

[0017] S2021 calls the API for obtaining a token and updates the updated token to the cache;

[0018] S2022 records and updates the current system time to the time point of the latest initialization token.

[0019] A WEB component token timing update implementation system based on NIFI interface, the system specifically includes a parameter setting module, an update judgment module and a data update module:

[0020] Parameter setting module: set the parameter definition configuration of Controller Service;

[0021] Update judgment module: judge whether the cache needs to be updated;

[0022] Data update module: According to NIFI, directly obtain StateManager from the context ProcessContext, obtain the corresponding Map data in Key / Value format according to the getState method in the interface, and obtain the token according to the corresponding token key.

[0023] The parameter setting module specifically includes an interface creation module and an information acquisition module:

[0024] Interface creation module: Create a new NIFI Controller Service interface definition;

[0025] Information acquisition module: obtains the request header information, request body information and expiration time parameters of the token interface.

[0026] The update judgment module specifically includes a comparison module, a cache module A and a cache module B:

[0027] Comparison module: compares the size relationship between the current system event and the sum of the last initialization time and the expiration time;

[0028] Cache module A: If it is greater than, get the latest token and store it in the cache;

[0029] Cache module B: If it is less than, get the token from the interface and store it in the cache.

[0030] The cache module A specifically includes a cache update module and an update record module:

[0031] Cache update module: call the interface for obtaining token and update the updated token to the cache;

[0032] Update record module: record and update the current system time to the time point of the latest initialization token.

[0033] The beneficial effects of the present invention are as follows: for the current interface call of a WEB component, if the interface is a call without verification, the information required by the corresponding interface can be directly filled in the component to obtain the return parameters. If token verification is required, there is a situation where the token expires and cannot be updated regularly. The method of the present invention wraps a layer of interface on the outside, first requests the token interface and then puts in the corresponding parameters, which increases the cost of interface development. In order to facilitate the use of the component, the step of obtaining the token is omitted, and the step of obtaining the token is integrated into the WEB component, reducing development costs and improving user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0035] Figure 1 is a flow chart of the method of the present invention; Figure 2 It is a schematic diagram of the structure of the system of the present invention. DETAILED DESCRIPTION

[0036] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments so that those skilled in the art can better understand the present invention and implement it, but the embodiments are not intended to limit the present invention.

[0037] Embodiment 1:

[0038] A method for implementing a timed update of a WEB component token based on a NIFI interface, wherein the method comprises the following specific steps:

[0039] S1 sets the parameter definition configuration of the Controller Service;

[0040] S2 determines whether the cache needs to be updated;

[0041] S3 directly obtains StateManager from the context ProcessContext according to NIFI, obtains the corresponding Map data in Key / Value format according to the getState method in the interface, and obtains the token according to the key of the corresponding token;

[0042] Furthermore, the specific steps of setting the parameter definition configuration of the Controller Service in S1 include:

[0043] S101 creates a new NIFI Controller Service interface definition;

[0044] S102 obtains the request header information, request body information and expiration time parameter of the token interface;

[0045] First, set the parameter definition configuration of the Controller Service according to S1. In order to achieve the regular update of token, you need to create a new Controller Service that implements nifi. In this control service design, users need to configure the necessary parameters for obtaining tokens, such as the request header information of the URL interface of the token interface, the request body information of the interface, and the expiration time of the token, expire_time. If you want to control whether to update, you can add a new update parameter, depending on the business scenario; 1

[0046] The following is the interface definition of the newly implemented Controller Service:

[0047]

[0048]

[0049]

[0050] The above is to reference the new Controller Service in the specified web call component;

[0051] Furthermore, the step of determining whether the cache needs to be updated in S2 includes:

[0052] S201 compares the magnitude relationship between the current event of the system and the sum of the last initialization time and the expiration time;

[0053] If S202 is greater than, the latest token is obtained and stored in the cache;

[0054] If S212 is less than 1, the token is obtained from the interface and stored in the cache;

[0055] Furthermore, if S202 is greater than , the specific steps of obtaining the latest token and storing it in the cache include:

[0056] S2021 calls the API for obtaining a token and updates the updated token to the cache;

[0057] S2022 records and updates the current system time to the time point of the latest initialization token.

[0058] After successful configuration, when the user starts the component for the first time, the method for obtaining the token is initialized in the @OnScheduled method (the annotated method will be called before being called by onTrigger, and will be called once each time a processor or report task is scheduled to run). Before calling the token method, first check whether the token already exists from the stateManager interface of nifi. If the token does not exist, directly initialize the call to the interface for obtaining the token to the cache of nifi. It can be set to local cache to avoid the deviation between node times affecting the result of judging whether the token has expired;

[0059] If a token exists, take it out and compare it with the system time of the last recorded token update to see if the latest token needs to be obtained. The judgment method is as follows:

[0060] 1. If the system time is less than the sum of the user-defined expiration time expire_time and the time when the token was last initialized, the corresponding token value is directly obtained from the cache;

[0061] 2. If the system time is greater than the expiration time expire_time and the time when the token was last initialized, the interface for obtaining the token is called to update the updated token to the cache. At the same time, the current system time needs to be recorded and updated to the time point when the token was last initialized. The time point can be saved in the cache like the token. Of course, a built-in variable can also be customized to save the time point. If a variable is used, the security and reliability of the variable in concurrent situations must be guaranteed. After obtaining the corresponding token, the updated token can be stored in the cache. This can be done by using the setState(Map<String, String>) in the StateManager in NIFI.<String,String> state,Scope scope) method stores the token into the cache interface, where the key in the parameter state is custom set, and the value stores the latest token value. For example, if a new Map object is set with the Key being authorization, map.put("authorization", "token") is used to initialize the parameters. Of course, other required parameters can also be stored if necessary, stateManage.setState(map,Scope.LOCAL). After the initialization is completed, the process enters the onTrigger(ProcessContext context,ProcessSession session) method for subsequent process use.

[0062]

[0063]

[0064]

[0065]

[0066] When you need to use a token, you can directly obtain the StateManager from the context ProcessContext of Nifi, for example, and obtain the corresponding Map data in the form of Key / Value according to the getState(Scope scope) method in the interface, and obtain the token according to the key of the corresponding token. For example, for a token stored in the form of local cache, context.getStateManager() obtains the stateManager, and then uses stateManager.getState(Scope.LOCAL) to obtain the corresponding Map of Key / Value values. If the custom Key is authorization, then map.get(authorization) is used to obtain the corresponding token value for easy use.

[0067] Embodiment 2:

[0068] A WEB component token timing update implementation system based on NIFI interface, the system specifically includes a parameter setting module, an update judgment module and a data update module:

[0069] Parameter setting module: set the parameter definition configuration of Controller Service;

[0070] Update judgment module: judge whether the cache needs to be updated;

[0071] Data update module: According to NIFI, directly obtain StateManager from the context ProcessContext, obtain the corresponding Map data in Key / Value format according to the getState method in the interface, and obtain the token according to the key of the corresponding token;

[0072] Furthermore, the parameter setting module specifically includes an interface creation module and an information acquisition module:

[0073] Interface creation module: Create a new NIFI Controller Service interface definition;

[0074] Information acquisition module: obtains the request header information, request body information and expiration time parameters of the token interface;

[0075] Furthermore, the update judgment module specifically includes a comparison module, a cache module A and a cache module B:

[0076] Comparison module: compares the size relationship between the current system event and the sum of the last initialization time and the expiration time;

[0077] Cache module A: If it is greater than, get the latest token and store it in the cache;

[0078] Cache module B: If it is less than, get the token from the interface and store it in the cache;

[0079] Furthermore, the cache module A specifically includes a cache update module and an update record module:

[0080] Cache update module: call the interface for obtaining token and update the updated token to the cache;

[0081] Update record module: record and update the current system time to the time point of the latest initialization token.

[0082] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for implementing a timed update of a WEB component token based on a NIFI interface, characterized in that The specific steps of the method include: S1 sets the parameter definition configuration of the Controller Service; S2 determines whether the cache needs to be updated; S3 directly obtains StateManager from the context ProcessContext according to NIFI, obtains the corresponding Map data in Key / Value format according to the getState method in the interface, and obtains the token according to the key of the corresponding token; The specific steps of setting the parameter definition configuration of the Controller Service in S1 include: S101 creates a new NIFI Controller Service interface definition; S102 obtains the request header information, request body information and expiration time parameter of the token interface; The step S2 of determining whether the cache needs to be updated includes: S201 compares the magnitude relationship between the current event of the system and the sum of the last initialization time and the expiration time; If S202 is greater than, the latest token is obtained and stored in the cache; If S212 is less than 1, the token is obtained from the interface and stored in the cache; If S202 is greater than, the specific steps of obtaining the latest token and storing it in the cache include: S2021 calls the API for obtaining a token and updates the updated token to the cache; S2022 records and updates the current system time to the time point of the latest initialization token.

2. A WEB component token timing update implementation system based on NIFI interface, characterized by The system specifically includes a parameter setting module, an update judgment module and a data update module: Parameter setting module: set the parameter definition configuration of Controller Service; Update judgment module: judge whether the cache needs to be updated; Data update module: According to NIFI, directly obtain StateManager from the context ProcessContext, obtain the corresponding Map data in Key / Value format according to the getState method in the interface, and obtain the token according to the key of the corresponding token; The parameter setting module specifically includes an interface creation module and an information acquisition module: Interface creation module: Create a new NIFI Controller Service interface definition; Information acquisition module: obtains the request header information, request body information and expiration time parameters of the token interface; The update judgment module specifically includes a comparison module, a cache module A and a cache module B: Comparison module: compares the size relationship between the current system event and the sum of the last initialization time and the expiration time; Cache module A: If it is greater than, get the latest token and store it in the cache; Cache module B: If it is less than, get the token from the interface and store it in the cache; The cache module A specifically includes a cache update module and an update record module: Cache update module: call the interface for obtaining token and update the updated token to the cache; Update record module: record and update the current system time to the time point of the latest initialization token.

Citation Information

Patent Citations

  • Network asynchronous request download framework implementation system and method, and computer program

    CN110213336A

  • WeChat applet automatic login method and storage equipment

    CN110362986A