com.github.homeant:data-shield-core

云盾

License

License

Categories

Categories

Ant Build Tools Data
GroupId

GroupId

com.github.homeant
ArtifactId

ArtifactId

data-shield-core
Last Version

Last Version

1.0-RELEASE
Release Date

Release Date

Type

Type

jar
Description

Description

云盾

Download data-shield-core

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.homeant/data-shield-core/ -->
<dependency>
    <groupId>com.github.homeant</groupId>
    <artifactId>data-shield-core</artifactId>
    <version>1.0-RELEASE</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.homeant/data-shield-core/
implementation 'com.github.homeant:data-shield-core:1.0-RELEASE'
// https://jarcasting.com/artifacts/com.github.homeant/data-shield-core/
implementation ("com.github.homeant:data-shield-core:1.0-RELEASE")
'com.github.homeant:data-shield-core:jar:1.0-RELEASE'
<dependency org="com.github.homeant" name="data-shield-core" rev="1.0-RELEASE">
  <artifact name="data-shield-core" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.homeant', module='data-shield-core', version='1.0-RELEASE')
)
libraryDependencies += "com.github.homeant" % "data-shield-core" % "1.0-RELEASE"
[com.github.homeant/data-shield-core "1.0-RELEASE"]

Dependencies

compile (5)

Group / Artifact Type Version
org.apache.commons : commons-lang3 jar 3.10
com.google.code.gson : gson jar
org.springframework.boot : spring-boot-configuration-processor Optional jar
org.springframework.boot : spring-boot-autoconfigure Optional jar
org.projectlombok : lombok jar

provided (2)

Group / Artifact Type Version
org.mybatis : mybatis jar 3.5.4
org.mybatis.spring.boot : mybatis-spring-boot-starter jar 2.1.2

Project Modules

There are no modules declared in this project.

data-shield

针对mybatis对业务敏感数据进行加密,为企业数据保驾护航

2021-04-03 16:23:16.604 DEBUG 3020 --- [           main] c.g.h.d.shield.mapper.UserMapper.insert  : ==>  Preparing: insert into t_user (username,password) values ( ?, ?) 
2021-04-03 16:23:16.629 DEBUG 3020 --- [           main] c.g.h.d.shield.mapper.UserMapper.insert  : ==> Parameters: tom(String), L0wfhbKDAELRnj03GtjKoQ==(String)
2021-04-03 16:23:16.651 DEBUG 3020 --- [           main] c.g.h.d.shield.mapper.UserMapper.insert  : <==    Updates: 1
2021-04-03 16:23:16.675 DEBUG 3020 --- [           main] c.g.h.d.s.mapper.UserMapper.selectOn     : ==>  Preparing: select id,username,password from t_user where id = ? 
2021-04-03 16:23:16.675 DEBUG 3020 --- [           main] c.g.h.d.s.mapper.UserMapper.selectOn     : ==> Parameters: 75(Integer)
2021-04-03 16:23:23.313 DEBUG 3020 --- [           main] c.g.h.d.s.mapper.UserMapper.selectOn     : <==      Total: 1
2021-04-03 16:23:26.166 DEBUG 3020 --- [           main] com.github.homeant.data.shield.DataTest  : user:User(id=75, username=tom, password=p@ssw0rd1234567)
mysql> select * from t_user;
+----+----------+--------------------------+
| id | username | password                 |
+----+----------+--------------------------+
| 74 | tom      | L0wfhbKDAELRnj03GtjKoQ== |
| 75 | tom      | L0wfhbKDAELRnj03GtjKoQ== |
+----+----------+--------------------------+
2 rows in set (0.03 sec)

pom.xml配置

<dependency>
   <groupId>com.github.homeant</groupId>
   <artifactId>data-shield</artifactId>
   <version>1.0-BATE</version>
</dependency>

yaml配置

app:
  data:
    shield:
      enable: true
      strategy: aes #支持AES/DES模式 
      key: AD42F6697B035B7580E4FEF93BE20BAD

业务字段配置

为需要处理的业务字段添加@TableField注解,只支持String类型

encrypt: 修改过程是否需要加密,默认为false

decode: 查询过程是否需要解密,默认为false

asserts: decode为true时,针对某些数据(历史数据)提供断言,默认值DefaultAssert.class(encrypt=true,decode=true)

@Data
public class User {
    private Integer id;

    private String username;

    @TableField(encrypt = true,decode = true,assertion=Base64Assert.class)
    private String phone;
}

更新日志

2020-05-17

  1. data-shield问世,针对mybatis对业务敏感数据进行加密,包含queryupdate操作;加密模式有AESDES
  2. 新增DataShieldService可单独对业务对象进行加解密
  3. 新增DataShieldHelper可对查询结果进行打码操作

2021-04-03

  1. 添加mybatisCursor查询
  2. 修改query模式不污染原始查询对象

Versions

Version
1.0-RELEASE