|
|
import java.io.IOException; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class CustomDataSource extends org.apache.tomcat.jdbc.pool.DataSource { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public synchronized void setPassword(String encodedPassword) { |
|
|
this.poolProperties.setPassword(AESUtils.decrypt(encodedPassword)); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public synchronized void setUsername(String encodedUsername) { |
|
|
this.poolProperties.setUsername(AESUtils.decrypt(encodedUsername)); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public synchronized void setUrl(String encodedUrl) { |
|
|
this.poolProperties.setUrl(AESUtils.decrypt(encodedUrl)); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void main(String args[]) throws IOException { |
|
|
|
|
|
if (args.length < 2) |
|
|
{ |
|
|
System.out.println("ArrayIndexOutOfBoundsException: 1, For Encrypt use command (sh encodeco.sh e '<input>') | For Decrypt use command (sh encodeco.sh d '<input>') | Note: Input must be in single quote" ); |
|
|
} |
|
|
else if (args[0].toString().equals("e")) |
|
|
{ |
|
|
System.out.println("Encrypted One"); |
|
|
System.out.println(AESUtils.encrypt(args[1].toString())); |
|
|
} |
|
|
else if (args[0].toString().equals("d")) |
|
|
{ |
|
|
System.out.println("Decrypted One"); |
|
|
System.out.println(AESUtils.decrypt(args[1].toString())); |
|
|
} |
|
|
} |
|
|
} |
|
|
|