In the general database configuration file, the connection database is like this, and now the project needs to encrypt the password processing,
So we're going to rewrite the Org.apache.commons.dbcp.BasicDataSource class as follows:
Package com.joyintech.tisaccel.base;
Import Org.apache.commons.dbcp.BasicDataSource;
public class Teradataconnection extends Basicdatasource {
Public Teradataconnection () {
TODO auto-generated Constructor stub
Super ();
}
@Override
public void SetPassword (String password) {
try{
This.password = base64.decryptdata (password);
}catch (Exception e) {
}
}
}
We rewrote the SetPassword method of the class, using Base64.decryptdata (password) when assigning values to password, and decrypting the password, the encryption algorithm used here is
[Java]java Encryption decryption algorithm (based on org.apache.commons) source code details please see http://www.cuplayer.com/player/PlayerCodeAs/2015/01141756.html "turn"
After rewriting SetPassword, we can modify the database configuration as follows:
So we can access the database directly with ciphertext,