Basic authentication web resource package com.ack.web.servlet; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * Securing a web application with basic HTTP authentication * has been reduced to a configuration within web.xml * * to test: http://localhost/ack/servlet/protected/footie/get_time * footie_time com.ack.web.servlet.BasicAuthenticationWebResource footie_time /protected/footie/get_time protected_zone /protected/footie/* GET POST PUT DELETE HEAD OPTIONS TRACE footie NONE BASIC pure genius football club the footie guys footie * * finally we need to map from the 'footie' role name to the * security principal with the application server, in weblogic * we do the following within the supporting weblogic.xml file: * * footie cleve */ public class BasicAuthenticationWebResource extends HttpServlet { public void doGet( HttpServletRequest req, HttpServletResponse res ) throws ServletException, IOException { res.setContentType( "text/html" ); PrintWriter pw = res.getWriter(); pw.println( "21:00 @ The Wandle Centre, Wandsworth" ); pw.println( "
don't be late!" ); } }