I have implement a simple JAAS module with realm configuration on Tomcat 7. It works properly when specifying the jaas.conf file in the catalina.sh like so
JAVA_OPTS=$JAVA_OPTS "-Djava.security.auth.login.config==$CATALINA_BASE/conf/jaas.config"
However, I wanted to simplify my application by adding this config file internally to the web application. Documentation states that you can use the configFile param
"The name of a JAAS configuration file to use with this Realm. It will be searched for using ClassLoader#getResource(String) so it is possible for the configuration to be bundled within a web application. If not specified, the default JVM global JAAS configuration will be used."
My context.xml in my web app:
<Realm appName="AppLogin" className="org.apache.catalina.realm.JAASRealm" configFile="WEB-INF/jaas.config" ...../>
The config file is located /WEB-INF/jaas.config
Why is my jaas config file not being loaded?
It will be searched for using
ClassLoader#getResource(String)
Then you need to put JAAS configuration file in the classpath: WEB-INF/classes
or WEB-INF/lib
but not WEB-INF
directly.
And specify only the file name as it is written in the documentation:
configFile
- The name of a JAAS configuration file to use with this Realm.