Matt/ blog/ Hudson and Jetty, getting realms to work

I've been using Hudson at home and, as the build server is exposed to the interwebs, I want to secure the pages. However, Hudson doesn't have detailed instructions on how to do this. Turns out, it's not Hudson specific at all, but instead relies on how you set your container realms up.

This page tells you how to add the login-config to your web.xml (in this case, add it to jetty's webdefault.xml, since repackaing Hudson is sort of lame). Then you copy a realm into the jetty.xml file, probably looking like so :

<Set name="UserRealms">
  <Array type="org.mortbay.jetty.security.UserRealm">
    <Item>
      <New class="org.mortbay.jetty.security.HashUserRealm">
        <Set name="name">DefaultRealm</Set>
        <Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties</Set>
        <Set name="refreshInterval">5</Set>
      </New>
    </Item>
  </Array>
</Set>

Then you edit your realm.properties, and you should be good to go.