1 4 5 9 10 package org.openlaszlo.auth; 11 12 import javax.servlet.http.*; 13 import java.util.*; 14 15 public class NullAuthentication implements Authentication 16 { 17 public static final String DEFAULT_USERNAME = "user"; 18 public String mDefaultUserName = null; 19 20 public void init(Properties prop) { 21 mDefaultUserName = 22 prop.getProperty("connection.none-authenticator.username", DEFAULT_USERNAME); 23 } 24 25 public int login(HttpServletRequest req, HttpServletResponse res, 26 HashMap param, StringBuffer xmlResponse) { 27 28 String usr = (String ) param.get("usr"); 29 if (usr == null) 30 usr = mDefaultUserName; 31 32 xmlResponse 33 .append("<authentication>") 34 .append("<response type=\"login\">") 35 .append("<status code=\"0\" msg=\"ok\" />") 36 .append("<username>").append(usr).append("</username>") 37 .append("</response>") 38 .append("</authentication>"); 39 return 0; 40 } 41 42 43 public int logout(HttpServletRequest req, HttpServletResponse res, 44 HashMap param, StringBuffer xmlResponse) { 45 xmlResponse 46 .append("<authentication>") 47 .append("<response type=\"logout\">") 48 .append("<status code=\"0\" msg=\"ok\" />") 49 .append("</response>") 50 .append("</authentication>"); 51 return 0; 52 } 53 54 55 public String getUsername(HttpServletRequest req, HttpServletResponse res, 56 HashMap param) 57 { 58 String usr = (String ) param.get("usr"); 59 return (usr!=null ? usr : mDefaultUserName); 60 } 61 } 62 | Popular Tags |