I just started storing all of my DB credentials in my WAR's context.xml
file, and loading them through JNDI. This way, my app can reuse the same credentials in multiple areas, and I can use JNDI to retrieve them (instead of sprinkling the credentials all over my codebase).
But now I'm thinking: what if an attacker gets onto the machine wehere my Tomcat server is installed? They could go straight to my webapps/MyApp exploded directory, find & open up the context.xml
directory, and voila - they can now access my database!
So what is the next step for introducing security here? Is there a way to keep all of my credentials in some keystore, and reference their labels from inside context.xml
? I still would like to use context.xml
so that my JDBC code can access the credentials through JNDI. If so, how does context.xml
access them in a secure way? What is the normal way of dealing with security here? Thanks in advance!