0

I use the jsqlparser framework to intercept the SQL launched by the client program on a MySQL database.

I would like that for some fields (columns) during the insertion / update, I use AES_ENCRYPT on parameter (?) And the same, I use of AES_DECRYPT during the selection (SELECT).

Any idea for this using "ExpressionDeParser" or other function?

Example

Insertion :

insert into customer (id, name) values (?,?) => insert into customer (id, name) values (?, AES_ENCRYPT (?));

Selection: SELECT id, name from customer ;=> SELECT id, AES_DECRYPT (name) from customer;

Thanks,

Ardile
  • 9
  • You have to write a visitor that replaces the columns with a functions you like. I could not see, how you decide in your insert sql, which column to decrypt and which one not. Maybe there is more logic needed. – wumpz Apr 19 '18 at 10:18
  • Thanks for reply, I have a couple of table / column containing the fields to encrypt / decrypt. If the fields are present in the statement, it must be replaced. But how to know if column is on "SELECT" or "WHERE" or "ORDER BY" on visitor method :public void visit(Column tableColumn) { ...} ? Thanks – Ardile Apr 20 '18 at 11:47
  • You have to track the position with some kind of stack or you start the visitor at specific positions of the parsed sql. – wumpz May 01 '18 at 22:35

0 Answers0