Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The data decrypt failure when I use mysql's blob field #3647

Closed
minghu-zhang opened this issue Dec 3, 2019 · 5 comments
Closed

The data decrypt failure when I use mysql's blob field #3647

minghu-zhang opened this issue Dec 3, 2019 · 5 comments
Labels

Comments

@minghu-zhang
Copy link
Contributor

@minghu-zhang minghu-zhang commented Dec 3, 2019

Sharding-encrypt doesn't work when I use Msql‘s blob field. There is a problem with the following code :

StreamQueryResult.java

private String getCiphertext(final Object value) {
    return null == value ? null : value.toString();   //Blob.toString() ?
}

Here is type convert code :

QueryResultUtil.java

private static Object getValueByColumnType(final ResultSet resultSet, final int columnIndex) throws SQLException {
ResultSetMetaData metaData = resultSet.getMetaData();
switch (metaData.getColumnType(columnIndex)) {
...
case Types.CLOB:
return resultSet.getClob(columnIndex);
case Types.BLOB:
case Types.BINARY:
case Types.VARBINARY:
case Types.LONGVARBINARY:
return resultSet.getBlob(columnIndex);
default:
return resultSet.getObject(columnIndex);
}
}

@terrymanu

This comment has been minimized.

Copy link
Member

@terrymanu terrymanu commented Dec 3, 2019

Can you change the title for search friendly?

@minghu-zhang minghu-zhang changed the title sharding-encrypt value The data decrypt failure when I use mysql's blob field Dec 3, 2019
@minghu-zhang

This comment has been minimized.

Copy link
Contributor Author

@minghu-zhang minghu-zhang commented Dec 3, 2019

I have annother problem when use mybatis, mybatis need driver support jdbc's api 4.2, but sharding's EncryptResultSet doesn't support . the text field is handle by mybatis ClobTypeHandler, sharding‘s handler result is String, the following code :

EncryptResultSet.java:339

@override
public Clob getClob(final String columnLabel) throws SQLException {
return (Clob) resultSet.getValue(getActualColumnLabel(columnLabel), Clob.class);
//
}

StreamQueryResult.java:74

@Override
public Object getValue(final String columnLabel, final Class<?> type) throws SQLException {
    // This type value is not used 
    return decrypt(columnLabel, QueryResultUtil.getValue(resultSet, queryResultMetaData.getColumnIndex(columnLabel)));
}
@terrymanu

This comment has been minimized.

Copy link
Member

@terrymanu terrymanu commented Dec 3, 2019

We have no plan to add encrypt feature to type blob, do you want add this feature? @minghu-zhang

@minghu-zhang

This comment has been minimized.

Copy link
Contributor Author

@minghu-zhang minghu-zhang commented Dec 4, 2019

We have no plan to add encrypt feature to type blob, do you want add this feature? @minghu-zhang

Ok,I'll try to add it

@minghu-zhang

This comment has been minimized.

Copy link
Contributor Author

@minghu-zhang minghu-zhang commented Dec 4, 2019

We have no plan to add encrypt feature to type blob, do you want add this feature? @minghu-zhang

Thank you very much. These problems have been fixed when I download the latest code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.