Question

I am following this tutorial instruction: http://www.eclipse.org/jetty/documentation/current/spnego-support.html

It says the following: A corresponding UserRealm needs to be created either programmatically if embedded, via the jetty.xml or in a context file for the webapp.

Now I am using embedded jetty and I could create a web.xml using the WebAppContext and \jee but what is the context file? Is it talking about something like a Spring context?

(I am fairly new to Java)

Was it helpful?

Solution

With context file for the webapp, they probably mean the jetty.xml configuration file, which can also be used on a per-app basis, when you name it jetty-web.xml and place it in your WEB-INF directory (alongside the web.xml configuration file).

Frame of a jetty-web.xml:

<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
    <!-- configuration here -->
</Configure>

You can configure your realms with it, e.g.:

<Configure class="org.eclipse.jetty.webapp.WebAppContext">
  <Set name="contextPath">/test</Set>
  <Set name="war"><SystemProperty name="jetty.home" default="."/>/webapps/test</Set>
  <Get name="securityHandler">
    <Set name="loginService">
      <New class="org.eclipse.jetty.security.HashLoginService">
            <Set name="name">Test Realm</Set>
            <Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties</Set>
      </New>
    </Set>
  </Get>
</Configure>

For details, see:

https://wiki.eclipse.org/Jetty/Reference/jetty-web.xml

https://wiki.eclipse.org/Jetty/Tutorial/Realms

Since you are using embedded jetty, I am unsure if you can configure user realms using the normal jetty-web.xml configuration, or if you have to set them up programmatically.

I did this programmatically, but with an older (6.1) version of Jetty. But I also have used the jetty-web.xml in an embedded jetty to configure some parameters, e.g. the upload file size limit.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top