Question: I'm trying to use JAAS for authentication in my WAR. I understand that my [configuration file](http://download.oracle.com/javase/6/docs/api/javax/security/auth/login/Configuration.html) ([another link](http://download.oracle.com/javase/6/docs/jre/api/security/jaas/spec/com/sun/security/auth/login/ConfigFile.html)) should be placed somewhere (as explained [here](http://download.oracle.com/javase/6/docs/technotes/guides/security/jaas/tutorials/GeneralAcnOnly.html#ConfigFile)). Unfortunately, I can't understand where exactly, if we're talking about WAR? And how to name the file?

```
// JAAS has to find the file and retrieve "foo" from it
LoginContext ctx = new LoginContext("foo", this);

```

Answer: 
You can encapsulate the client\_jaas.conf in the jar, and use the code to specify the configuration dynamically

```java
System.setProperty("java.security.auth.login.config", XXX.class.getClassLoader().getResource("client_jaas.conf").toString());

```
Unfortunately the only way I was able to get it to work was to create a file `jass.conf` and specify it using either:

* In the Tomcat java parameters:

```
-Djava.security.auth.login.config==c:\\path\\To\\file.conf

```
* or from within the Java code:

```
System.setProperty("java.security.auth.login.config","c:\\path\\To\\file.conf");

```

I'd also like to know a better way to specify the configuration. I want to package that configuration in my WAR.