views:

453

answers:

2

I'd like to read a properties file in my applications WEB-INF folder or my tomcat/apache server from a JAAS loginModule. But I'm not understanding how to properly refer to the location from the LoginModule, in a host name independent manner.

A: 

Can't you put your properties in login.conf instead of in a properties file?

Maurice Perry
I already have properties in the login.conf file but I wanted to use the same properties file as my spring application so as to reduce the amount of configuration proliferation i'm experiencing.
Martlark
+1  A: 

You could use the catalina.base system property:

File confDir = new File(System.getProperty("catalina.base"), "conf");
File confFile = new File(confDir, "myprops.properties");
InputStream in = new FileInputStream(confFile);
try {
    props.load(in);
} finally {
    in.close();
}
Maurice Perry
Nice solution. Thanks for your help.
Martlark