Attribute verification method, device, electronic device and storage medium
By receiving service requests and calling the verification interface corresponding to the annotation, the properties of the value object are checked, which solves the problem of large number of verification components and poor management in the prior art, and realizes unified management and flexible writing and maintenance of verification components.
Patent Information
- Application Number
- CN202110713732.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-25
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2041-06-25
AI Technical Summary
The large number of verification components in the prior art and the lack of unified and standardized management has led to developers lacking flexibility in writing and maintaining verification components.
By receiving service requests, obtaining the value object and calling the verification interface through its corresponding annotation, the properties of the value object are checked. The verification interface includes a global verification interface, a service verification interface, an attribute verification interface and a service verification interface, which are used for verification at different levels.
It realizes unified management of verification components, improves developers' flexibility when writing and maintaining verification components, and simplifies the verification process.
Smart Images

Figure CN113312675B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular, to an attribute verification method, apparatus, electronic device, and storage medium. Background Art
[0002] Currently, with the development of computer technology, users have higher and higher requirements for the security of data between the front end and the back-end system of applications.
[0003] In related technologies, in order to meet users' requirements for data security, developers usually use some existing verification components. By adding annotations, the verification components can be directly called to implement the verification of fields during verification.
[0004] However, when using the above method for field verification, due to the large variety and quantity of verification components in the prior art and the lack of unified and standardized management, it is not conducive to the subsequent writing and maintenance of verification components by developers, and makes it lack a certain degree of flexibility for developers to use verification components in the subsequent process. Summary of the Invention
[0005] This application provides an attribute verification method, apparatus, electronic device, and storage medium, which are used to solve the problem that the large number of verification components in the prior art makes it inflexible for developers to write and maintain verification components.
[0006] In a first aspect, this application provides an attribute verification method, and the method includes:
[0007] Receiving a service request and obtaining a value object in the service request;
[0008] Obtaining an annotation corresponding to the value object, and verifying the attributes of the value object by calling a verification interface corresponding to the annotation to obtain a verification result returned by the verification interface; wherein, the verification interface includes an implementation class for performing verification.
[0009] In a possible implementation manner, the verification interface includes at least one of the following: a global verification interface, a business verification interface, an attribute verification interface, and a service verification interface;
[0010] Wherein, the global verification interface includes an implementation class of global verification rules, and the global verification rules are used to verify the common characteristics of value objects of all fields in the service request;
[0011] The business verification interface includes implementation classes of business verification rules corresponding to multiple business types, and the business verification rules are used to verify the business characteristics of value objects of all fields in the service request corresponding to the corresponding transaction type;
[0012] The attribute verification interface includes implementation classes corresponding to field verification rules for various fields, and the field verification rules are used to verify the value objects of the corresponding fields in the service request;
[0013] The service verification interface includes implementation classes for pre-edited defined verification rules. The defined verification rules include common rules and private rules. Among them, the common rules are obtained by extracting from multiple established verification rules, and the private rules are user-defined rules.
[0014] In a possible implementation manner, verifying the attributes of the value object by calling the verification interface corresponding to the annotation includes:
[0015] Determine the interface to be called, and the verification rules corresponding to the annotation are included under the interface to be called;
[0016] For the interface to be called, obtain the configuration parameters of the current interface to be called from the configuration file;
[0017] If the configuration parameter of the interface to be called is the first value, determine that the interface to be called is in an available state; if the configuration parameter of the interface to be called is the second value, determine that the interface to be called is in an unavailable state;
[0018] If the interface to be called is in an available state, call the verification interface corresponding to the annotation to verify the attributes of the value object.
[0019] In a possible implementation manner, the number of interfaces to be called is multiple; verifying the attributes of the value object by calling the verification interface corresponding to the annotation includes:
[0020] Based on the priorities of the pre-configured verification interfaces, call the interfaces to be called in sequence to verify the attributes of the value object.
[0021] In a possible implementation manner, the service request includes a business request; the method further includes:
[0022] If the verification result returned by the verification interface is verification success, obtain the business response returned by the business execution interface by calling the business execution interface corresponding to the business request, where the business execution interface includes an implementation class for performing business processing.
[0023] In a second aspect, the present application provides an attribute verification device, and the device includes:
[0024] A receiving unit, configured to receive a service request and obtain a value object in the service request;
[0025] An acquisition unit is used to acquire the annotation corresponding to the value object, and by calling the verification interface corresponding to the annotation, verify the attributes of the value object to obtain the verification result returned by the verification interface; wherein, the verification interface includes an implementation class for performing verification.
[0026] In a possible implementation manner, the verification interface includes at least one of the following: a global verification interface, a business verification interface, an attribute verification interface, and a service verification interface;
[0027] Among them, the global verification interface includes an implementation class of global verification rules, and the global verification rules are used to verify the common characteristics of the value objects of all fields in the service request;
[0028] The business verification interface includes implementation classes of business verification rules corresponding to multiple business types, and the business verification rules are used to verify the business characteristics of the value objects of all fields in the service request corresponding to the corresponding transaction type;
[0029] The attribute verification interface includes implementation classes of field verification rules corresponding to multiple fields, and the field verification rules are used to verify the value objects of the corresponding fields in the service request;
[0030] The service verification interface includes an implementation class of pre-edited defined verification rules, and the defined verification rules include public rules and private rules. Among them, the public rules are obtained by extracting from multiple established verification rules, and the private rules are user-defined rules.
[0031] In a possible implementation manner, the acquisition unit includes:
[0032] A first determination module is used to determine the interface to be called, and the interface to be called includes the verification rules corresponding to the annotation;
[0033] A call module is used to obtain the configuration parameters of the currently to-be-called interface from the configuration file for the to-be-called interface;
[0034] A second determination module is used to determine that the to-be-called interface is in an available state if the configuration parameter of the to-be-called interface is a first value; and determine that the to-be-called interface is in an unavailable state if the configuration parameter of the to-be-called interface is a second value;
[0035] A verification module is used to call the verification interface corresponding to the annotation to verify the attributes of the value object if the to-be-called interface is in an available state.
[0036] In a possible implementation manner, the number of to-be-called interfaces is multiple; the acquisition unit is further specifically used for:
[0037] Call the to-be-called interface in sequence based on the priorities of the pre-configured verification interfaces to verify the attributes of the value object.
[0038] In a possible implementation manner, the service request includes a service request; the device further includes:
[0039] A response unit, configured to, if the verification result returned by the verification interface is verification success, obtain a service response returned by the service execution interface corresponding to the service request by calling the service execution interface, where the service execution interface includes an implementation class for performing service processing.
[0040] In a third aspect, the present application provides an electronic device, including: a memory, a processor;
[0041] A memory; a memory for storing executable instructions of the processor;
[0042] Wherein, the processor is configured to execute the method according to any one of the first aspect based on the executable instructions.
[0043] In a fourth aspect, the present application provides a computer-readable storage medium, in which computer-executable instructions are stored, and when the computer-executable instructions are executed by a processor, they are used to implement the method according to any one of the first aspect.
[0044] In a fifth aspect, the present application provides a computer program product, where the computer program product includes a computer program, and when the computer program is executed by a processor, it implements the method according to any one of the first aspect.
[0045] The present application provides an attribute verification method, device, electronic device, and storage medium. By receiving a service request, obtaining a value object in the service request; and based on the annotation corresponding to the obtained value object, calling the verification interface corresponding to the annotation to verify the attributes of the value object, and obtaining a verification result returned by the verification interface; where the verification interface includes an implementation class for performing verification. In the present application, by encapsulating the implementation class for performing verification in an interface, during subsequent verification, the attribute verification of the value object can be implemented by calling the relevant verification interface. Furthermore, the management of the implementation class available for performing verification is realized through the verification interface, so that subsequent developers can write and maintain the verification implementation class. Description of the Drawings
[0046] The drawings here are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present application, and are used together with the specification to explain the principles of the present application.
[0047] Figure 1 A schematic diagram of an application scenario provided for this application;
[0048] Figure 2 A schematic flowchart of an attribute verification method provided for an embodiment of this application;
[0049] Figure 3 A schematic flowchart of a method for invoking an attribute verification interface provided for an embodiment of this application;
[0050] Figure 4 A schematic structural diagram of an attribute verification device provided for an embodiment of this application;
[0051] Figure 5 Another schematic structural diagram of an attribute verification device provided for an embodiment of this application;
[0052] Figure 6 A schematic structural diagram of an electronic device provided for an embodiment of this application.
[0053] Through the above-mentioned drawings, specific embodiments of this application have been shown, and there will be more detailed descriptions hereinafter. These drawings and textual descriptions are not intended to limit the scope of the concept of this application in any way, but to illustrate the concept of this application to those skilled in the art by referring to specific embodiments. Specific Embodiments
[0054] Here, the exemplary embodiments will be described in detail, and the examples are shown in the drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. On the contrary, they are merely examples of devices and methods consistent with some aspects of this application as detailed in the appended claims.
[0055] Currently, with the continuous development of computer technology, users and system developers have higher and higher requirements for the security of the system and data. Generally, when the application front-end and the background system call each other, it is necessary to verify the security of the data input from the front-end to prevent some non-compliant data from being input into the background system, thereby causing failures and security problems in the operation of the background system. In addition, when performing data security verification, since the data transmitted from the front-end to the background system is easily intercepted, maliciously tampered with, forged, etc., it is also necessary to verify it when the data is transmitted to the background system to prevent abnormalities in the background system. For example, as Figure 1 shown Figure 1A schematic diagram of an application scenario provided for this application. In the figure, the front end and the back end can communicate with each other. When the front end sends information, it is easily intercepted by a third-party system, and the transmitted data is tampered with, resulting in a failure when the back end receives the tampered transmitted data.
[0056] Currently, when performing attribute verification on the fields transmitted between the front end and the back end, corresponding annotations are usually added in the function code for implementing the service, and then the relevant verification components are called through the added annotations to implement the attribute verification of the relevant fields.
[0057] However, when performing field verification using the above method, due to the large variety and quantity of verification components in the prior art, and the lack of unified standardized management of verification components, it takes a long time for developers to obtain verification components subsequently. Moreover, due to the differences in the verification functions implemented by each component, it lacks flexibility for subsequent developers to maintain.
[0058] The attribute verification method, device, electronic device, and storage medium provided by this application aim to solve the above technical problems in the prior art.
[0059] The technical solution of this application and how the technical solution of this application solves the above technical problems will be described in detail below with specific embodiments. These several specific embodiments below can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of this application will be described below with reference to the accompanying drawings.
[0060] Figure 2 A flowchart of an attribute verification method provided for an embodiment of this application, the method includes the following steps:
[0061] S101. Receive a service request and obtain a value object in the service request.
[0062] Exemplarily, the attribute verification method provided in this embodiment can be applied to the background system of the application so that the background system can implement attribute verification on the value object in the received request. When receiving a service request, obtain one or more value objects in the service request.
[0063] In one example, the service request received by the background system can be the received service request information. For example, it can be a query request for user account information, etc.
[0064] In one example, the received service request can be a verification request.
[0065] S102. Obtain the annotation corresponding to the value object, and by calling the verification interface corresponding to the annotation, verify the attributes of the value object to obtain the verification result returned by the verification interface; wherein, the verification interface includes an implementation class for performing verification.
[0066] Exemplarily, after determining the value object in the service request, obtain the annotation corresponding to the value object in the service request, and then, based on the implementation class for performing verification under the verification interface corresponding to the annotation, verify the attributes of the obtained value object. For example, the length of the field, the type of field symbol, etc. can be verified. Then, the verification interface returns the verification result for the field attributes.
[0067] For example, when a user enters their username and password for a login operation on the front end, after the background system receives the request, it will verify whether the username conforms to the preset field attributes (for example, the username needs to be in Chinese character format or an 11-digit mobile phone number, etc.), and then verify the user's password (for example, whether it contains both numbers and letters, etc.). Then, if the obtained field information does not meet the preset field attributes, the verification result can be returned to the front end, such as information indicating that the password is incorrect. In one example, when the field attribute verification result passes, it is possible to continue to confirm whether the user's username has been registered and whether the username and password correspond to implement the user's login operation.
[0068] In this embodiment, by encapsulating the implementation class for performing verification in the verification interface, the verification method realizes unified management. This enables subsequent effective management of the implementation class for performing verification through the interface, facilitating the writing and maintenance of verification components by subsequent developers.
[0069] In the actual verification process, the verification interface includes at least one of the following: global verification interface, business verification interface, attribute verification interface, and service verification interface.
[0070] Among them, the global verification interface includes an implementation class for global verification rules, and the global verification rules are used to verify the common characteristics of the value objects of all fields in the service request. For example, in a certain system, if the background system requires that the field attributes of all fields in the received service request are non-empty fields, then at this time, the characteristic of non-empty fields can be used as the common characteristic of the value object.
[0071] The business verification interface includes implementation classes for business verification rules corresponding to various business types, and the business verification rules are used to verify the business characteristics of the value objects of all fields in the service request corresponding to the corresponding transaction type.
[0072] Exemplarily, the verification rules in the service verification interface are the verification rules for each service. For example, the services can include the service of a user performing a balance query, the service of a user making a transfer, etc. When a user performs a balance query service, it is required that the user name and password are in a specified format. For example, the user name cannot contain special characters, and the user password is 6 digits. When a user performs a transfer service, it is required that the transfer amount entered by the user is a number and the currency is RMB, etc. When a user performs foreign currency exchange, the currency is not limited to the only type of currency, i.e., RMB. That is, each service corresponds to its own verification rules.
[0073] The attribute verification interface includes implementation classes corresponding to field verification rules for multiple fields. The field verification rules are used to verify the value objects of the corresponding fields in the service request. Under this attribute verification interface, corresponding verification rules can be set for each field.
[0074] The service verification interface includes implementation classes that pre-edit the defined verification rules. The defined verification rules include public rules and private rules. Among them, the public rules are extracted from multiple established verification rules, and the private rules are rules defined by users.
[0075] Exemplarily, in the service verification interface, users can customize verification classes for some field attribute rules. Among them, when defining verification rules, some existing implementation classes of verification rules can be used to achieve customization. For example, the common parts of multiple existing verification rules can be directly extracted, and then the user-defined custom rules can be added to complete the writing of the rules. Optionally, the operation of adding or modifying verification rules can also be directly performed in the code of the existing verification component.
[0076] In this embodiment, the verification interface can be divided into different types of interfaces according to the above division rules. Then, in the subsequent process of execution and invocation, the corresponding verification interface can be selected according to the verification requirements to implement verification.
[0077] In the actual verification process, by calling the verification interface corresponding to the annotation, the attributes of the value object are verified, and the verification result returned by the verification interface is obtained. That is, when performing step S102, as Figure 3 shown, Figure 3 is a schematic flow chart of a method for calling an attribute verification interface provided by an embodiment of the present application. The method can specifically include the following steps:
[0078] S201. Determine the interface to be called. The interface to be called includes the verification rules corresponding to the annotation;
[0079] S202. For the interface to be called, obtain the configuration parameters of the currently to-be-called interface from the configuration file;
[0080] S203. If the configuration parameter of the interface to be called is the first value, determine that the interface to be called is in an available state;
[0081] S204. If the configuration parameter of the interface to be called is the second value, determine that the interface to be called is in an unavailable state;
[0082] S205. If the interface to be called is in an available state, call the verification interface corresponding to the annotation to verify the attributes of the value object, and obtain the verification result returned by the verification interface.
[0083] Exemplarily, in this embodiment, each verification interface is set with its own configuration parameter. By setting the configuration parameter of the verification interface, it can be used to implement the setting of the interface state. Among them, the state of the interface is divided into an available state and an unavailable state. After determining the interface to be called according to the annotation of the value object, it is necessary to find the configuration parameters of each interface to be called in the configuration file of the verification interface. If the configuration parameter of the interface to be called is the first value, then at this time the call interface is in an available state, and then the field verification can be performed through this interface to be called, and the execution result is returned. If the interface to be called is in an unavailable state, no verification is performed.
[0084] In one example, when determining the interface to be called, the verification interface corresponding to the annotation of the value object can be determined according to the mapping relationship established in advance between the annotation of the value object, the verification interface, and the implementation class in the verification interface.
[0085] In one example, the above service request includes a business request; then based on this embodiment, the method further includes:
[0086] If the verification result returned by the verification interface is verification success, then by calling the business execution interface corresponding to the business request, obtain the business response returned by the business execution interface, where the business execution interface includes an implementation class for performing business processing.
[0087] Exemplarily, if the current service request is a business request, then after performing the attribute verification of the value object, if the attribute verification of the value object is successful, the implementation class that can be used for business processing in the corresponding business execution interface in the business request can be directly called, thereby completing the business response of the business request. For example, in the above user login scenario, after performing the attribute verification on the value objects corresponding to the username and password of the user, the user login verification operation can be directly performed, thereby completing the user login request.
[0088] In this embodiment, the configuration file of the verification interface includes configuration parameters of each verification interface, where each configuration parameter can be used to control the status of the verification interface as available and unavailable. When the interface to be called is confirmed, it is necessary to determine whether the interface to be called is in an available state. When it is in an available state, the interface can be directly called to implement verification. In addition, after verification, if the currently received request is a service request, the service request can be continuously responded to.
[0089] In some embodiments, when the number of interfaces to be called is determined to be multiple, the verification interface corresponding to the annotation can be called to verify the attributes of the value object, including: sequentially calling the interfaces to be called based on the priorities of each pre-configured verification interface to verify the attributes of the value object.
[0090] Exemplarily, during the verification process, if it is confirmed that there are multiple interfaces to be called corresponding to the value object, at this time, the value object can be verified according to the preset priorities of the interfaces to be called. For example, when designing the priorities of the interfaces, the priorities of the interfaces can be set as global verification interfaces, service verification interfaces, attribute verification interfaces, and service verification interfaces. When the above four call interfaces are all interfaces to be called, global field verification can be performed first, and then after passing the verification of the current interface to be called according to the priority, the next interface can be called. Through the above method, hierarchical verification of the value object can be realized, and the verification efficiency can be improved.
[0091] Specifically, in some embodiments, the above two embodiments can be combined and implemented, that is, during verification, first, the interface status is confirmed according to the configuration file of the interface to be called, and then, according to the preset priority order of the verification interfaces, verification interfaces are sequentially selected from the available interfaces to be called to implement verification.
[0092] In this embodiment, during attribute verification, the status of the interface to be called can be first judged, and then, according to the priority of the call interface, attribute verification is sequentially performed in the available interfaces to determine whether the value object in the service request meets the verification rules, thereby improving the verification speed.
[0093] Figure 4 The following is a schematic structural diagram of an attribute verification device provided by an embodiment of the present application, as Figure 4 shown, the attribute verification device includes:
[0094] A receiving unit 41, configured to receive a service request and obtain a value object in the service request;
[0095] An acquisition unit 42 is configured to acquire the annotation corresponding to the value object, and perform verification on the attributes of the value object by calling the verification interface corresponding to the annotation, so as to obtain the verification result returned by the verification interface; wherein, the verification interface includes an implementation class for performing verification.
[0096] The device provided in this embodiment is used to implement the technical solution provided by the above method, and its implementation principle and technical effect are similar, which will not be elaborated here.
[0097] Figure 5 FIG. is a schematic structural diagram of another attribute verification device provided by an embodiment of the present application. As Figure 5 shown, based on the device structure shown above Figure 4 in the present embodiment, the verification interface includes at least one of the following: a global verification interface, a service verification interface, an attribute verification interface, and a service verification interface;
[0098] Among them, the global verification interface includes an implementation class of the global verification rule, and the global verification rule is used to verify the common characteristics of the value objects of all fields in the service request;
[0099] The service verification interface includes implementation classes of service verification rules corresponding to multiple service types, and the service verification rules are used to verify the service characteristics of the value objects of all fields in the service request corresponding to the corresponding transaction type;
[0100] The attribute verification interface includes implementation classes of field verification rules corresponding to multiple fields, and the field verification rules are used to verify the value objects of the corresponding fields in the service request;
[0101] The service verification interface includes implementation classes of pre-edited definition verification rules, and the definition verification rules include public rules and private rules. Among them, the public rules are obtained by extracting from multiple established verification rules, and the private rules are user-defined rules.
[0102] In some embodiments, the acquisition unit 42 includes:
[0103] A first determination module 421 is configured to determine the interface to be called, and the interface to be called includes the verification rule corresponding to the annotation;
[0104] A call module 422 is configured to obtain the configuration parameters of the currently to-be-called interface from the configuration file for the to-be-called interface;
[0105] A second determination module 423 is configured to determine that the interface to be called is in an available state if the configuration parameter of the interface to be called is the first value; and determine that the interface to be called is in an unavailable state if the configuration parameter of the interface to be called is the second value;
[0106] A verification module 424, configured to, if the interface to be called is in an available state, call the verification interface corresponding to the annotation to verify the attributes of the value object.
[0107] In some embodiments, when the number of interfaces to be called is multiple; the obtaining unit 42 is further specifically configured to:
[0108] Based on the priorities of the pre-configured verification interfaces, call the interfaces to be called in sequence to verify the attributes of the value object.
[0109] In some embodiments, the service request includes a business request; the apparatus further includes:
[0110] A response unit 43, configured to, if the verification result returned by the verification interface is verification success, obtain a service response returned by the service execution interface by calling the service execution interface corresponding to the business request, where the service execution interface includes an implementation class for performing service processing.
[0111] The apparatus provided in this embodiment is used to implement the technical solution provided by the above method, and its implementation principle and technical effects are similar, and will not be elaborated here.
[0112] Figure 6 It is a schematic structural diagram of an electronic device provided in an embodiment of the present application, as Figure 6 shown, the electronic device includes:
[0113] A processor 291, the electronic device further includes a memory 292; it may further include a communication interface 293 and a bus 294. Among them, the processor 291, the memory 292, and the communication interface 293 can complete mutual communication through the bus 294. The communication interface 293 can be used for information transmission. The processor 291 can call the logic instructions in the memory 294 to execute the method in the above embodiment.
[0114] In addition, when the above logic instructions in the memory 292 are implemented in the form of a software functional unit and sold or used as an independent product, they can be stored in a computer-readable storage medium.
[0115] The memory 292, as a computer-readable storage medium, can be used to store software programs and computer-executable programs, such as the program instructions / modules corresponding to the method in the embodiment of the present application. The processor 291 executes functional applications and data processing by running the software programs, instructions, and modules stored in the memory 292, that is, implements the method in the above method embodiment.
[0116] The memory 292 may include a program storage area and a data storage area. The program storage area may store an operating system and application programs required for at least one function. The data storage area may store data created according to the use of the terminal device, etc. In addition, the memory 292 may include a high-speed random access memory and may also include a non-volatile memory.
[0117] This application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the method according to any one of the first aspects.
[0118] This application provides a computer program product. The computer program product includes a computer program, and when the computer program is executed by a processor, it implements the method according to any one of the first aspects.
[0119] Those skilled in the art will readily conceive of other embodiments of this application after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application, which follow the general principles of this application and include known common knowledge or conventional technical means in the technical field not disclosed in this application. The specification and examples are only regarded as exemplary, and the true scope and spirit of this application are pointed out by the appended claims.
[0120] It should be understood that this application is not limited to the exact structures described above and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is only limited by the appended claims.
Claims
1. An attribute verification method, characterized in that, the method includes: Receiving a service request and obtaining a value object in the service request; Obtaining the annotation corresponding to the value object, and determining the verification interface corresponding to the annotation of the value object according to the mapping relationship between the preset value object annotation, verification interface, and implementation class in the verification interface; Verifying the attributes of the value object by calling the verification interface corresponding to the annotation, and obtaining the verification result returned by the verification interface; wherein, the verification interface includes an implementation class for performing verification; The step of verifying the attributes of the value object by calling the verification interface corresponding to the annotation includes: Determining the interface to be called, and the verification rules corresponding to the annotation are included under the interface to be called; For the interface to be called, obtaining the configuration parameters of the current interface to be called from the configuration file; If the configuration parameter of the interface to be called is the first value, determining that the interface to be called is in an available state; if the configuration parameter of the interface to be called is the second value, determining that the interface to be called is in an unavailable state; If the interface to be called is in an available state, calling the verification interface corresponding to the annotation to verify the attributes of the value object; The number of the interfaces to be called is multiple; the step of verifying the attributes of the value object by calling the verification interface corresponding to the annotation includes: Based on the priorities of the pre-configured verification interfaces, sequentially calling the interfaces to be called to verify the attributes of the value object.
2. The method according to claim 1, characterized in that, The verification interface includes at least one of the following: global verification interface, business verification interface, attribute verification interface, and service verification interface; Among them, the global verification interface includes an implementation class of global verification rules, and the global verification rules are used to verify the common characteristics of value objects of all fields in the service request; The business verification interface includes implementation classes of business verification rules corresponding to multiple business types, and the business verification rules are used to verify the business characteristics of value objects of all fields in the service request corresponding to the corresponding transaction type; The attribute verification interface includes implementation classes of field verification rules corresponding to multiple fields, and the field verification rules are used to verify the value objects of the corresponding fields in the service request; The service verification interface includes an implementation class of pre-edited definition verification rules, and the definition verification rules include public rules and private rules, wherein the public rules are extracted from multiple established verification rules, and the private rules are user-defined rules.
3. The method according to claim 1 or 2, characterized in that, The service request includes a business request; the method further includes: If the verification result returned by the verification interface is verification success, obtaining the business response returned by the business execution interface by calling the business execution interface corresponding to the business request, wherein the business execution interface includes an implementation class for performing business processing.
4. An attribute verification device, characterized in that, the device includes: A receiving unit, configured to receive a service request and obtain a value object in the service request; An obtaining unit, configured to obtain an annotation corresponding to the value object, and determine a verification interface corresponding to the annotation of the value object according to a mapping relationship between a preset value object annotation, a verification interface, and an implementation class in the verification interface; verify attributes of the value object by calling the verification interface corresponding to the annotation, and obtain a verification result returned by the verification interface; wherein, the verification interface includes an implementation class for performing verification; The obtaining unit includes: A first determination module, configured to determine an interface to be called, where the interface to be called includes a verification rule corresponding to the annotation; A calling module, configured to obtain configuration parameters of the currently called interface from a configuration file for the interface to be called; A second determination module, configured to determine that the interface to be called is in an available state if the configuration parameter of the interface to be called is a first value; and determine that the interface to be called is in an unavailable state if the configuration parameter of the interface to be called is a second value; A verification module, configured to call the verification interface corresponding to the annotation to verify attributes of the value object if the interface to be called is in an available state; The number of interfaces to be called is multiple; the obtaining unit is further specifically configured to sequentially call the interfaces to be called based on priorities of each verification interface configured in advance to verify attributes of the value object.
5. The apparatus according to claim 4, wherein, the verification interface includes at least one of the following: a global verification interface, a service verification interface, an attribute verification interface, and a service verification interface; wherein, the global verification interface includes an implementation class of a global verification rule, and the global verification rule is used to verify common characteristics of value objects of all fields in the service request; the service verification interface includes implementation classes of service verification rules corresponding to multiple service types, and the service verification rules are used to verify service characteristics of value objects of all fields in a service request corresponding to a corresponding transaction type; the attribute verification interface includes implementation classes of field verification rules corresponding to multiple fields, and the field verification rules are used to verify value objects of corresponding fields in the service request; the service verification interface includes an implementation class of a defined verification rule pre-edited, and the defined verification rule includes a public rule and a private rule, wherein the public rule is obtained by extracting from multiple established verification rules, and the private rule is a rule defined by a user.
6. The apparatus according to claim 4 or 5, wherein, the service request includes a service request; the apparatus further includes: A response unit, configured to, if the verification result returned by the verification interface is verification success, obtain a service response returned by the service execution interface corresponding to the service request by calling the service execution interface, where the service execution interface includes an implementation class for performing service processing.
7. An electronic device, wherein, includes: a memory, a processor; a memory; a memory for storing executable instructions of the processor; Wherein, the processor is configured to execute the method according to any one of claims 1-3 based on the executable instructions.
8. A computer-readable storage medium, characterized in that, computer-executable instructions are stored in the computer-readable storage medium, and when the computer-executable instructions are executed by a processor, they are configured to implement the method according to any one of claims 1-3.
9. A computer program product, characterized in that, the computer program product includes a computer program, and when the computer program is executed by a processor, it implements the method according to any one of claims 1-3.
Citation Information
Patent Citations
Method and device for verifying interface packet
CN109510824A
Security verification method, device, equipment and medium
CN112788017A