| | |
| | | package com.hx.mybatis.aes.handler; |
| | | |
| | | import com.hx.mybatis.aes.springbean.VariableAesKey; |
| | | import com.hx.util.mysql.aes.MysqlHexAes; |
| | | import com.hx.util.mysql.aes.MysqlHexAesTool; |
| | | import org.apache.ibatis.type.BaseTypeHandler; |
| | | import org.apache.ibatis.type.JdbcType; |
| | | import org.apache.ibatis.type.MappedJdbcTypes; |
| | |
| | | @Override |
| | | public String getNullableResult(ResultSet rs, String columnName) throws SQLException { |
| | | String data = rs.getString(columnName); |
| | | if(data != null && data.length()%32==0 && MysqlHexAes.isHexStrValid(data)){ |
| | | if(data != null && data.length()%32==0 && MysqlHexAesTool.isHexStrValid(data)){ |
| | | try{ |
| | | data = MysqlHexAes.decryptData(data, VariableAesKey.getAesKey(columnName),null); |
| | | data = MysqlHexAesTool.decryptData(data, VariableAesKey.getAesKey(columnName),null); |
| | | }catch (Exception e){ |
| | | //e.printStackTrace(); |
| | | } |
| | |
| | | @Override |
| | | public String getNullableResult(ResultSet rs, int columnIndex) throws SQLException { |
| | | String data = rs.getString(columnIndex); |
| | | if(data != null && data.length()%32==0 && MysqlHexAes.isHexStrValid(data)){ |
| | | if(data != null && data.length()%32==0 && MysqlHexAesTool.isHexStrValid(data)){ |
| | | try{ |
| | | data = MysqlHexAes.decryptData(data, VariableAesKey.getAesKey(null),null); |
| | | data = MysqlHexAesTool.decryptData(data, VariableAesKey.getAesKey(null),null); |
| | | }catch (Exception e){ |
| | | //e.printStackTrace(); |
| | | } |
| | |
| | | @Override |
| | | public String getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { |
| | | String data = cs.getString(columnIndex); |
| | | if(data != null && data.length() < 129 && data.length()%32==0 && MysqlHexAes.isHexStrValid(data)){ |
| | | if(data != null && data.length() < 129 && data.length()%32==0 && MysqlHexAesTool.isHexStrValid(data)){ |
| | | try{ |
| | | data = MysqlHexAes.decryptData(data, VariableAesKey.getAesKey(null),null); |
| | | data = MysqlHexAesTool.decryptData(data, VariableAesKey.getAesKey(null),null); |
| | | }catch (Exception e){ |
| | | //e.printStackTrace(); |
| | | } |