1 16 package org.mortbay.jetty.servlet; 17 18 import java.io.IOException ; 19 20 import org.mortbay.http.HttpFields; 21 import org.mortbay.http.HttpRequest; 22 import org.mortbay.http.HttpResponse; 23 import org.mortbay.http.UserRealm; 24 25 26 30 public class DigestAuthenticator extends org.mortbay.http.DigestAuthenticator 31 { 32 33 34 public void sendChallenge(UserRealm realm, 35 HttpRequest request, 36 HttpResponse response, 37 boolean stale) 38 throws IOException 39 { 40 response.setField(HttpFields.__WwwAuthenticate, 41 "Digest realm=\""+realm.getName()+ 42 "\", domain=\""+ 43 response.getHttpContext().getContextPath() + 44 "\", nonce=\""+newNonce(request)+ 45 "\", algorithm=MD5, qop=\"auth\"" + (useStale?(" stale="+stale):"") 46 ); 47 48 ServletHttpResponse sresponse = (ServletHttpResponse) response.getWrapper(); 49 if (sresponse!=null) 50 sresponse.sendError(HttpResponse.__401_Unauthorized); 51 else 52 response.sendError(HttpResponse.__401_Unauthorized); 53 } 54 } 55 | Popular Tags |