1 16 17 package org.apache.tester; 18 19 20 import java.io.*; 21 import java.security.Principal ; 22 import javax.servlet.*; 23 import javax.servlet.http.*; 24 25 34 35 public class Authentication03 extends HttpServlet { 36 37 public void doGet(HttpServletRequest request, HttpServletResponse response) 38 throws IOException, ServletException { 39 40 response.setContentType("text/plain"); 42 PrintWriter writer = response.getWriter(); 43 StringBuffer results = new StringBuffer (); 44 45 String remoteUser = request.getRemoteUser(); 47 if (remoteUser == null) { 48 results.append(" Not Authenticated/"); 49 } else if (!"tomcat".equals(remoteUser)) { 50 results.append(" Authenticated as '"); 51 results.append(remoteUser); 52 results.append("'/"); 53 } 54 55 if (!request.isUserInRole("tomcat")) { 57 results.append(" Not in role 'tomcat'/"); 58 } 59 60 if (!request.isUserInRole("alias")) { 63 results.append(" Not in role 'alias'/"); 64 } 65 66 if (request.isUserInRole("unknown")) { 68 results.append(" In role 'unknown'/"); 69 } 70 71 if (results.length() < 1) { 73 writer.println("Authentication03 PASSED"); 74 } else { 75 writer.print("Authentication03 FAILED -"); 76 writer.println(results.toString()); 77 } 78 79 while (true) { 81 String message = StaticLogger.read(); 82 if (message == null) 83 break; 84 writer.println(message); 85 } 86 StaticLogger.reset(); 87 88 89 } 90 91 } 92 | Popular Tags |