-/*
- * Copyright (C) 2001, 2002 The Mir-coders group
- *
- * This file is part of Mir.
- *
- * Mir is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Mir is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Mir; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with any library licensed under the Apache Software License,
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
- * (or with modified versions of the above that use the same license as the above),
- * and distribute linked combinations including the two. You must obey the
- * GNU General Public License in all respects for all of the code used other than
- * the above mentioned libraries. If you modify this file, you may extend this
- * exception to your version of the file, but you are not obligated to do so.
- * If you do not wish to do so, delete this exception statement from your version.
- */
-package mir.session;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.Vector;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import org.apache.commons.fileupload.FileItem;
-
-import mir.util.HTTPParsedRequest;
-
-public class HTTPAdapters {
- public static class HTTPRequestAdapter implements Request {
- private HttpServletRequest request;
-
- public HTTPRequestAdapter(HttpServletRequest aRequest) {
- request = aRequest;
- }
-
- public String getHeader(String aHeaderName) {
- return request.getHeader(aHeaderName);
- };
-
- public String getParameter(String aName) {
- return request.getParameter(aName);
- };
-
- public List getUploadedFiles() {
- return new Vector();
- };
-
- public List getParameters(String aName) {
- return Arrays.asList(request.getParameterValues(aName));
- };
-
- public HttpServletRequest getRequest() {
- return request;
- }
- }
-
- public static class HTTPParsedRequestAdapter implements Request {
- private HTTPParsedRequest request;
-
- public HTTPParsedRequestAdapter(HTTPParsedRequest aRequest) {
- request = aRequest;
- }
-
- public String getHeader(String aHeaderName) {
- return request.getHeader(aHeaderName);
- };
-
- public String getParameter(String aName) {
- return request.getParameter(aName);
- };
-
- public List getParameters(String aName) {
- return request.getParameterList(aName);
- };
-
- public List getUploadedFiles() {
- List result = new Vector();
- List files = request.getFiles();
-
- for (int i=0; i<files.size(); i++) {
- result.add(new CommonsUploadedFileAdapter((FileItem) files.get(i)));
- }
-
- return result;
- };
-
- public HttpServletRequest getRequest() {
- return request.getRequest();
- }
- }
-
- public static class HTTPSessionAdapter implements Session {
- private HttpSession session;
-
- public HTTPSessionAdapter(HttpSession aSession) {
- session = aSession;
- }
- public Object getAttribute(String aName) {
- return session.getAttribute(aName);
- }
-
- public void deleteAttribute(String aName) {
- session.removeAttribute(aName);
- }
-
- public void setAttribute(String aName, Object aNewValue) {
- if (aNewValue==null)
- deleteAttribute(aName);
- else
- session.setAttribute(aName, aNewValue);
- }
-
- public void terminate() {
- session.invalidate();
- }
- }
+/*\r
+ * Copyright (C) 2001, 2002 The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two. You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries. If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+package mir.session;\r
+\r
+import java.util.Arrays;\r
+import java.util.List;\r
+import java.util.Vector;\r
+import javax.servlet.http.HttpServletRequest;\r
+import javax.servlet.http.HttpSession;\r
+\r
+import org.apache.commons.fileupload.FileItem;\r
+\r
+import mir.util.HTTPParsedRequest;\r
+\r
+public class HTTPAdapters {\r
+ public static class HTTPRequestAdapter implements Request {\r
+ private HttpServletRequest request;\r
+\r
+ public HTTPRequestAdapter(HttpServletRequest aRequest) {\r
+ request = aRequest;\r
+ }\r
+\r
+ public String getHeader(String aHeaderName) {\r
+ if (aHeaderName.equals("ip"))\r
+ return request.getRemoteAddr();\r
+\r
+ return request.getHeader(aHeaderName);\r
+ };\r
+\r
+ public String getParameter(String aName) {\r
+ return request.getParameter(aName);\r
+ };\r
+\r
+ public List getUploadedFiles() {\r
+ return new Vector();\r
+ };\r
+\r
+ public List getParameters(String aName) {\r
+ return Arrays.asList(request.getParameterValues(aName));\r
+ };\r
+\r
+ public HttpServletRequest getRequest() {\r
+ return request;\r
+ }\r
+ }\r
+\r
+ public static class HTTPParsedRequestAdapter implements Request {\r
+ private HTTPParsedRequest request;\r
+\r
+ public HTTPParsedRequestAdapter(HTTPParsedRequest aRequest) {\r
+ request = aRequest;\r
+ }\r
+\r
+ public String getHeader(String aHeaderName) {\r
+ if (aHeaderName.equals("ip"))\r
+ return request.getRequest().getRemoteAddr();\r
+\r
+ return request.getHeader(aHeaderName);\r
+ };\r
+\r
+ public String getParameter(String aName) {\r
+ return request.getParameter(aName);\r
+ };\r
+\r
+ public List getParameters(String aName) {\r
+ return request.getParameterList(aName);\r
+ };\r
+\r
+ public List getUploadedFiles() {\r
+ List result = new Vector();\r
+ List files = request.getFiles();\r
+\r
+ for (int i=0; i<files.size(); i++) {\r
+ result.add(new CommonsUploadedFileAdapter((FileItem) files.get(i)));\r
+ }\r
+\r
+ return result;\r
+ };\r
+\r
+ public HttpServletRequest getRequest() {\r
+ return request.getRequest();\r
+ }\r
+ }\r
+\r
+ public static class HTTPSessionAdapter implements Session {\r
+ private HttpSession session;\r
+\r
+ public HTTPSessionAdapter(HttpSession aSession) {\r
+ session = aSession;\r
+ }\r
+ public Object getAttribute(String aName) {\r
+ return session.getAttribute(aName);\r
+ }\r
+\r
+ public void deleteAttribute(String aName) {\r
+ session.removeAttribute(aName);\r
+ }\r
+\r
+ public void setAttribute(String aName, Object aNewValue) {\r
+ if (aName.equals("$httpsessiontimeout")) {\r
+ if (aNewValue instanceof Number) {\r
+ try {\r
+ session.setMaxInactiveInterval( ( (Number) aNewValue).intValue());\r
+ }\r
+ catch (Throwable t) {\r
+ }\r
+ }\r
+ }\r
+ else {\r
+ if (aNewValue == null)\r
+ deleteAttribute(aName);\r
+ else\r
+ session.setAttribute(aName, aNewValue);\r
+ }\r
+ }\r
+\r
+ public void terminate() {\r
+ session.invalidate();\r
+ }\r
+ }\r
}
\ No newline at end of file