     (.info logger (str "Stopping www application."))
     (.. context getAttributes (get "org.altlaw.solr.core") close)))
 
+(defn make-admin-guard [context next]
+  (doto (Guard. context ChallengeScheme/HTTP_DIGEST
+                "AltLaw admin")
+    (.. getSecrets (put (context/admin-username)
+                        (.toCharArray (context/admin-password))))
+    (.setNext next)))
+
 (defn -createRoot [this]
   (let [context (.getContext this)
         static-finder (new org.altlaw.www.StaticFinder context)]

      (.attach "/v1/search" org.altlaw.www.SearchResource)
      (.attach "/v1/cases/{docid}/citations" org.altlaw.www.CitationsResource)
      (.attach "/v1/cases/{docid}" org.altlaw.www.DocResource)
      (.attach static-finder))))

  (:gen-class :extends org.restlet.Application
              :exposes-methods {start superStart
                                stop superStop})
  (:import (org.restlet Router Guard)
           (org.restlet.data ChallengeScheme))
  (:require org.altlaw.www.StaticFinder
            org.altlaw.www.CiteFinder
            org.altlaw.www.AllCasesFinder
            org.altlaw.www.SearchResource
            org.altlaw.www.CitationsResource
            org.altlaw.www.AdminNorobotsResource
            org.altlaw.www.DocResource
            org.altlaw.www.content-pages
            [org.altlaw.util.context :as context]
