Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] Jetty custom LoginService question

Can anyone point me to a working example of a custom LoginService for Jetty?

I am just trying to do something as simple as making a copy of HashLoginService in a package in my project then reference that class from jetty-web.xml. When I do so, I always get:

2017-05-23 21:16:36.511:WARN:oejw.WebAppContext:main: Failed startup of context o.e.j.w.WebAppContext@60c6f5b{/,file:///D:/jetty-distribution-9.4.2.v2
0170220/webapps/a5-1.0-SNAPSHOT/,UNAVAILABLE}{D:\jetty-distribution-9.4.2.v20170220\webapps\a5-1.0-SNAPSHOT}
java.lang.NoSuchMethodException: class org.eclipse.jetty.security.ConstraintSecurityHandler.setAuthenticator(class org.eclipse.jetty.security.authenti
cation.FormAuthenticator)
        at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.set(XmlConfiguration.java:593)
        at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:411)
        at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.get(XmlConfiguration.java:675)
        at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:420)

OR

java.lang.NoSuchMethodException: class org.eclipse.jetty.security.ConstraintSecu
rityHandler.setLoginService(class org.overlord.fta.login.MyLoginService)
        at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.set(XmlC
onfiguration.java:579)
        at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configur
e(XmlConfiguration.java:384)

Is this some classloader issue that I'm not understanding? Can anyone help me get a custom LoginService working? Thanks so much!

I have tried the code at the following github project which is similar to my project setup but that doesn't work either (same errors). https://github.com/EricWittmann/fuse-test-apps/tree/master/fta-custom-login-service-war

Below is my jetty-web.xml:

  <Get name="securityHandler">
    <Set name="loginService">
      <!-- THIS WORKS USING JETTY'S HASHLOGINSERVICE -->
      <New class="org.eclipse.jetty.security.HashLoginService">
        <Set name="name">testrealm</Set>
        <Set name="config">
        <SystemProperty name="jetty.base"
                        default="." />/etc/realm.properties</Set>
      </New>   
      <!-- THIS WON'T WORK USING MY HASHLOGINSERVICE -->   
      <!--New class="com.mysite.HashLoginService">
        <Set name="name">testrealm</Set>
        <Set name="config">
        <SystemProperty name="jetty.base"
                        default="." />/etc/realm.properties</Set>
      </New-->
  </Get>

Back to the top