01: /*
02: * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
03: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
04: */
05: package com.sun.portal.desktop.context;
06:
07: import javax.servlet.http.Cookie;
08: import javax.servlet.http.HttpServletRequest;
09: import java.util.Hashtable;
10:
11: /**
12: * This class implements the SessionContext interface using
13: * Properties attributes.
14: */
15: class PropertiesSessionContext implements SessionContext {
16: private Hashtable props = new Hashtable();
17:
18: private String portalId = null;
19:
20: public PropertiesSessionContext() {
21: }
22:
23: public void init(HttpServletRequest req, String portalId) {
24: if (portalId != null && portalId.length() != 0) {
25: this .portalId = portalId;
26: }
27: }
28:
29: public String getStringProperty(String name) {
30: name = portalId == null ? name : (portalId + "." + name);
31: String val = (String) props.get(name);
32: if (val == null) {
33: if ("lastChannelName" == name) {
34: val = "desktopDesktopTabContainer";
35: }
36: }
37: log("PropertiesSessionContext.getStringProperty(" + name
38: + ") = " + val);
39: return val;
40: }
41:
42: public void setStringProperty(String name, String val) {
43: name = portalId == null ? name : (portalId + "." + name);
44: log("PropertiesSessionContext.setStringProperty(" + name + ", "
45: + val + ")");
46: props.put(name, val);
47: }
48:
49: /*
50: * Validates user session by checking SSOToken.
51: */
52: public boolean validateSession(HttpServletRequest req) {
53: return true;
54: }
55:
56: public String getSessionID() {
57: return "sessionid";
58: }
59:
60: public String getUserID() {
61: return "userid";
62: }
63:
64: public void addSessionListener(SessionListener sl) {
65: }
66:
67: public void addUserReference() {
68: }
69:
70: public void addUserListener(UserListener sl) {
71: }
72:
73: public String encodeURL(String url) {
74:
75: return url;
76:
77: }
78:
79: public void log(String msg) {
80: System.out.println(msg);
81: }
82:
83: public String getAuthenticationType() {
84: return "desktop.properties";
85: }
86:
87: /* Properties that are stored as Cookie on client browser.
88: * AuthlessAnonymous user state is managed via such cookie.
89: * Authenticated users use AM/DSAME session to manage user state, returns null in such case.
90: */
91: public Cookie getClientProperties() {
92: return null;
93: }
94: }
|