I'm configuring a custom JAAS Login module in Jetty.
import org.eclipse.jetty.jaas.spi.AbstractLoginModule;
public class HybridLoginModule extends AbstractLoginModule
I add the file in: jetty-9.4.8/etc/login.conf
hybridRealm {
net.sf.jkniv.jaas.jetty.HybridLoginModule required
}
Enable the jaas in: jetty-9.4.8/start.ini
--module=jaas
jetty.jaas.login.conf=etc/login.conf
And config JAAS JAASLoginService in jetty-9.4.8/etc/jetty-webapp.xml
<Call name="addBean">
<Arg>
<New class="org.eclipse.jetty.jaas.JAASLoginService">
<Set name="name">Hybrid JAAS Realm</Set>
<Set name="LoginModuleName">hybridRealm</Set>
</New>
</Arg>
</Call>
But when I start jetty server java -jar start.jar
the exception is throw
IllegalStateException: No LoginService for FormAuthenticator
java.lang.IllegalStateException: No LoginService for org.eclipse.jetty.security.authentication.FormAuthenticator@25084a1e in org.eclipse.jetty.security.ConstraintSecurityHandler@156b88f5
at org.eclipse.jetty.security.authentication.LoginAuthenticator.setConfiguration(LoginAuthenticator.java:76)
at org.eclipse.jetty.security.authentication.FormAuthenticator.setConfiguration(FormAuthenticator.java:131)
The jetty documentation it's ambiguous, to solution the configuration problem set the
realm-name
property from web.xml file to same value from <Set name="Name">
proprety, no <Set name="LoginModuleName">
.
web.xml file:
<realm-name>xyzREALM</realm-name>
jetty-webapp.xml file:
<New class="org.eclipse.jetty.jaas.JAASLoginService">
<Set name="Name">xyzREALM</Set>
<Set name="LoginModuleName">hybridRealm</Set>
</New>