001: /*
002: * Version: MPL 1.1/GPL 2.0/LGPL 2.1
003: *
004: * "The contents of this file are subject to the Mozilla Public License
005: * Version 1.1 (the "License"); you may not use this file except in
006: * compliance with the License. You may obtain a copy of the License at
007: * http://www.mozilla.org/MPL/
008: *
009: * Software distributed under the License is distributed on an "AS IS"
010: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
011: * License for the specific language governing rights and limitations under
012: * the License.
013: *
014: * The Original Code is ICEfaces 1.5 open source software code, released
015: * November 5, 2006. The Initial Developer of the Original Code is ICEsoft
016: * Technologies Canada, Corp. Portions created by ICEsoft are Copyright (C)
017: * 2004-2006 ICEsoft Technologies Canada, Corp. All Rights Reserved.
018: *
019: * Contributor(s): _____________________.
020: *
021: * Alternatively, the contents of this file may be used under the terms of
022: * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"
023: * License), in which case the provisions of the LGPL License are
024: * applicable instead of those above. If you wish to allow use of your
025: * version of this file only under the terms of the LGPL License and not to
026: * allow others to use your version of this file under the MPL, indicate
027: * your decision by deleting the provisions above and replace them with
028: * the notice and other provisions required by the LGPL License. If you do
029: * not delete the provisions above, a recipient may use your version of
030: * this file under either the MPL or the LGPL License."
031: *
032: */
033:
034: package com.icesoft.faces.env;
035:
036: import java.security.Principal;
037: import java.util.Collections;
038: import java.util.Enumeration;
039: import java.util.List;
040: import java.util.Locale;
041: import java.util.Map;
042:
043: /**
044: * This is an abstract class that contains fields and method implementations
045: * that are common to any request type class that is environmentally dependent.
046: * Currently this includes both servlets (ServletEnvironmentRequest) and
047: * portlets (PortletEnvironmentRenderRequest).
048: */
049: public abstract class CommonEnvironmentRequest {
050: protected String authType;
051: protected String remoteUser;
052: protected Principal userPrincipal;
053: protected String requestedSessionId;
054: protected boolean requestedSessionIdValid;
055: protected String scheme;
056: protected String serverName;
057: protected int serverPort;
058: protected Locale locale;
059: protected boolean secure;
060: protected String contextPath;
061: protected List locales;
062: protected Map attributes;
063: protected Map parameters;
064:
065: public String getAuthType() {
066: return authType;
067: }
068:
069: public String getContextPath() {
070: return contextPath;
071: }
072:
073: public String getRemoteUser() {
074: return remoteUser;
075: }
076:
077: public Principal getUserPrincipal() {
078: return userPrincipal;
079: }
080:
081: public String getRequestedSessionId() {
082: return requestedSessionId;
083: }
084:
085: public boolean isRequestedSessionIdValid() {
086: return requestedSessionIdValid;
087: }
088:
089: public Object getAttribute(String name) {
090: return attributes.get(name);
091: }
092:
093: public Enumeration getAttributeNames() {
094: return Collections.enumeration(attributes.keySet());
095: }
096:
097: public String getParameter(String name) {
098: Object value = parameters.get(name);
099: if (value instanceof String[]) {
100: return ((String[]) value)[0];
101: } else {
102: return (String) value;
103: }
104: }
105:
106: public Enumeration getParameterNames() {
107: return Collections.enumeration(parameters.keySet());
108: }
109:
110: public String[] getParameterValues(String name) {
111: return (String[]) parameters.get(name);
112: }
113:
114: public Map getParameterMap() {
115: return parameters;
116: }
117:
118: public String getScheme() {
119: return scheme;
120: }
121:
122: public String getServerName() {
123: return serverName;
124: }
125:
126: public int getServerPort() {
127: return serverPort;
128: }
129:
130: public void setAttribute(String name, Object value) {
131: if (null == value) {
132: attributes.remove(name);
133: } else {
134: attributes.put(name, value);
135: }
136: }
137:
138: public void removeAttribute(String name) {
139: attributes.remove(name);
140: }
141:
142: public Locale getLocale() {
143: return locale;
144: }
145:
146: public Enumeration getLocales() {
147: return Collections.enumeration(locales);
148: }
149:
150: public boolean isSecure() {
151: return secure;
152: }
153: }
|