Sharding Encryptor
[New feature] Sharding Encryptor This new feature is to encode sensitive information, e.g, password or ID to store them in databases, and decode ciphertext in databases for queries. Here are the main tasks:
- SQL parsing for sensitive columns
- SQL rewriting for sensitive columns
- API of Sharding Encryptor
- [x] Design API of encryptor for ShardingRule
- [x] Design API of encryptRule
- [x] Design API of encryptor for Sharding SpringNameSpace
- [x] Design API of encryptor for Sharding SpringBoot
- [x] Add unit tests
- JDBC interface implementation for Sharding Encryptor
- Built-in Encryptor implementation
This new feature is important and time-consuming, so each of tasks will take a plenty of time to finish. Currently first task is assigned to hongJun Du, and i am doing the thrid one. I hope i can finish the third one before Spring Festival, therefore i can continue to do others. Any suggestions, please let us know. Waiting for youre reply.
We need to consider about interface of ShardingEncryptor.
Right now is:
Object encrypt(Object plaintext);
Object decrypt(Object ciphertext);
The parameter for encrypt is plaintext, and return value is object, plaintext means the parameter is String. so, maybe should rename param name as plainValue, and return value will save into database, string is a good return type.
The parameter for decrypt is ciphertext, it is returned from database, so string is good type. object of return type is fine.
hi guys,it's nice feature. but how can i use encryptor and sharding in the same time,it's look like conflict each other. the execption message blow
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.sql.SQLFeatureNotSupportedException: getCatalog
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:622)
... 70 common frames omitted
Caused by: java.sql.SQLFeatureNotSupportedException: getCatalog
at org.apache.shardingsphere.shardingjdbc.jdbc.unsupported.AbstractUnsupportedOperationConnection.getCatalog(AbstractUnsupportedOperationConnection.java:91)
at org.apache.shardingsphere.shardingjdbc.jdbc.core.datasource.EncryptDataSource.isTableExist(EncryptDataSource.java:88)
at org.apache.shardingsphere.shardingjdbc.jdbc.core.datasource.EncryptDataSource.createEncryptTableMetaData(EncryptDataSource.java:79)
at org.apache.shardingsphere.shardingjdbc.jdbc.core.datasource.EncryptDataSource.<init>(EncryptDataSource.java:71)
at org.apache.shardingsphere.shardingjdbc.api.EncryptDataSourceFactory.createDataSource(EncryptDataSourceFactory.java:43)
at org.apache.shardingsphere.samples.config.ShardingConfig.dataSource(ShardingConfig.java:70)
at org.apache.shardingsphere.samples.config.ShardingConfig$$EnhancerBySpringCGLIB$$8816e7e7.CGLIB$dataSource$0(<generated>)
at org.apache.shardingsphere.samples.config.ShardingConfig$$EnhancerBySpringCGLIB$$8816e7e7$$FastClassBySpringCGLIB$$839386bc.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:363)
at org.apache.shardingsphere.samples.config.ShardingConfig$$EnhancerBySpringCGLIB$$8816e7e7.dataSource(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
... 71 common frames omitted