You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/03/13 03:19:52 UTC

[GitHub] [incubator-shardingsphere] Jaskey opened a new issue #4741: How to implement a user-define encryptors

Jaskey opened a new issue #4741: How to implement a user-define encryptors
URL: https://github.com/apache/incubator-shardingsphere/issues/4741
 
 
   I look up the total user guide and search google for a long time but I can't find how to implement a user-define encryptors. And some body give me an example?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] Jaskey closed issue #4741: How to implement a user-define encryptors

Posted by GitBox <gi...@apache.org>.
Jaskey closed issue #4741: How to implement a user-define encryptors
URL: https://github.com/apache/incubator-shardingsphere/issues/4741
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] Jaskey edited a comment on issue #4741: How to implement a user-define encryptors

Posted by GitBox <gi...@apache.org>.
Jaskey edited a comment on issue #4741: How to implement a user-define encryptors
URL: https://github.com/apache/incubator-shardingsphere/issues/4741#issuecomment-598545620
 
 
   After Reading some source code, Solution found!
   
   ## 1. Given your Encryptor which implements 
   
   ```
   
   public class TestShardingEncryptor implements ShardingEncryptor {
   
       private Properties properties = new Properties();
   
       @Override
       public String getType() {
           return "TEST";
       }
   
   
       @Override
       public void init() {
           log.info("==============init ");
       }
   
       @Override
       public String encrypt(final Object plaintext) {
           return "TEST-"+String.valueOf(plaintext);
       }
   
       @Override
       public Object decrypt(final String ciphertext) {
           return ciphertext.replaceAll("TEST-","");
       }
   }
   
   ```
   
   ## 2.   Create a spi file in your resouce folder  
            
             .....src\main\resources\META-INF\services\org.apache.shardingsphere.spi.encrypt.ShardingEncryptor
   
   And write your full class name it, for example: 
   
          mytest.sharding.TestShardingEncryptor
   
   ## 3. At last,  every ShardingEncryptor has a type value which return from `getType` method(in my case,  that is "TEST") , 
   
    Just use your Type when configuring EncryptorRuleConfiguration, in Java Config case, that is
        
        EncryptorRuleConfiguration encryptorConfig = new EncryptorRuleConfiguration("TEST", props);
   
   The rest is the same as usual.  Done!
   
           
   
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] Jaskey edited a comment on issue #4741: How to implement a user-define encryptors

Posted by GitBox <gi...@apache.org>.
Jaskey edited a comment on issue #4741: How to implement a user-define encryptors
URL: https://github.com/apache/incubator-shardingsphere/issues/4741#issuecomment-598545620
 
 
   After Reading some source code, Solution found!
   
   ## 1. Given your Encryptor which implements 
   
   ```
   
   public class TestShardingEncryptor implements ShardingEncryptor {
   
       private Properties properties = new Properties();
   
       @Override
       public String getType() {
           return "TEST";
       }
   
   
       @Override
       public void init() {
           log.info("==============init ");
       }
   
       @Override
       public String encrypt(final Object plaintext) {
           return "TEST-"+String.valueOf(plaintext);
       }
   
       @Override
       public Object decrypt(final String ciphertext) {
           return ciphertext.replaceAll("TEST-","");
       }
   }
   
   ```
   
   ## 2.   Create a spi file in your resouce folder  
            
             .....src\main\resources\META-INF\services\org.apache.shardingsphere.spi.encrypt.ShardingEncryptor
   
   And write your full class name it, for example: 
   
          mytest.sharding.TestShardingEncryptor
   
   ## 3. At last,  specify to use your defined  ShardingEncryptor 
   
   Your ShardingEncryptor will have a type value which return from `getType` method (in my case,  that is "TEST") , so just use this type when configuring EncryptorRuleConfiguration.
   
   In Java Configuration case, that is
        
        EncryptorRuleConfiguration encryptorConfig = new EncryptorRuleConfiguration("TEST", props);
   
   
   The rest is the same as usual.  Done!
   
           
   
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] Jaskey edited a comment on issue #4741: How to implement a user-define encryptors

Posted by GitBox <gi...@apache.org>.
Jaskey edited a comment on issue #4741: How to implement a user-define encryptors
URL: https://github.com/apache/incubator-shardingsphere/issues/4741#issuecomment-598545620
 
 
   After Reading some source code, Solution found!
   
   ## 1. Given your Encryptor which implements 
   
   ```
   
   public class TestShardingEncryptor implements ShardingEncryptor {
   
       private Properties properties = new Properties();
   
       @Override
       public String getType() {
           return "TEST";
       }
   
   
       @Override
       public void init() {
           log.info("==============init ");
       }
   
       @Override
       public String encrypt(final Object plaintext) {
           return "TEST-"+String.valueOf(plaintext);
       }
   
       @Override
       public Object decrypt(final String ciphertext) {
           return ciphertext.replaceAll("TEST-","");
       }
   }
   
   ```
   
   ##2.   Create a spi file in your resouce folder  
            
             .....src\main\resources\META-INF\services\org.apache.shardingsphere.spi.encrypt.ShardingEncryptor
   
   And write your full class name it, for example: 
   
          mytest.sharding.TestShardingEncryptor
   
   3. At last,  every ShardingEncryptor has a type value which return from `getType` method(in my case,  that is "TEST") , 
   
    Just use your Type when configuring EncryptorRuleConfiguration, in Java Config case, that is
        
        EncryptorRuleConfiguration encryptorConfig = new EncryptorRuleConfiguration("TEST", props);
   
           
   
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] Jaskey commented on issue #4741: How to implement a user-define encryptors

Posted by GitBox <gi...@apache.org>.
Jaskey commented on issue #4741: How to implement a user-define encryptors
URL: https://github.com/apache/incubator-shardingsphere/issues/4741#issuecomment-598545620
 
 
   After Reading some source code, Solution found!
   
   1. Given your Encryptor which implements 
   
   ```
   
   public class TestShardingEncryptor implements ShardingEncryptor {
   
       private Properties properties = new Properties();
   
       @Override
       public String getType() {
           return "TEST";
       }
   
   
       @Override
       public void init() {
           log.info("==============init ");
       }
   
       @Override
       public String encrypt(final Object plaintext) {
           return "TEST-"+String.valueOf(plaintext);
       }
   
       @Override
       public Object decrypt(final String ciphertext) {
           return ciphertext.replaceAll("TEST-","");
       }
   }
   
   ```
   
   2.  Create a spi file in your resouce folder 
            
         .....src\main\resources\META-INF\services\org.apache.shardingsphere.spi.encrypt.ShardingEncryptor
   
   And write your class name in the file like 
   
          mytest.sharding.TestShardingEncryptor
   
   3. At last,  every ShardingEncryptor has a type value which return from `getType` method(in my case,  that is "TEST") , 
   
    Just use your Type when configuring EncryptorRuleConfiguration, in Java Config case, that is
        
        EncryptorRuleConfiguration encryptorConfig = new EncryptorRuleConfiguration("TEST", props);
   
           
   
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services