Method for realizing key data desensitization by adding custom annotation in javabean object

By adding custom annotations to Java Bean objects, using Spring MVC and Jackson class libraries, the backend desensitization processing of sensitive data is achieved, solving the problems of low and insecure front-end execution efficiency and efficient and secure data desensitization Sensitive effect.

CN119442295APending Publication Date: 2025-02-14JIANGSU FINSTONE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310981710.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-08-07
Publication Date
2025-02-14

AI Technical Summary

Technical Problem

In the prior art, when the need to desensitize sensitive data in processing WEB systems, the front-end execution is inefficient, unsafe, and cannot fully utilize the computing power of the back-end service.

Method used

By adding custom annotations to Java Bean objects, using Spring MVC and Jackson class libraries to dynamically parse the object's metadata annotations, implementing the backend's desensitization of key data, and returning the desensitized data to the frontend.

Benefits of technology

It realizes safe desensitization of sensitive data without affecting the front-end performance, makes full use of the computing power of back-end services, simplifies the development process and improves development efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119442295A_ABST
    Figure CN119442295A_ABST
Patent Text Reader

Abstract

The invention discloses a method for realizing key data desensitization by adding a custom annotation in a java beam object. The method comprises the following steps: step 1, starting Spring MVC; step 2, calling a Jackson class library; step 3, analyzing object processing information; step 4, binding expansion points of the desensitization method; 5, analyzing whether the annotation exists or not; step 6, formally serializing the desensitization method; step 7, annotation attribute matching processing; 8, generating a character string; and step 9, responding to the front end. According to the scheme, the operational capability of a back-end service layer can be fully utilized, desensitized data are returned to a front end, back-end service dynamically analyzes metadata annotations of related fields of a returned object, the fields needing to be desensitized are analyzed and labeled, and the desensitized data are obtained. According to different desensitization rules, the key data content is converted into desensitization data using placeholders, and on the premise that the safe desensitization requirement is met, the query and response performance is further improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of java bean data desensitization, and in particular to a method for implementing key data desensitization by adding custom annotations in java bean objects. Background Art

[0002] At present, in the data information that the WEB system finally presents to users, it is necessary to partially block the information content such as ID card number, mobile phone number, bank card number, password, address, etc., and only display part of the information. The conventional practice requires the front-end script processing logic to process and judge the key characters one by one. On the one hand, the front-end execution efficiency is low, and the key data needs to be judged one by one. If the data volume is large, it will cause performance problems for the front-end page rendering; secondly, this processing method is unsafe, and users can use technical means to skip the processing of the front-end script and display the complete data content; finally, it is impossible to use the back-end service processing capabilities.

[0003] Through this solution, the computing power of the backend service layer can be fully utilized to return desensitized data to the frontend. The backend service dynamically parses the metadata annotations of the returned object-related fields, parses and annotates the fields that need to be desensitized, and converts key data content into desensitized data using placeholders according to different desensitization rules. Through key technical processing, it supports desensitization of attribute fields of various objects, arrays, and nested objects on the backend, and further improves query and response performance while meeting security desensitization requirements. Summary of the invention

[0004] The purpose of the present invention is to provide a method for desensitizing key data by adding custom annotations in a Java bean object, so as to solve the problems raised in the above background technology.

[0005] To achieve the above object, the present invention provides the following technical solutions:

[0006] According to the method of adding custom annotations to java bean objects to achieve key data desensitization, the following steps are included: Step 1, start Spring MVC; Step 2, call the Jackson class library; Step 3, parse the object processing information; Step 4, bind the desensitization method extension point; Step 5, parse whether there is an annotation; Step 6, formally serialize the desensitization method; Step 7, annotation attribute matching processing; Step 8, generate a string; Step 9, respond to the front end;

[0007] In the above step 1: start using annotations on Spring MVC and define the package information to be scanned;

[0008] In the above step 2: when Spring MVC outputs the response result, the Jackson library is called by default to serialize the result into a json string;

[0009] In the above step 3: by extending Jackson's BeanSerializerModifier extension point, parse and process the returned JavaBean object information;

[0010] In the above step 4: BeanSerializerModifier will bind a specific serialization method according to each attribute of the object;

[0011] In the above step 5: parse whether there is a custom Sensitive desensitization annotation. If so, bind the desensitization serialization interface method SensitiveJsonSerializer of the field. If not, keep the default setting and do not process.

[0012] In the above step 6: Jackson serialization logic will call serialization in sequence according to the bound serialization method of the field;

[0013] In the above step 7: call SensitiveUtils to perform desensitization serialization method logical value matching processing and return the desensitized value corresponding to the field value;

[0014] In the above step 8: the serialization process is completed and a new JSON string is generated;

[0015] In the above step nine: SpringMVC responds to the front end with json.

[0016] Preferably, the data desensitization is performed when the processing result is returned to the front-end application according to the Web development framework SpringMVC RestController and serialized into data in JSON format.

[0017] Preferably, when the SpringMVC Restful outputs a response result, the Jackson class library is called by default to serialize the result into a json string, and the returned JavaBean object information is parsed and processed by extending the BeanSerializerModifier extension point of Jackson.

[0018] Preferably, the BeanSerializerModifier will bind a specific serialization method according to each attribute of the object, traverse all attribute fields of the object, and parse whether there is a custom Sensitive annotation. If so, the desensitized serialization interface method of the binding field is retained. If not, the default setting is maintained.

[0019] Preferably, the Jackson serialization logic will call serialization in sequence according to the bound serialization method of the field, and when encountering a desensitized serialization field, the desensitized serialization method will be called for serialization.

[0020] Preferably, the logic of the desensitization serialization method calls SensitiveUtils to perform character matching processing according to the desensitization type, leading mask length, trailing mask length, mask identifier, and other annotation attributes defined in the field annotation, and returns the desensitized content corresponding to the content, which is directly overwritten as the desensitized value.

[0021] Preferably, when the serialization process is completed, the generated json string will automatically contain the desensitized value corresponding to the annotated field. SpringMVC will respond the json to the front-end caller, and the caller will display the desensitized value of the field at the required position according to the agreed method. The desensitized display is completed, and the front-end caller does not need to perform any further processing.

[0022] Preferably, for the query of large amount of data, the backend will generally perform paging and only return the data of the current page. When SpringMVC outputs the response, it will only process the data of the current page. Based on this, the field desensitization stage is placed between the backend logic return and the SpringMVC response to the front end. The framework automatically performs desensitization processing, which is not noticeable to the developer and simplifies the development, thereby improving the development efficiency.

[0023] Compared with the prior art, the present invention has the following beneficial effects:

[0024] The present invention makes full use of the computing power of the back-end service layer to return the desensitized data to the front end. The back-end service returns the metadata annotations of the relevant fields of the object through dynamic analysis, parses and annotates the fields that need to be desensitized, and converts the key data content into desensitized data using placeholders according to different desensitization rules, so that the front-end script does not need to perform desensitization processing, avoiding the risk of data leakage. The back end does not need to hard-code and write desensitization logic separately, and can be done by adding simple annotations; supports single JavaBean objects, supports collections, supports composite or nested objects, and has no hierarchical restrictions; supports single Map type objects, supports collections, supports composite or nested objects, and has no hierarchical restrictions; supports multiple desensitization types (name, ID number, landline, mobile phone, address, email, bank card, password, key, etc.) by default, supports custom desensitization ranges for additional attributes, is insensitive to development and simplifies development, and improves development efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] Figure 1 This is a schematic diagram of field desensitization sequence binding of the present invention;

[0026] Figure 2 This is a schematic diagram of Jackson's formal serialization of the present invention;

[0027] Figure 3 The present invention is a schematic diagram of obtaining the desensitization return result. DETAILED DESCRIPTION

[0028] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions 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 are within the scope of protection of the present invention.

[0029] In the description of the present invention, it should be noted that the terms "upper", "lower", "inner", "outer", "front end", "rear end", "two ends", "one end", "the other end" and the like indicate positions or positional relationships based on the positions or positional relationships shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance.

[0030] In the description of the present invention, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "provided with", "connected", etc. should be understood in a broad sense. For example, "connected" can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0031] Example 1

[0032] See also Figure 1-3 , the embodiment provided by the present invention: a method for implementing key data desensitization by adding custom annotations in a java bean object, which is divided into the following steps: step 1, starting Spring MVC; step 2, calling the Jackson class library; step 3, parsing object processing information; step 4, binding the desensitization method extension point; step 5, parsing whether there is an annotation; step 6, formally serializing the desensitization method;

[0033] Step 7: annotation attribute matching and processing; Step 8: generating a string; Step 9: responding to the front end;

[0034] In the above step 1: start using annotations on Spring MVC and define the package information to be scanned;

[0035] In the above step 2: when Spring MVC outputs the response result, the Jackson library is called by default to serialize the result into a json string;

[0036] In the above step 3: by extending Jackson's BeanSerializerModifier extension point, parse and process the returned JavaBean object information;

[0037] In the above step 4: BeanSerializerModifier will bind a specific serialization method according to each attribute of the object;

[0038] In the above step 5: parse whether there is a custom Sensitive desensitization annotation. If so, bind the desensitization serialization interface method SensitiveJsonSerializer of the field. If not, keep the default setting and do not process.

[0039] In the above step 6: Jackson serialization logic will call serialization in sequence according to the bound serialization method of the field;

[0040] In the above step 7: call SensitiveUtils to perform desensitization serialization method logical value matching processing and return the desensitized value corresponding to the field value;

[0041] In the above step 8: the serialization process is completed and a new JSON string is generated;

[0042] In the above step nine: SpringMVC responds to the front end with json.

[0043] Example 2

[0044] Data desensitization is performed when the processing results are returned to the front-end application by the Web development framework SpringMVC RestController and serialized into JSON format data. When SpringMVC Restful outputs the response results, the Jackson class library is called by default to serialize the results into json strings. By extending Jackson's BeanSerializerModifier extension point, the returned JavaBean object information is parsed and processed. BeanSerializerModifier will bind a specific serialization method to each attribute of the object, traverse all attribute fields of the object, and parse whether there is a custom Sensitive annotation. If so, the desensitized serialization interface method of the field is bound. If not, the default setting is maintained. The Jackson serialization logic will call the serialization method in sequence according to the bound serialization method of the field. When encountering a desensitized serialization field, the desensitized serialization method will be called for serialization.

[0045] The logic of the desensitization serialization method calls SensitiveUtils for character matching according to the desensitization type defined in the field annotation, the leading mask length, the trailing mask length, the mask identifier, and other annotation attributes. The desensitized content corresponding to the returned content is directly overwritten as the desensitized value. After the serialization process is completed, the generated json string will automatically contain the desensitized value corresponding to the annotated field. SpringMVC responds to the front-end caller with json. The caller displays the desensitized value of the field in the required position according to the agreed method to complete the desensitized display. The front-end caller does not need to process it again. For queries with large amounts of data, the back-end generally performs paging and only returns the data of the current page. When SpringMVC outputs the response, it will only process the data of the current page. Based on this point, the field desensitization stage is placed between the back-end logic return and the SpringMVC response to the front-end. The framework automatically performs desensitization processing, which is insensitive to development and simplifies development, thereby improving development efficiency.

[0046] The matters not described in detail in the present invention are all known technologies to those skilled in the art.

[0047] Finally, it should be noted that the above specific implementation methods are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified and replaced by equivalents without departing from the spirit and scope of the technical solution of the present invention, which should be included in the scope of the claims of the present invention.

Claims

1. According to the method of adding custom annotations to java bean objects to implement key data desensitization, the method is divided into the following steps: step 1, start Spring MVC; step 2, call Jackson class library; step 3, parse object processing information; step 4, desensitization method extension point binding; step 5, parse whether there is an annotation; step 6, formal serialization of the desensitization method; step 7, annotation attribute matching processing; step 8, generate a string; step 9, respond to the front end; it is characterized by: In the above step 1: start using annotations on Spring MVC and define the package information to be scanned; In the above step 2: when Spring MVC outputs the response result, the Jackson library is called by default to serialize the result into a json string; In the above step 3: by extending Jackson's BeanSerializerModifier extension point, parse and process the returned JavaBean object information; In the above step 4: BeanSerializerModifier will bind a specific serialization method according to each attribute of the object; In the above step 5: parse whether there is a custom Sensitive desensitization annotation. If so, bind the desensitization serialization interface method SensitiveJsonSerializer of the field. If not, keep the default setting and do not process. In the above step 6: Jackson serialization logic will call serialization in sequence according to the bound serialization method of the field; In the above step 7: call SensitiveUtils to perform desensitization serialization method logical value matching processing and return the desensitized value corresponding to the field value; In the above step 8: the serialization process is completed and a new JSON string is generated; In the above step nine: SpringMVC responds to the front end with json.

2. The method for desensitizing key data by adding custom annotations in a Java bean object according to claim 1, characterized in that: The data desensitization is performed when the processing result is returned to the front-end application according to the Web development framework SpringMVC RestController and serialized into JSON format data.

3. The method for desensitizing key data by adding custom annotations in a Java bean object according to claim 1, characterized in that: When the SpringMVC Restful outputs the response result, the Jackson class library is called by default to serialize the result into a json string, and the returned JavaBean object information is parsed and processed by extending the BeanSerializerModifier extension point of Jackson.

4. The method for desensitizing key data by adding custom annotations in a Java bean object according to claim 1, characterized in that: The BeanSerializerModifier will bind a specific serialization method to each attribute of the object, traverse all attribute fields of the object, and parse whether there is a custom Sensitive annotation. If so, it will bind the desensitized serialization interface method of the field. If not, it will keep the default setting.

5. The method for desensitizing key data by adding custom annotations in a Java bean object according to claim 1, characterized in that: The Jackson serialization logic will call serialization in sequence according to the bound serialization method of the field. When encountering a desensitized serialization field, the desensitized serialization method will be called for serialization.

6. The method for desensitizing key data by adding custom annotations in a Java bean object according to claim 1, characterized in that: The logic of the desensitization serialization method calls SensitiveUtils to perform character matching processing according to the desensitization type, leading mask length, trailing mask length, mask identifier, and other annotation attributes defined in the field annotation, and returns the desensitized content corresponding to the content, which is directly overwritten as the desensitized value.

7. The method for desensitizing key data by adding custom annotations in a Java bean object according to claim 1, characterized in that: After the serialization process is completed, the generated json string will automatically contain the desensitized value corresponding to the annotated field. SpringMVC will respond the json to the front-end caller. The caller will display the desensitized value of the field at the required position according to the agreed method. The desensitized display is completed and the front-end caller does not need to process it further.

8. The method for desensitizing key data by adding custom annotations in a Java bean object according to claim 1, characterized in that: For queries with large amounts of data, the backend will generally perform paging and only return the data of the current page. When SpringMVC outputs a response, it will only process the data of the current page. Based on this, the field desensitization stage is placed between the backend logic return and the SpringMVC response to the front end. The framework automatically performs desensitization processing, which is imperceptible to development and simplifies development, thereby improving development efficiency.