javamavenjettyjaasmaven-jetty-plugin

How to specify JAAS config file with jetty-maven-plugin 10


I am trying to use jetty-maven-plugin in a dev environment. However, I am struggling to get JAAS to correctly pickup the login module configuration file.

The following is an excerpt from my pom.xml (I left commented parts to show variants which I have tried):

        <plugin>
          <groupId>org.eclipse.jetty</groupId>
          <artifactId>jetty-maven-plugin</artifactId>
          <version>10.0.2</version>
          <configuration>
            <webApp>
              <contextPath>/${project.build.finalName}</contextPath>
            </webApp>
            <contextXml>${project.basedir}/jetty-context.xml</contextXml>
            <stopKey>CTRL+C</stopKey>
            <stopPort>8999</stopPort>
            <scanIntervalSeconds>10</scanIntervalSeconds>
            <scanTargets>
              <scanTarget>src/main/webapp/WEB-INF/web.xml</scanTarget>
            </scanTargets>
            <!-- <systemProperties>
              <systemProperty>
                <name>jetty.jaas.login.conf</name>
                <value>${project.basedir}/jaas.conf</value>
              </systemProperty>
              <systemProperty>
                <name>java.security.auth.login.config</name>
                <value>${project.basedir}/jaas.conf</value>
              </systemProperty>
            </systemProperties> -->
            <jettyProperties>
              <jettyProperty>
                <name>jetty.jaas.login.conf</name>
                <value>${project.basedir}/jaas.conf</value>
              </jettyProperty>
            </jettyProperties>
          </configuration>

However, when running with mvn jetty:run it does not attempt to load the jaas.conf file. I have confirmed this by using strace:

$ strace -f mvn jetty:run 2>&1 | grep -i '\.conf'
...snip...
[pid 24242] openat(AT_FDCWD, "/etc/host.conf", O_RDONLY|O_CLOEXEC) = 165
[pid 24242] openat(AT_FDCWD, "/etc/resolv.conf", O_RDONLY|O_CLOEXEC) = 165
[pid 24270] stat("/home/myuser/.java.login.config",  <unfinished ...>

The final line where it tries to read the ~/.java.login.config file is the standard behaviour documented in ConfigFile when the java.security.auth.login.config system property is not set.

I can explicitly set this on the command line, but it its not an ideal solution:

mvn jetty:run -Djava.security.auth.login.config=jaas.conf

What is the correct way to configure this?


Solution

  • In case its of use to anyone, the solution to this was that systemProperties should have been specified as follows:

    <systemProperties>
     <java.security.auth.login.config>${project.basedir}/jaas.conf</java.security.auth.login.config>
    </systemProperties>