1 4 5 9 10 package org.openlaszlo.auth; 11 12 import org.openlaszlo.data.*; 13 import org.openlaszlo.server.*; 14 import org.openlaszlo.servlets.*; 15 import org.openlaszlo.utils.*; 16 import java.io.*; 17 import java.net.*; 18 import java.security.*; 19 import java.util.*; 20 import javax.servlet.http.*; 21 import org.apache.commons.httpclient.*; 22 import org.apache.commons.httpclient.methods.*; 23 import org.apache.log4j.*; 24 import org.jdom.*; 25 import org.jdom.input.*; 26 27 28 35 public class RoleAuthentication implements Authentication 36 { 37 38 protected static Logger mLogger = Logger.getLogger(RoleAuthentication.class); 39 40 public void init(Properties prop) 41 { 42 } 43 44 45 public int login(HttpServletRequest req, HttpServletResponse res, 46 HashMap param, StringBuffer xmlResponse) 47 { 48 49 mLogger.debug("login(req,res,param,xmlResponse)"); 50 String role = req.getParameter("role"); 51 return req.isUserInRole(role) ? 0 : 1; 52 } 53 54 public int logout(HttpServletRequest req, HttpServletResponse res, 55 HashMap param, StringBuffer xmlResponse) 56 { 57 58 mLogger.debug("logout(req,res,param,xmlResponse)"); 59 HttpSession sess = req.getSession(false); 61 if (sess == null) { 62 return 1; 63 } else { 64 req.getSession().invalidate(); 65 return 0; 66 } 67 } 68 69 70 public String getUsername(HttpServletRequest req, HttpServletResponse res, 71 HashMap param) 72 { 73 mLogger.debug("getUsername(req,res,param)"); 74 return req.getRemoteUser(); 75 } 76 77 } 78 | Popular Tags |