IllegalStateException:没有FormAuthenticator Jetty的LoginService

时间:2018-04-19 21:28:03

标签: jetty jaas jetty-9

我在Jetty中配置自定义JAAS登录模块。

import org.eclipse.jetty.jaas.spi.AbstractLoginModule;

public class HybridLoginModule extends AbstractLoginModule

我将文件添加到:jetty-9.4.8/etc/login.conf

hybridRealm {
  net.sf.jkniv.jaas.jetty.HybridLoginModule required
}

启用ja:jetty-9.4.8/start.ini

--module=jaas
jetty.jaas.login.conf=etc/login.conf

jetty-9.4.8/etc/jetty-webapp.xml

中配置JAAS JAASLoginService
  <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>

但是当我启动jetty服务器java -jar start.jar时,抛出异常

IllegalStateException:没有FormAuthenticator的LoginService

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)

1 个答案:

答案 0 :(得分:0)

enter image description here The jetty documentation it's ambiguous,要解决配置问题,请将 web.xml 文件中的realm-name属性设置为<Set name="Name"> proprety的相同值,没有<Set name="LoginModuleName">

web.xml文件:

<realm-name>xyzREALM</realm-name>

jetty-webapp.xml文件:

<New class="org.eclipse.jetty.jaas.JAASLoginService">
  <Set name="Name">xyzREALM</Set>
  <Set name="LoginModuleName">hybridRealm</Set>
</New>