01: /* *****************************************************************************
02: * NullAuthentication.java
03: * ****************************************************************************/
04:
05: /* J_LZ_COPYRIGHT_BEGIN *******************************************************
06: * Copyright 2001-2004 Laszlo Systems, Inc. All Rights Reserved. *
07: * Use is subject to license terms. *
08: * J_LZ_COPYRIGHT_END *********************************************************/
09:
10: package org.openlaszlo.auth;
11:
12: import javax.servlet.http.*;
13: import java.util.*;
14:
15: public class NullAuthentication implements Authentication {
16: public static final String DEFAULT_USERNAME = "user";
17: public String mDefaultUserName = null;
18:
19: public void init(Properties prop) {
20: mDefaultUserName = prop.getProperty(
21: "connection.none-authenticator.username",
22: 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.append("<authentication>").append(
33: "<response type=\"login\">").append(
34: "<status code=\"0\" msg=\"ok\" />")
35: .append("<username>").append(usr).append("</username>")
36: .append("</response>").append("</authentication>");
37: return 0;
38: }
39:
40: public int logout(HttpServletRequest req, HttpServletResponse res,
41: HashMap param, StringBuffer xmlResponse) {
42: xmlResponse.append("<authentication>").append(
43: "<response type=\"logout\">").append(
44: "<status code=\"0\" msg=\"ok\" />").append(
45: "</response>").append("</authentication>");
46: return 0;
47: }
48:
49: public String getUsername(HttpServletRequest req,
50: HttpServletResponse res, HashMap param) {
51: String usr = (String) param.get("usr");
52: return (usr != null ? usr : mDefaultUserName);
53: }
54: }
|