diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..549e00a2a96fa9d7c5dbc9859664a78d980158c2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/pom.xml b/pom.xml index fb260bb2012992633b46b9b94632fe7e718d0e5e..052ceacdc3e89c951b1d418aeea63b4dd458bc89 100644 --- a/pom.xml +++ b/pom.xml @@ -3,175 +3,64 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 io.gitee.chemors - secure-ext-spring-boot-starter + secure-ext-spring-boot 1.0.3-RELEASE - secure-ext-spring-boot-starter - secure-ext-spring-boot-starter - https://gitee.com/chemors/secure-ext-spring-boot-starter - + secure-ext-spring-boot + secure-ext-spring-boot + pom 1.8 2.7.3 5.8.5 1.18.24 + + + + org.springframework.boot + spring-boot-starter + ${springboot.version} + + + org.springframework.boot + spring-boot-starter-web + ${springboot.version} + + + org.springframework.boot + spring-boot-configuration-processor + ${springboot.version} + + + org.springframework.boot + spring-boot-starter-aop + ${springboot.version} + - - - org.springframework.boot - spring-boot-starter - ${springboot.version} - - - - org.springframework.boot - spring-boot-configuration-processor - ${springboot.version} - compile - - - - org.springframework.boot - spring-boot-starter-aop - ${springboot.version} - compile - - - - org.springframework.boot - spring-boot-starter-test - ${springboot.version} - test - - - cn.hutool - hutool-all - ${hutool-all.version} - compile - - - org.projectlombok - lombok - ${lombok.version} - compile - - - + + org.springframework.boot + spring-boot-starter-test + ${springboot.version} + test + + + cn.hutool + hutool-all + ${hutool-all.version} + + + org.projectlombok + lombok + ${lombok.version} + + + + + secure-ext-spring-boot-starter + secure-ext-sensitive-demo + - - ${project.artifactId} - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.8 - 1.8 - - - - - org.apache.maven.plugins - maven-source-plugin - 2.1 - - true - - - - compile - - jar - - - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.1 - - private - true - UTF-8 - UTF-8 - UTF-8 - - - - package - - jar - - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 1.5 - - - sign-artifacts - verify - - sign - - - - - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.8 - true - - oss - https://s01.oss.sonatype.org/ - true - - - - - - - oss - https://oss.sonatype.org/content/repositories/snapshots/ - - - oss - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - - - - - - The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - - - - - scm:git:git@gitee.com:chemors/secure-ext-spring-boot-starter.git - scm:git:git@gitee.com:chemors/secure-ext-spring-boot-starter.git - git@gitee.com:chemors/secure-ext-spring-boot-starter.git - - - - - xiaochenge - grq100296@163.com - https://gitee.com/chemors/secure-ext-spring-boot-starter - +8 - - diff --git a/secure-ext-sensitive-demo/pom.xml b/secure-ext-sensitive-demo/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..bccbb4a9142f8811916a6688dd1c83dbf6de9886 --- /dev/null +++ b/secure-ext-sensitive-demo/pom.xml @@ -0,0 +1,33 @@ + + + secure-ext-spring-boot + io.gitee.chemors + 1.0.3-RELEASE + + 4.0.0 + + secure-ext-sensitive-demo + jar + + secure-ext-sensitive-demo + https://gitee.com/chemors/secure-ext-spring-boot-starter + + + UTF-8 + + + + + org.springframework.boot + spring-boot-starter-web + + + + io.gitee.chemors + secure-ext-spring-boot-starter + ${project.version} + + + + diff --git a/secure-ext-sensitive-demo/src/main/java/com/chemors/Page.java b/secure-ext-sensitive-demo/src/main/java/com/chemors/Page.java new file mode 100644 index 0000000000000000000000000000000000000000..f66e8d38af396da4af94e6d131186e1881660c5d --- /dev/null +++ b/secure-ext-sensitive-demo/src/main/java/com/chemors/Page.java @@ -0,0 +1,16 @@ +package com.chemors; + + +import lombok.Data; + +import java.util.List; + +@Data +public class Page { + + private int current; + + private int size; + + private List records; +} diff --git a/secure-ext-sensitive-demo/src/main/java/io/gitee/chemors/secure/ext/sensitive/demo/App.java b/secure-ext-sensitive-demo/src/main/java/io/gitee/chemors/secure/ext/sensitive/demo/App.java new file mode 100644 index 0000000000000000000000000000000000000000..92c4683428bc28b8dcffe9ed93a2c8d258ffa66f --- /dev/null +++ b/secure-ext-sensitive-demo/src/main/java/io/gitee/chemors/secure/ext/sensitive/demo/App.java @@ -0,0 +1,15 @@ +package io.gitee.chemors.secure.ext.sensitive.demo; + + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class App +{ + public static void main( String[] args ) + { + SpringApplication.run(App.class, args); + } + +} diff --git a/secure-ext-sensitive-demo/src/main/java/io/gitee/chemors/secure/ext/sensitive/demo/SensitiveController.java b/secure-ext-sensitive-demo/src/main/java/io/gitee/chemors/secure/ext/sensitive/demo/SensitiveController.java new file mode 100644 index 0000000000000000000000000000000000000000..d00ca17c8e6388782ff1f9589c92a1dac3c408b3 --- /dev/null +++ b/secure-ext-sensitive-demo/src/main/java/io/gitee/chemors/secure/ext/sensitive/demo/SensitiveController.java @@ -0,0 +1,42 @@ +package io.gitee.chemors.secure.ext.sensitive.demo; + +import cn.hutool.json.JSONUtil; +import com.chemors.Page; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 敏感控制器 + * + * @author 小尘哥 + * @date 2022/08/22 + */ +@RestController +@RequestMapping("sensitive") +public class SensitiveController { + + @Resource + private SensitiveService sensitiveService; + + @GetMapping("simple") + public String simpleData() { + SensitiveEntity sensitiveEntity = sensitiveService.simpleData(); + return JSONUtil.toJsonStr(sensitiveEntity); + } + + @GetMapping("list") + public String listData() { + List sensitiveEntities = sensitiveService.listData(); + return JSONUtil.toJsonStr(sensitiveEntities); + } + + @GetMapping("page") + public String page() { + Page page = sensitiveService.page(); + return JSONUtil.toJsonStr(page); + } +} diff --git a/src/test/java/com/mos/secure/ext/demo/SensitiveEntity.java b/secure-ext-sensitive-demo/src/main/java/io/gitee/chemors/secure/ext/sensitive/demo/SensitiveEntity.java similarity index 73% rename from src/test/java/com/mos/secure/ext/demo/SensitiveEntity.java rename to secure-ext-sensitive-demo/src/main/java/io/gitee/chemors/secure/ext/sensitive/demo/SensitiveEntity.java index c08831e1e42991e3d9ea15313b26ad82cd9e3d92..5f4a858ef012865b63ae583db4bc99cbbb7ff5c7 100644 --- a/src/test/java/com/mos/secure/ext/demo/SensitiveEntity.java +++ b/secure-ext-sensitive-demo/src/main/java/io/gitee/chemors/secure/ext/sensitive/demo/SensitiveEntity.java @@ -1,8 +1,8 @@ -package com.mos.secure.ext.demo; +package io.gitee.chemors.secure.ext.sensitive.demo; -import com.mos.secure.ext.enums.SensitiveTypeEnum; -import com.mos.secure.ext.annotations.DesensitizationProp; +import io.gitee.chemors.secure.ext.annotations.DesensitizationProp; +import io.gitee.chemors.secure.ext.enums.SensitiveTypeEnum; import lombok.Data; import java.util.List; diff --git a/secure-ext-sensitive-demo/src/main/java/io/gitee/chemors/secure/ext/sensitive/demo/SensitiveGrandSonEntity.java b/secure-ext-sensitive-demo/src/main/java/io/gitee/chemors/secure/ext/sensitive/demo/SensitiveGrandSonEntity.java new file mode 100644 index 0000000000000000000000000000000000000000..192cda49446c50afe7b430b75077e14910157f15 --- /dev/null +++ b/secure-ext-sensitive-demo/src/main/java/io/gitee/chemors/secure/ext/sensitive/demo/SensitiveGrandSonEntity.java @@ -0,0 +1,12 @@ +package io.gitee.chemors.secure.ext.sensitive.demo; + +import io.gitee.chemors.secure.ext.annotations.DesensitizationProp; +import io.gitee.chemors.secure.ext.enums.SensitiveTypeEnum; +import lombok.Data; + +@Data +public class SensitiveGrandSonEntity { + + @DesensitizationProp(value = SensitiveTypeEnum.EMAIL) + private String email; +} diff --git a/secure-ext-sensitive-demo/src/main/java/io/gitee/chemors/secure/ext/sensitive/demo/SensitiveService.java b/secure-ext-sensitive-demo/src/main/java/io/gitee/chemors/secure/ext/sensitive/demo/SensitiveService.java new file mode 100644 index 0000000000000000000000000000000000000000..dd4b47c6a702069282068e28816613a5d405e76f --- /dev/null +++ b/secure-ext-sensitive-demo/src/main/java/io/gitee/chemors/secure/ext/sensitive/demo/SensitiveService.java @@ -0,0 +1,62 @@ +package io.gitee.chemors.secure.ext.sensitive.demo; + +import com.chemors.Page; +import io.gitee.chemors.secure.ext.annotations.Desensitization; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +@Service +@Slf4j +public class SensitiveService { + @Desensitization + public SensitiveEntity simpleData() { + SensitiveEntity sensitiveEntity = createEntity("1", "樱木花道", "15699996666", "101010200001010001"); + return sensitiveEntity; + } + + @Desensitization + public List listData() { + System.out.println("执行业务处理..."); + List list = new ArrayList(); + for (int i = 0; i < 5; i++) { + SensitiveEntity sensitiveEntity = createEntity("1" + i, "樱木花道" + i, "15699996666" + i, "10101020000101000" + i); + list.add(sensitiveEntity); + } + return list; + } + + @Desensitization + public Page page() { + Page page = new Page(); + page.setCurrent(1); + page.setSize(10); + page.setRecords(listData()); + return page; + } + + private static SensitiveEntity createEntity(String i, String i1, String i2, String i3) { + SensitiveEntity sensitiveEntity = new SensitiveEntity(); + sensitiveEntity.setId(i); + sensitiveEntity.setName(i1); + sensitiveEntity.setMobile(i2); + sensitiveEntity.setIdCard(i3); + List subEntities = new ArrayList(); + for (int j=0;j<3;j++){ + SensitiveSubEntity sensitiveSubEntity = new SensitiveSubEntity(); + sensitiveSubEntity.setAddress("addr--->"+j); + + SensitiveGrandSonEntity grandSonEntity = new SensitiveGrandSonEntity(); + grandSonEntity.setEmail("grq100296@163.com"); + sensitiveSubEntity.setSensitiveGrandSonEntity(grandSonEntity); + + subEntities.add(sensitiveSubEntity); + } + sensitiveEntity.setSubEntities(subEntities); + return sensitiveEntity; + } + + +} diff --git a/src/test/java/com/mos/secure/ext/demo/SensitiveSubEntity.java b/secure-ext-sensitive-demo/src/main/java/io/gitee/chemors/secure/ext/sensitive/demo/SensitiveSubEntity.java similarity index 47% rename from src/test/java/com/mos/secure/ext/demo/SensitiveSubEntity.java rename to secure-ext-sensitive-demo/src/main/java/io/gitee/chemors/secure/ext/sensitive/demo/SensitiveSubEntity.java index 2a786f90a991875b3af9287678644d94bfcae338..a41f5c5bd6f515e4f943169d5efa3ab578fad94e 100644 --- a/src/test/java/com/mos/secure/ext/demo/SensitiveSubEntity.java +++ b/secure-ext-sensitive-demo/src/main/java/io/gitee/chemors/secure/ext/sensitive/demo/SensitiveSubEntity.java @@ -1,8 +1,8 @@ -package com.mos.secure.ext.demo; +package io.gitee.chemors.secure.ext.sensitive.demo; -import com.mos.secure.ext.enums.SensitiveTypeEnum; -import com.mos.secure.ext.annotations.DesensitizationProp; +import io.gitee.chemors.secure.ext.annotations.DesensitizationProp; +import io.gitee.chemors.secure.ext.enums.SensitiveTypeEnum; import lombok.Data; /** @@ -17,4 +17,5 @@ public class SensitiveSubEntity { @DesensitizationProp(SensitiveTypeEnum.ADDRESS) private String address; + private SensitiveGrandSonEntity sensitiveGrandSonEntity; } diff --git a/secure-ext-sensitive-demo/src/main/resources/application.yaml b/secure-ext-sensitive-demo/src/main/resources/application.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1aa5dcdc47c97daacd5fd96150a38adca3f6d7d6 --- /dev/null +++ b/secure-ext-sensitive-demo/src/main/resources/application.yaml @@ -0,0 +1,5 @@ +server: + port: 8082 +sensitive: + depth: true + packages: io.gitee.chemors.secure.ext,com.chemors diff --git a/LICENSE b/secure-ext-spring-boot-starter/LICENSE similarity index 98% rename from LICENSE rename to secure-ext-spring-boot-starter/LICENSE index 29f81d812f3e768fa89638d1f72920dbfd1413a8..261eeb9e9f8b2b4b0d119366dda99c6fd7d35c64 100644 --- a/LICENSE +++ b/secure-ext-spring-boot-starter/LICENSE @@ -1,201 +1,201 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/secure-ext-spring-boot-starter/README.md similarity index 96% rename from README.md rename to secure-ext-spring-boot-starter/README.md index 89a8ee13e34dc05b1fd50602b182fcb69bf5feab..daf0bd160a4eebaf2305251440f7652a85882148 100644 --- a/README.md +++ b/secure-ext-spring-boot-starter/README.md @@ -1,113 +1,113 @@ -# secure-ext-spring-boot-starter - -## 1、简介 -专注安全领域,实现内容脱敏展示,期望做到可灵活配置,灵活启用,并且最好内置丰富插件,支持手机号、邮箱、身份证号、住址、中文名、座机号、银行卡、自定义等多种类型的脱敏配置。 - -由此诞生了本控件:**secure-ext-spring-boot-starter** - - -## 2、优点 - -**易集成:** 只需引入starter包,简单到无需任何初始化配置; - -**灵活:** 具体到方法级; - -**内置丰富:** 内置多种默认类型,且可根据自身需求,支持自定义脱敏规则 - -**自动化:** 支持深度脱敏,自动寻找返回值中嵌套对象包含的需脱敏的属性 - -## 3、最新版本 -[![Maven Central](https://img.shields.io/maven-metadata/v.svg?label=maven-central&metadataUrl=https%3A%2F%2Frepo1.maven.org%2Fmaven2%2Fio%2Fgitee%2Fchemors%2Fsecure-ext-spring-boot-starter%2Fmaven-metadata.xml)](https://search.maven.org/artifact/io.gitee.chemors/secure-ext-spring-boot-starter) -## 4、使用步骤 -### 4.1 引入依赖 -```xml - - io.gitee.chemors - secure-ext-spring-boot-starter - Lastest Version - -``` -### 4.2 开启脱敏注解 -```yaml -sensitive: - enable: true # 默认为true - depth: false # 是否开启深度脱敏,默认false - packages: # 扫描包路径,默认为空 -``` -### 4.3 添加注解 -**注意:** -* 方法注解表示该方法的返回值需要脱敏 -* 属性注解标识具体的脱敏规则 -#### 4.3.1 添加方法注解 -```java -@Desensitization -public Obj test(){ - // 业务逻辑,构建返回对象Obj - return Obj; -} -``` -#### 4.3.2 添加属性注解 -```java - @DesensitizationProp(SensitiveTypeEnum.MOBILE_PHONE) - private String mobile; -``` - -## 5、 默认类型说明 -* CHINESE_NAME //中文名 -* ID_CARD // 身份证号 -* FIXED_PHONE // 电话 -* MOBILE_PHONE // 手机 -* ADDRESS //地址 -* EMAIL //邮箱 -* BANK_CARD //银行卡号 -* PASSWORD // 密码 -* CUSTOM //自定义 (配合 DesensitizationProp 中preLength和sufLength 进行个性化定义) - -## 6、demo -* [secure-ext-demo](https://gitee.com/chemors/secure-ext-demo) - -## 7、示例 - -### 7.1 后台数据 - -```java - @Desensitization - public SensitiveEntity simpleData() { - SensitiveEntity sensitiveEntity = new SensitiveEntity(); - sensitiveEntity.setId("1"); - sensitiveEntity.setName("樱木花道"); - sensitiveEntity.setMobile("15699996666"); - sensitiveEntity.setIdCard("101010200001010001"); - return sensitiveEntity; - } -``` -### 7.2 返回结果 -```json -{ - "id": "1", - "name": "樱***", - "mobile": "156****6666", - "idCard": "101010********0001" -} -``` - - -## 8、其他开源项目 - -* [基于springboot开发的脚手架,旨在迅速搭建开发平台--eboot](https://gitee.com/QuanZhanZhiLu/eboot) -## 6、版权 -[Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0) -## 7、捐赠 -![输入图片说明](src/main/resources/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20220823111833.jpg) -## 8、关注我 -![欢迎关注公众号](https://images.gitee.com/uploads/images/2018/0726/081557_aa7756c9_660787.jpeg "陌与尘埃") - -## 9、更新日志 -* V1.0.0 -> 基础版 - -* V1.0.1 -> 支持复杂对象,多层嵌套属性自动脱敏 - -* V1.0.2 -> 优化包引用 +# secure-ext-spring-boot-starter + +## 1、简介 +专注安全领域,实现内容脱敏展示,期望做到可灵活配置,灵活启用,并且最好内置丰富插件,支持手机号、邮箱、身份证号、住址、中文名、座机号、银行卡、自定义等多种类型的脱敏配置。 + +由此诞生了本控件:**secure-ext-spring-boot-starter** + + +## 2、优点 + +**易集成:** 只需引入starter包,简单到无需任何初始化配置; + +**灵活:** 具体到方法级; + +**内置丰富:** 内置多种默认类型,且可根据自身需求,支持自定义脱敏规则 + +**自动化:** 支持深度脱敏,自动寻找返回值中嵌套对象包含的需脱敏的属性 + +## 3、最新版本 +[![Maven Central](https://img.shields.io/maven-metadata/v.svg?label=maven-central&metadataUrl=https%3A%2F%2Frepo1.maven.org%2Fmaven2%2Fio%2Fgitee%2Fchemors%2Fsecure-ext-spring-boot-starter%2Fmaven-metadata.xml)](https://search.maven.org/artifact/io.gitee.chemors/secure-ext-spring-boot-starter) +## 4、使用步骤 +### 4.1 引入依赖 +```xml + + io.gitee.chemors + secure-ext-spring-boot-starter + Lastest Version + +``` +### 4.2 开启脱敏注解 +```yaml +sensitive: + enable: true # 默认为true + depth: false # 是否开启深度脱敏,默认false + packages: # 扫描包路径,默认为空 +``` +### 4.3 添加注解 +**注意:** +* 方法注解表示该方法的返回值需要脱敏 +* 属性注解标识具体的脱敏规则 +#### 4.3.1 添加方法注解 +```java +@Desensitization +public Obj test(){ + // 业务逻辑,构建返回对象Obj + return Obj; +} +``` +#### 4.3.2 添加属性注解 +```java + @DesensitizationProp(SensitiveTypeEnum.MOBILE_PHONE) + private String mobile; +``` + +## 5、 默认类型说明 +* CHINESE_NAME //中文名 +* ID_CARD // 身份证号 +* FIXED_PHONE // 电话 +* MOBILE_PHONE // 手机 +* ADDRESS //地址 +* EMAIL //邮箱 +* BANK_CARD //银行卡号 +* PASSWORD // 密码 +* CUSTOM //自定义 (配合 DesensitizationProp 中preLength和sufLength 进行个性化定义) + +## 6、demo +* [secure-ext-demo](https://gitee.com/chemors/secure-ext-demo) + +## 7、示例 + +### 7.1 后台数据 + +```java + @Desensitization + public SensitiveEntity simpleData() { + SensitiveEntity sensitiveEntity = new SensitiveEntity(); + sensitiveEntity.setId("1"); + sensitiveEntity.setName("樱木花道"); + sensitiveEntity.setMobile("15699996666"); + sensitiveEntity.setIdCard("101010200001010001"); + return sensitiveEntity; + } +``` +### 7.2 返回结果 +```json +{ + "id": "1", + "name": "樱***", + "mobile": "156****6666", + "idCard": "101010********0001" +} +``` + + +## 8、其他开源项目 + +* [基于springboot开发的脚手架,旨在迅速搭建开发平台--eboot](https://gitee.com/QuanZhanZhiLu/eboot) +## 6、版权 +[Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0) +## 7、捐赠 +![输入图片说明](src/main/resources/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20220823111833.jpg) +## 8、关注我 +![欢迎关注公众号](https://images.gitee.com/uploads/images/2018/0726/081557_aa7756c9_660787.jpeg "陌与尘埃") + +## 9、更新日志 +* V1.0.0 +> 基础版 + +* V1.0.1 +> 支持复杂对象,多层嵌套属性自动脱敏 + +* V1.0.2 +> 优化包引用 diff --git a/secure-ext-spring-boot-starter/pom.xml b/secure-ext-spring-boot-starter/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..96ba5e75e27c2c458f97ef1b7a54f5fa70dbc8a4 --- /dev/null +++ b/secure-ext-spring-boot-starter/pom.xml @@ -0,0 +1,171 @@ + + + + secure-ext-spring-boot + io.gitee.chemors + 1.0.3-RELEASE + + 4.0.0 + secure-ext-spring-boot-starter + secure-ext-spring-boot-starter + secure-ext-spring-boot-starter + https://gitee.com/chemors/secure-ext-spring-boot-starter + + + 1.8 + + + + + org.springframework.boot + spring-boot-starter + + + + org.springframework.boot + spring-boot-configuration-processor + compile + + + + org.springframework.boot + spring-boot-starter-aop + compile + + + + org.springframework.boot + spring-boot-starter-test + test + + + cn.hutool + hutool-all + compile + + + org.projectlombok + lombok + compile + + + + + + ${project.artifactId} + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + org.apache.maven.plugins + maven-source-plugin + 2.1 + + true + + + + compile + + jar + + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.1 + + private + true + UTF-8 + UTF-8 + UTF-8 + + + + package + + jar + + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.5 + + + sign-artifacts + verify + + sign + + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.8 + true + + oss + https://s01.oss.sonatype.org/ + true + + + + + + + + + + oss + https://oss.sonatype.org/content/repositories/snapshots/ + + + oss + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + + + + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + scm:git:git@gitee.com:chemors/secure-ext-spring-boot-starter.git + scm:git:git@gitee.com:chemors/secure-ext-spring-boot-starter.git + git@gitee.com:chemors/secure-ext-spring-boot-starter.git + + + + + xiaochenge + grq100296@163.com + https://gitee.com/chemors/secure-ext-spring-boot-starter + +8 + + + diff --git a/secure-ext-spring-boot-starter/src/main/java/io/gitee/chemors/secure/ext/AppRun.java b/secure-ext-spring-boot-starter/src/main/java/io/gitee/chemors/secure/ext/AppRun.java new file mode 100644 index 0000000000000000000000000000000000000000..d9997391aac0a866e585712633ceceab9d1f2dbd --- /dev/null +++ b/secure-ext-spring-boot-starter/src/main/java/io/gitee/chemors/secure/ext/AppRun.java @@ -0,0 +1,8 @@ +package io.gitee.chemors.secure.ext; + +public class AppRun { + + public static void main(String[] args) { + + } +} diff --git a/src/main/java/com/mos/secure/ext/annotations/Desensitization.java b/secure-ext-spring-boot-starter/src/main/java/io/gitee/chemors/secure/ext/annotations/Desensitization.java similarity index 85% rename from src/main/java/com/mos/secure/ext/annotations/Desensitization.java rename to secure-ext-spring-boot-starter/src/main/java/io/gitee/chemors/secure/ext/annotations/Desensitization.java index c756d4da8fdd47cd7f5005b1272f4cb55965954a..ab624b9a7217eaff0e173aaf358d1ec8604a2eb9 100644 --- a/src/main/java/com/mos/secure/ext/annotations/Desensitization.java +++ b/secure-ext-spring-boot-starter/src/main/java/io/gitee/chemors/secure/ext/annotations/Desensitization.java @@ -1,4 +1,4 @@ -package com.mos.secure.ext.annotations; +package io.gitee.chemors.secure.ext.annotations; import java.lang.annotation.*; diff --git a/src/main/java/com/mos/secure/ext/annotations/DesensitizationProp.java b/secure-ext-spring-boot-starter/src/main/java/io/gitee/chemors/secure/ext/annotations/DesensitizationProp.java similarity index 75% rename from src/main/java/com/mos/secure/ext/annotations/DesensitizationProp.java rename to secure-ext-spring-boot-starter/src/main/java/io/gitee/chemors/secure/ext/annotations/DesensitizationProp.java index 88441b67d5aaa16b3ef6848cc19aa973a68d02c1..558ffb75457761deefd0eaa286caed01e81cf03c 100644 --- a/src/main/java/com/mos/secure/ext/annotations/DesensitizationProp.java +++ b/secure-ext-spring-boot-starter/src/main/java/io/gitee/chemors/secure/ext/annotations/DesensitizationProp.java @@ -1,6 +1,6 @@ -package com.mos.secure.ext.annotations; +package io.gitee.chemors.secure.ext.annotations; -import com.mos.secure.ext.enums.SensitiveTypeEnum; +import io.gitee.chemors.secure.ext.enums.SensitiveTypeEnum; import java.lang.annotation.*; diff --git a/src/main/java/com/mos/secure/ext/aspect/SensitiveAspect.java b/secure-ext-spring-boot-starter/src/main/java/io/gitee/chemors/secure/ext/aspect/SensitiveAspect.java similarity index 90% rename from src/main/java/com/mos/secure/ext/aspect/SensitiveAspect.java rename to secure-ext-spring-boot-starter/src/main/java/io/gitee/chemors/secure/ext/aspect/SensitiveAspect.java index 322083b1495ff716ed341c83cfb5d16b8be54b9a..b64aae98765f994bec0e8f62453adc9f566f263f 100644 --- a/src/main/java/com/mos/secure/ext/aspect/SensitiveAspect.java +++ b/secure-ext-spring-boot-starter/src/main/java/io/gitee/chemors/secure/ext/aspect/SensitiveAspect.java @@ -1,10 +1,10 @@ -package com.mos.secure.ext.aspect; +package io.gitee.chemors.secure.ext.aspect; import cn.hutool.core.util.StrUtil; -import com.mos.secure.ext.annotations.Desensitization; -import com.mos.secure.ext.annotations.DesensitizationProp; -import com.mos.secure.ext.config.SensitiveProp; -import com.mos.secure.ext.util.MosDesensitizedUtil; +import io.gitee.chemors.secure.ext.annotations.Desensitization; +import io.gitee.chemors.secure.ext.annotations.DesensitizationProp; +import io.gitee.chemors.secure.ext.config.SensitiveProp; +import io.gitee.chemors.secure.ext.util.MosDesensitizedUtil; import lombok.extern.slf4j.Slf4j; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; @@ -35,7 +35,7 @@ public class SensitiveAspect { /** * 切点 */ - @Pointcut(value = "@annotation(com.mos.secure.ext.annotations.Desensitization)") + @Pointcut(value = "@annotation(io.gitee.chemors.secure.ext.annotations.Desensitization)") public void getPoint() { } diff --git a/src/main/java/com/mos/secure/ext/config/SensitiveAutoConfigure.java b/secure-ext-spring-boot-starter/src/main/java/io/gitee/chemors/secure/ext/config/SensitiveAutoConfigure.java similarity index 81% rename from src/main/java/com/mos/secure/ext/config/SensitiveAutoConfigure.java rename to secure-ext-spring-boot-starter/src/main/java/io/gitee/chemors/secure/ext/config/SensitiveAutoConfigure.java index a002625944b283587b51c7df62dc93e86d27d403..0dca059807630fc206d0f31e1f8b7a4b8ecc2882 100644 --- a/src/main/java/com/mos/secure/ext/config/SensitiveAutoConfigure.java +++ b/secure-ext-spring-boot-starter/src/main/java/io/gitee/chemors/secure/ext/config/SensitiveAutoConfigure.java @@ -1,6 +1,6 @@ -package com.mos.secure.ext.config; +package io.gitee.chemors.secure.ext.config; -import com.mos.secure.ext.aspect.SensitiveAspect; +import io.gitee.chemors.secure.ext.aspect.SensitiveAspect; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/src/main/java/com/mos/secure/ext/config/SensitiveConfig.java b/secure-ext-spring-boot-starter/src/main/java/io/gitee/chemors/secure/ext/config/SensitiveConfig.java similarity index 92% rename from src/main/java/com/mos/secure/ext/config/SensitiveConfig.java rename to secure-ext-spring-boot-starter/src/main/java/io/gitee/chemors/secure/ext/config/SensitiveConfig.java index 74ea81b380d1be2b03beef6d20d1c07ae46ee194..770fca896b3a922356b569166d67afa905b0fd4f 100644 --- a/src/main/java/com/mos/secure/ext/config/SensitiveConfig.java +++ b/secure-ext-spring-boot-starter/src/main/java/io/gitee/chemors/secure/ext/config/SensitiveConfig.java @@ -1,4 +1,4 @@ -package com.mos.secure.ext.config; +package io.gitee.chemors.secure.ext.config; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.context.annotation.Bean; diff --git a/src/main/java/com/mos/secure/ext/config/SensitiveProp.java b/secure-ext-spring-boot-starter/src/main/java/io/gitee/chemors/secure/ext/config/SensitiveProp.java similarity index 91% rename from src/main/java/com/mos/secure/ext/config/SensitiveProp.java rename to secure-ext-spring-boot-starter/src/main/java/io/gitee/chemors/secure/ext/config/SensitiveProp.java index 83bad452a094e81454e8b5e5b4366f0bcb0cf4b5..db3a7e94686bbce824838351c6f37c891300a058 100644 --- a/src/main/java/com/mos/secure/ext/config/SensitiveProp.java +++ b/secure-ext-spring-boot-starter/src/main/java/io/gitee/chemors/secure/ext/config/SensitiveProp.java @@ -1,4 +1,4 @@ -package com.mos.secure.ext.config; +package io.gitee.chemors.secure.ext.config; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; diff --git a/src/main/java/com/mos/secure/ext/enums/SensitiveTypeEnum.java b/secure-ext-spring-boot-starter/src/main/java/io/gitee/chemors/secure/ext/enums/SensitiveTypeEnum.java similarity index 91% rename from src/main/java/com/mos/secure/ext/enums/SensitiveTypeEnum.java rename to secure-ext-spring-boot-starter/src/main/java/io/gitee/chemors/secure/ext/enums/SensitiveTypeEnum.java index b9b6673ac396082a15fdc819d37c8b7c3d966d8d..88a33dae7bdf12419cc8147ae9fa695ebfa7e76f 100644 --- a/src/main/java/com/mos/secure/ext/enums/SensitiveTypeEnum.java +++ b/secure-ext-spring-boot-starter/src/main/java/io/gitee/chemors/secure/ext/enums/SensitiveTypeEnum.java @@ -1,4 +1,4 @@ -package com.mos.secure.ext.enums; +package io.gitee.chemors.secure.ext.enums; /** diff --git a/src/main/java/com/mos/secure/ext/util/MosDesensitizedUtil.java b/secure-ext-spring-boot-starter/src/main/java/io/gitee/chemors/secure/ext/util/MosDesensitizedUtil.java similarity index 94% rename from src/main/java/com/mos/secure/ext/util/MosDesensitizedUtil.java rename to secure-ext-spring-boot-starter/src/main/java/io/gitee/chemors/secure/ext/util/MosDesensitizedUtil.java index 80c0b381e0f5415b7d3c6a11fe8fb74631b3aeb2..a883363dab923056d84347682759ee9e62565463 100644 --- a/src/main/java/com/mos/secure/ext/util/MosDesensitizedUtil.java +++ b/secure-ext-spring-boot-starter/src/main/java/io/gitee/chemors/secure/ext/util/MosDesensitizedUtil.java @@ -1,8 +1,8 @@ -package com.mos.secure.ext.util; +package io.gitee.chemors.secure.ext.util; import cn.hutool.core.util.DesensitizedUtil; import cn.hutool.core.util.StrUtil; -import com.mos.secure.ext.annotations.DesensitizationProp; +import io.gitee.chemors.secure.ext.annotations.DesensitizationProp; import lombok.extern.slf4j.Slf4j; /** diff --git a/src/main/resources/META-INF/spring.factories b/secure-ext-spring-boot-starter/src/main/resources/META-INF/spring.factories similarity index 36% rename from src/main/resources/META-INF/spring.factories rename to secure-ext-spring-boot-starter/src/main/resources/META-INF/spring.factories index 0119181a7db0988d55a115e0f1be6bcc9d746e1f..708f90bc0b9b099c311c7dacb14bab256aaedf02 100644 --- a/src/main/resources/META-INF/spring.factories +++ b/secure-ext-spring-boot-starter/src/main/resources/META-INF/spring.factories @@ -1,3 +1,3 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ - com.mos.secure.ext.config.SensitiveConfig,\ - com.mos.secure.ext.config.SensitiveAutoConfigure + io.gitee.chemors.secure.ext.config.SensitiveConfig,\ + io.gitee.chemors.secure.ext.config.SensitiveAutoConfigure diff --git a/src/main/resources/application.yaml b/secure-ext-spring-boot-starter/src/main/resources/application.yaml similarity index 100% rename from src/main/resources/application.yaml rename to secure-ext-spring-boot-starter/src/main/resources/application.yaml diff --git "a/src/main/resources/\345\276\256\344\277\241\345\233\276\347\211\207_20220823111833.jpg" "b/secure-ext-spring-boot-starter/src/main/resources/\345\276\256\344\277\241\345\233\276\347\211\207_20220823111833.jpg" similarity index 100% rename from "src/main/resources/\345\276\256\344\277\241\345\233\276\347\211\207_20220823111833.jpg" rename to "secure-ext-spring-boot-starter/src/main/resources/\345\276\256\344\277\241\345\233\276\347\211\207_20220823111833.jpg" diff --git "a/src/main/resources/\351\231\214\344\270\216\345\260\230\345\237\203\345\205\254\344\274\227\345\217\267.jpg" "b/secure-ext-spring-boot-starter/src/main/resources/\351\231\214\344\270\216\345\260\230\345\237\203\345\205\254\344\274\227\345\217\267.jpg" similarity index 100% rename from "src/main/resources/\351\231\214\344\270\216\345\260\230\345\237\203\345\205\254\344\274\227\345\217\267.jpg" rename to "secure-ext-spring-boot-starter/src/main/resources/\351\231\214\344\270\216\345\260\230\345\237\203\345\205\254\344\274\227\345\217\267.jpg" diff --git "a/\351\231\214\344\270\216\345\260\230\345\237\203\345\205\254\344\274\227\345\217\267.jpg" "b/secure-ext-spring-boot-starter/\351\231\214\344\270\216\345\260\230\345\237\203\345\205\254\344\274\227\345\217\267.jpg" similarity index 100% rename from "\351\231\214\344\270\216\345\260\230\345\237\203\345\205\254\344\274\227\345\217\267.jpg" rename to "secure-ext-spring-boot-starter/\351\231\214\344\270\216\345\260\230\345\237\203\345\205\254\344\274\227\345\217\267.jpg" diff --git a/src/test/java/com/mos/secure/ext/SensitiveSpringBootStarterApplicationTests.java b/src/test/java/com/mos/secure/ext/SensitiveSpringBootStarterApplicationTests.java deleted file mode 100644 index 90dbca9b98f9ac20167a87a03e0454a0aa5b11b4..0000000000000000000000000000000000000000 --- a/src/test/java/com/mos/secure/ext/SensitiveSpringBootStarterApplicationTests.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.mos.secure.ext; - -import cn.hutool.json.JSONUtil; -import com.mos.secure.ext.demo.SensitiveEntity; -import com.mos.secure.ext.demo.SensitiveService; -import lombok.extern.slf4j.Slf4j; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -import javax.annotation.Resource; -import java.util.List; - -@SpringBootTest -@Slf4j -class SensitiveSpringBootStarterApplicationTests { - - @Resource - private SensitiveService sensitiveService; - - @Test - void contextLoads() { - SensitiveEntity sensitiveEntity = sensitiveService.simpleData(); - log.info("d--->{}", JSONUtil.toJsonStr(sensitiveEntity)); - } - - @Test - void listData() { - List d = sensitiveService.listData(); - log.info("d--->{}", JSONUtil.toJsonStr(d)); - } -} diff --git a/src/test/java/com/mos/secure/ext/demo/SensitiveService.java b/src/test/java/com/mos/secure/ext/demo/SensitiveService.java deleted file mode 100644 index 376ad2beb9f71c76c2fd6381d7dd3bcee8898f3c..0000000000000000000000000000000000000000 --- a/src/test/java/com/mos/secure/ext/demo/SensitiveService.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.mos.secure.ext.demo; - -import com.mos.secure.ext.annotations.Desensitization; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.ArrayList; -import java.util.List; - -@Component -@Slf4j -public class SensitiveService { - @Desensitization - public SensitiveEntity simpleData() { - SensitiveEntity sensitiveEntity = new SensitiveEntity(); - sensitiveEntity.setId("1"); - sensitiveEntity.setName("樱木花道"); - sensitiveEntity.setMobile("15699996666"); - sensitiveEntity.setIdCard("101010200001010001"); - return sensitiveEntity; - } - - @Desensitization - public List listData() { - System.out.println("执行业务处理..."); - List list = new ArrayList(); - for (int i = 0; i < 5; i++) { - - SensitiveEntity sensitiveEntity = new SensitiveEntity(); - sensitiveEntity.setId("1" + i); - sensitiveEntity.setName("樱木花道" + i); - sensitiveEntity.setMobile("15699996666" + i); - sensitiveEntity.setIdCard("10101020000101000" + i); - List subEntities = new ArrayList(); - for (int j=0;j<3;j++){ - SensitiveSubEntity sensitiveSubEntity = new SensitiveSubEntity(); - sensitiveSubEntity.setAddress("addr--->"+j); - subEntities.add(sensitiveSubEntity); - } - sensitiveEntity.setSubEntities(subEntities); - list.add(sensitiveEntity); - } - return list; - } - - -}