01: /*
02: * JBoss, Home of Professional Open Source
03: * Copyright 2005, JBoss Inc., and individual contributors as indicated
04: * by the @authors tag. See the copyright.txt in the distribution for a
05: * full listing of individual contributors.
06: *
07: * This is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as
09: * published by the Free Software Foundation; either version 2.1 of
10: * the License, or (at your option) any later version.
11: *
12: * This software is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this software; if not, write to the Free
19: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21: */
22: package org.jboss.portal.cms.security;
23:
24: import org.jboss.portal.identity.User;
25:
26: import java.io.Serializable;
27: import java.util.HashMap;
28: import java.util.Map;
29:
30: /**
31: * An implementation of SecurityContext for the core Portal Engine
32: *
33: * @author Sohil Shah - sohil.shah@jboss.com - Nov 27, 2006
34: */
35: public class PortalCMSSecurityContext implements Serializable {
36: private Map contextMap = null;
37:
38: /** signifies the user currently logged in to the system */
39: private User portalUser = null;
40:
41: /**
42: *
43: *
44: */
45: public PortalCMSSecurityContext(User portalUser) {
46: super ();
47: this .portalUser = portalUser;
48: this .contextMap = new HashMap();
49: }
50:
51: /**
52: * This method returns the Identity of the user logged into the portal. The return value is of type
53: * org.jboss.portal.identity.User
54: *
55: * @return Identity related information associated with the user logged into the portal
56: */
57: public Object getIdentity() {
58: return this .portalUser;
59: }
60:
61: /**
62: * Returns value corresponding to the specified attribute name
63: *
64: * @param name
65: * @return
66: */
67: public Object getAttribute(String name) {
68: return this .contextMap.get(name);
69: }
70:
71: /**
72: * Sets a specified value corresponding to the specified name in the context
73: *
74: * @param name
75: * @param value
76: */
77: public void setAttribute(String name, Object value) {
78: this .contextMap.put(name, value);
79: }
80:
81: /**
82: * Removes the specified attribute
83: *
84: * @param name
85: */
86: public void removeAttribute(String name) {
87: this .contextMap.remove(name);
88: }
89:
90: /**
91: * Returns an array of Strings consisting of all keys/names stored in the context
92: *
93: * @return
94: */
95: public String[] getAttributeNames() {
96: return (String[]) this.contextMap.keySet().toArray();
97: }
98: }
|