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/01/11 07:39:19 UTC

[GitHub] [incubator-shardingsphere] longjy opened a new pull request #3934: Get ciphertext column as a string

longjy opened a new pull request #3934: Get ciphertext column as a string
URL: https://github.com/apache/incubator-shardingsphere/pull/3934
 
 
   Encrypt the field, and take the value of string type directly. For example, after digital encryption, the database can be saved as varchar, and the corresponding field of bean can still be numbe

----------------------------------------------------------------
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] terrymanu commented on issue #3934: Get ciphertext column as a string

Posted by GitBox <gi...@apache.org>.
terrymanu commented on issue #3934: Get ciphertext column as a string
URL: https://github.com/apache/incubator-shardingsphere/pull/3934#issuecomment-573644085
 
 
   Why close this pr?

----------------------------------------------------------------
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] longjy commented on a change in pull request #3934: Get ciphertext column as a string

Posted by GitBox <gi...@apache.org>.
longjy commented on a change in pull request #3934: Get ciphertext column as a string
URL: https://github.com/apache/incubator-shardingsphere/pull/3934#discussion_r365776366
 
 

 ##########
 File path: encrypt-core/encrypt-core-merge/src/main/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptMergedResult.java
 ##########
 @@ -44,15 +44,15 @@
     public boolean next() throws SQLException {
         return mergedResult.next();
     }
-    
+
     @Override
     public Object getValue(final int columnIndex, final Class<?> type) throws SQLException {
-        Object value = mergedResult.getValue(columnIndex, type);
-        if (null == value || !queryWithCipherColumn) {
-            return value;
+        Optional<Encryptor> encryptor;
+        if (!queryWithCipherColumn || !(encryptor = metaData.findEncryptor(columnIndex)).isPresent()) {
+            return mergedResult.getValue(columnIndex, type);
         }
-        Optional<Encryptor> encryptor = metaData.findEncryptor(columnIndex);
-        return encryptor.isPresent() ? encryptor.get().decrypt(value.toString()) : value;
+        String ciphertext = (String) mergedResult.getValue(columnIndex, String.class);
+        return ciphertext == null ? null : encryptor.get().decrypt(ciphertext);
 
 Review comment:
   Coding style I will fix

----------------------------------------------------------------
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] SteNicholas commented on a change in pull request #3934: Get ciphertext column as a string

Posted by GitBox <gi...@apache.org>.
SteNicholas commented on a change in pull request #3934: Get ciphertext column as a string
URL: https://github.com/apache/incubator-shardingsphere/pull/3934#discussion_r365621729
 
 

 ##########
 File path: encrypt-core/encrypt-core-merge/src/main/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptMergedResult.java
 ##########
 @@ -44,15 +44,15 @@
     public boolean next() throws SQLException {
         return mergedResult.next();
     }
-    
+
 
 Review comment:
   This should recover to the origin style.

----------------------------------------------------------------
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] terrymanu commented on issue #3934: Get ciphertext column as a string

Posted by GitBox <gi...@apache.org>.
terrymanu commented on issue #3934: Get ciphertext column as a string
URL: https://github.com/apache/incubator-shardingsphere/pull/3934#issuecomment-573320514
 
 
   I have a little confuse, why force get value from ResultSet by String type?
   I can't get the point, what is the issue in original code?

----------------------------------------------------------------
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] SteNicholas commented on a change in pull request #3934: Get ciphertext column as a string

Posted by GitBox <gi...@apache.org>.
SteNicholas commented on a change in pull request #3934: Get ciphertext column as a string
URL: https://github.com/apache/incubator-shardingsphere/pull/3934#discussion_r365622157
 
 

 ##########
 File path: encrypt-core/encrypt-core-merge/src/main/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptMergedResult.java
 ##########
 @@ -44,15 +44,15 @@
     public boolean next() throws SQLException {
         return mergedResult.next();
     }
-    
+
     @Override
     public Object getValue(final int columnIndex, final Class<?> type) throws SQLException {
-        Object value = mergedResult.getValue(columnIndex, type);
-        if (null == value || !queryWithCipherColumn) {
-            return value;
+        Optional<Encryptor> encryptor;
+        if (!queryWithCipherColumn || !(encryptor = metaData.findEncryptor(columnIndex)).isPresent()) {
+            return mergedResult.getValue(columnIndex, type);
         }
-        Optional<Encryptor> encryptor = metaData.findEncryptor(columnIndex);
-        return encryptor.isPresent() ? encryptor.get().decrypt(value.toString()) : value;
+        String ciphertext = (String) mergedResult.getValue(columnIndex, String.class);
 
 Review comment:
   Does the `mergeResult` include result type except String? This transformation could cause exception.

----------------------------------------------------------------
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] longjy closed pull request #3934: Get ciphertext column as a string

Posted by GitBox <gi...@apache.org>.
longjy closed pull request #3934: Get ciphertext column as a string
URL: https://github.com/apache/incubator-shardingsphere/pull/3934
 
 
   

----------------------------------------------------------------
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] SteNicholas commented on a change in pull request #3934: Get ciphertext column as a string

Posted by GitBox <gi...@apache.org>.
SteNicholas commented on a change in pull request #3934: Get ciphertext column as a string
URL: https://github.com/apache/incubator-shardingsphere/pull/3934#discussion_r365621924
 
 

 ##########
 File path: encrypt-core/encrypt-core-merge/src/main/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptMergedResult.java
 ##########
 @@ -44,15 +44,15 @@
     public boolean next() throws SQLException {
         return mergedResult.next();
     }
-    
+
     @Override
     public Object getValue(final int columnIndex, final Class<?> type) throws SQLException {
-        Object value = mergedResult.getValue(columnIndex, type);
-        if (null == value || !queryWithCipherColumn) {
-            return value;
+        Optional<Encryptor> encryptor;
+        if (!queryWithCipherColumn || !(encryptor = metaData.findEncryptor(columnIndex)).isPresent()) {
+            return mergedResult.getValue(columnIndex, type);
         }
-        Optional<Encryptor> encryptor = metaData.findEncryptor(columnIndex);
-        return encryptor.isPresent() ? encryptor.get().decrypt(value.toString()) : value;
+        String ciphertext = (String) mergedResult.getValue(columnIndex, String.class);
+        return ciphertext == null ? null : encryptor.get().decrypt(ciphertext);
 
 Review comment:
   This should be `null == ciphertext` according to code style.

----------------------------------------------------------------
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] longjy commented on issue #3934: Get ciphertext column as a string

Posted by GitBox <gi...@apache.org>.
longjy commented on issue #3934: Get ciphertext column as a string
URL: https://github.com/apache/incubator-shardingsphere/pull/3934#issuecomment-573664656
 
 
   > Why close this pr?
   
   Misoperation, please help me reopen PR

----------------------------------------------------------------
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] longjy commented on a change in pull request #3934: Get ciphertext column as a string

Posted by GitBox <gi...@apache.org>.
longjy commented on a change in pull request #3934: Get ciphertext column as a string
URL: https://github.com/apache/incubator-shardingsphere/pull/3934#discussion_r365776178
 
 

 ##########
 File path: encrypt-core/encrypt-core-merge/src/main/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptMergedResult.java
 ##########
 @@ -44,15 +44,15 @@
     public boolean next() throws SQLException {
         return mergedResult.next();
     }
-    
+
     @Override
     public Object getValue(final int columnIndex, final Class<?> type) throws SQLException {
-        Object value = mergedResult.getValue(columnIndex, type);
-        if (null == value || !queryWithCipherColumn) {
-            return value;
+        Optional<Encryptor> encryptor;
+        if (!queryWithCipherColumn || !(encryptor = metaData.findEncryptor(columnIndex)).isPresent()) {
+            return mergedResult.getValue(columnIndex, type);
         }
-        Optional<Encryptor> encryptor = metaData.findEncryptor(columnIndex);
-        return encryptor.isPresent() ? encryptor.get().decrypt(value.toString()) : value;
+        String ciphertext = (String) mergedResult.getValue(columnIndex, String.class);
 
 Review comment:
   After verification, mysql is not a varchar field type, getString will not have a type exception. And encrypted field storage is generally varchar, Encryptor class
   String encrypt (Object plaintext) also returns String

----------------------------------------------------------------
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