Author: julien_viet
Date: 2010-09-28 12:19:26 -0400 (Tue, 28 Sep 2010)
New Revision: 4412
Added:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/RegisterPortletApplicationController.java
Removed:
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/CaptchaServlet.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/BaseHttpRequestWrapper.java
Modified:
portal/trunk/examples/portal/war/src/main/webapp/WEB-INF/web.xml
portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/portlet.xml
portal/trunk/web/portal/src/main/webapp/WEB-INF/web.xml
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/HttpRequestWrapper.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/CaptchaValidator.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/UICaptcha.java
Log:
GTNPORTAL-1503 : Implement Captcha image as a portlet resource serving
Deleted:
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/CaptchaServlet.java
===================================================================
---
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/CaptchaServlet.java 2010-09-28
13:09:32 UTC (rev 4411)
+++
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/CaptchaServlet.java 2010-09-28
16:19:26 UTC (rev 4412)
@@ -1,88 +0,0 @@
-/******************************************************************************
- * JBoss by Red Hat *
- * Copyright 2010, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software 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 *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.exoplatform.web.security;
-
-import static nl.captcha.Captcha.NAME;
-
-import java.io.IOException;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-
-import nl.captcha.Captcha;
-import nl.captcha.servlet.CaptchaServletUtil;
-
-/**
- * @author <a href="mailto:theute@redhat.com">Thomas Heute</a>
- * @version $Revision$
- */
-public class CaptchaServlet extends HttpServlet
-{
-
- private static final long serialVersionUID = 1L;
-
- private static final String PARAM_HEIGHT = "height";
-
- private static final String PARAM_WIDTH = "width";
-
- protected int _width = 200;
-
- protected int _height = 50;
-
- @Override
- public void init() throws ServletException
- {
- if (getInitParameter(PARAM_HEIGHT) != null)
- {
- _height = Integer.valueOf(getInitParameter(PARAM_HEIGHT));
- }
-
- if (getInitParameter(PARAM_WIDTH) != null)
- {
- _width = Integer.valueOf(getInitParameter(PARAM_WIDTH));
- }
- }
-
- @Override
- public void doGet(HttpServletRequest req, HttpServletResponse resp) throws
ServletException, IOException
- {
- HttpSession session = req.getSession();
- Captcha captcha;
- if (session.getAttribute(NAME) == null)
- {
- captcha = new Captcha.Builder(_width,
_height).addText().gimp().addNoise().addBackground().build();
-
- session.setAttribute(NAME, captcha);
- CaptchaServletUtil.writeImage(resp, captcha.getImage());
-
- return;
- }
-
- captcha = (Captcha) session.getAttribute(NAME);
- CaptchaServletUtil.writeImage(resp, captcha.getImage());
- }
-
-}
Modified: portal/trunk/examples/portal/war/src/main/webapp/WEB-INF/web.xml
===================================================================
--- portal/trunk/examples/portal/war/src/main/webapp/WEB-INF/web.xml 2010-09-28 13:09:32
UTC (rev 4411)
+++ portal/trunk/examples/portal/war/src/main/webapp/WEB-INF/web.xml 2010-09-28 16:19:26
UTC (rev 4412)
@@ -186,24 +186,6 @@
<load-on-startup>0</load-on-startup>
</servlet>
- <servlet>
- <servlet-name>StickyCaptcha</servlet-name>
-
<servlet-class>org.exoplatform.web.security.CaptchaServlet</servlet-class>
- <init-param>
- <param-name>width</param-name>
- <param-value>200</param-value>
- </init-param>
- <init-param>
- <param-name>height</param-name>
- <param-value>75</param-value>
- </init-param>
- </servlet>
-
- <servlet-mapping>
- <servlet-name>StickyCaptcha</servlet-name>
- <url-pattern>/captcha</url-pattern>
- </servlet-mapping>
-
<!-- ================================================================= -->
<servlet-mapping>
<servlet-name>InitiateLoginServlet</servlet-name>
Added:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/RegisterPortletApplicationController.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/RegisterPortletApplicationController.java
(rev 0)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/RegisterPortletApplicationController.java 2010-09-28
16:19:26 UTC (rev 4412)
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.account.webui.component;
+
+import nl.captcha.Captcha;
+import nl.captcha.servlet.CaptchaServletUtil;
+import org.exoplatform.webui.application.portlet.PortletApplicationController;
+
+import javax.portlet.PortletException;
+import javax.portlet.PortletSession;
+import javax.portlet.ResourceRequest;
+import javax.portlet.ResourceResponse;
+import javax.portlet.ResourceServingPortlet;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+
+import static nl.captcha.Captcha.NAME;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+public class RegisterPortletApplicationController extends PortletApplicationController
implements ResourceServingPortlet
+{
+
+ private static final String PARAM_HEIGHT = "height";
+
+ private static final String PARAM_WIDTH = "width";
+
+ protected int _width = 200;
+
+ protected int _height = 50;
+
+ @Override
+ public void init() throws PortletException
+ {
+ if (getInitParameter(PARAM_HEIGHT) != null)
+ {
+ _height = Integer.valueOf(getInitParameter(PARAM_HEIGHT));
+ }
+
+ if (getInitParameter(PARAM_WIDTH) != null)
+ {
+ _width = Integer.valueOf(getInitParameter(PARAM_WIDTH));
+ }
+ }
+
+ public void serveResource(ResourceRequest req, ResourceResponse resp)
+ throws PortletException, java.io.IOException
+ {
+ PortletSession session = req.getPortletSession();
+ Captcha captcha;
+ if (session.getAttribute(NAME) == null)
+ {
+ captcha = new Captcha.Builder(_width,
_height).addText().gimp().addNoise().addBackground().build();
+
+
+ session.setAttribute(NAME, captcha);
+ writeImage(resp, captcha.getImage());
+
+ return;
+ }
+
+ captcha = (Captcha)session.getAttribute(NAME);
+ writeImage(resp, captcha.getImage());
+
+ }
+
+ public static void writeImage(ResourceResponse response, BufferedImage bi)
+ {
+ response.setProperty("Cache-Control",
"private,no-cache,no-store");
+ response.setContentType("image/png"); // PNGs allow for transparency.
JPGs do not.
+ try
+ {
+ CaptchaServletUtil.writeImage(response.getPortletOutputStream(), bi);
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+}
Modified: portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/portlet.xml
===================================================================
--- portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/portlet.xml 2010-09-28 13:09:32
UTC (rev 4411)
+++ portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/portlet.xml 2010-09-28 16:19:26
UTC (rev 4412)
@@ -85,12 +85,20 @@
<description xml:lang="EN">Register Portlet</description>
<portlet-name>RegisterPortlet</portlet-name>
<display-name xml:lang="EN">Register Portlet</display-name>
-
<portlet-class>org.exoplatform.webui.application.portlet.PortletApplicationController</portlet-class>
+
<portlet-class>org.exoplatform.account.webui.component.RegisterPortletApplicationController</portlet-class>
<init-param>
<name>webui.configuration</name>
<value>/WEB-INF/conf/portlet/exoadmin/RegisterPortlet/webui/configuration.xml</value>
</init-param>
+ <init-param>
+ <name>width</name>
+ <value>200</value>
+ </init-param>
+ <init-param>
+ <name>height</name>
+ <value>75</value>
+ </init-param>
<expiration-cache>0</expiration-cache>
<supports>
Modified: portal/trunk/web/portal/src/main/webapp/WEB-INF/web.xml
===================================================================
--- portal/trunk/web/portal/src/main/webapp/WEB-INF/web.xml 2010-09-28 13:09:32 UTC (rev
4411)
+++ portal/trunk/web/portal/src/main/webapp/WEB-INF/web.xml 2010-09-28 16:19:26 UTC (rev
4412)
@@ -226,25 +226,6 @@
<load-on-startup>0</load-on-startup>
</servlet>
- <servlet>
- <servlet-name>StickyCaptcha</servlet-name>
-
<servlet-class>org.exoplatform.web.security.CaptchaServlet</servlet-class>
- <init-param>
- <param-name>width</param-name>
- <param-value>200</param-value>
- </init-param>
- <init-param>
- <param-name>height</param-name>
- <param-value>75</param-value>
- </init-param>
- </servlet>
-
- <servlet-mapping>
- <servlet-name>StickyCaptcha</servlet-name>
- <url-pattern>/captcha</url-pattern>
- </servlet-mapping>
-
-
<!-- ================================================================= -->
<servlet-mapping>
<servlet-name>InitiateLoginServlet</servlet-name>
Deleted:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/BaseHttpRequestWrapper.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/BaseHttpRequestWrapper.java 2010-09-28
13:09:32 UTC (rev 4411)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/BaseHttpRequestWrapper.java 2010-09-28
16:19:26 UTC (rev 4412)
@@ -1,497 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.exoplatform.portal.application.localization;
-
-import javax.servlet.RequestDispatcher;
-import javax.servlet.ServletInputStream;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.security.Principal;
-import java.util.Enumeration;
-import java.util.Locale;
-import java.util.Map;
-
-/**
- * This class is an alternative for {@link
javax.servlet.http.HttpServletRequestWrapper}.
- * One reason for favoring it is to avoid situations when servlet container decides to
replace
- * the delegate via {@link
javax.servlet.ServletRequestWrapper#setRequest(javax.servlet.ServletRequest)}.
- *
- * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
- */
-public class BaseHttpRequestWrapper implements HttpServletRequest
-{
-
- private HttpServletRequest delegate;
-
- /**
- * Create new instance
- * @param request delegate {@link HttpServletRequest}
- */
- public BaseHttpRequestWrapper(HttpServletRequest request)
- {
- delegate = request;
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getAuthType()
- */
- public String getAuthType()
- {
- return delegate.getAuthType();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getCookies()
- */
- public Cookie[] getCookies()
- {
- return delegate.getCookies();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getDateHeader(String)
- */
- public long getDateHeader(String name)
- {
- return delegate.getDateHeader(name);
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getHeader(String)
- */
- public String getHeader(String name)
- {
- return delegate.getHeader(name);
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getHeaders(String)
- */
- public Enumeration getHeaders(String name)
- {
- return delegate.getHeaders(name);
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getHeaderNames()
- */
- public Enumeration getHeaderNames()
- {
- return delegate.getHeaderNames();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getIntHeader(String)
- */
- public int getIntHeader(String name)
- {
- return delegate.getIntHeader(name);
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getMethod()
- */
- public String getMethod()
- {
- return delegate.getMethod();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getPathInfo()
- */
- public String getPathInfo()
- {
- return delegate.getPathInfo();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getPathTranslated()
- */
- public String getPathTranslated()
- {
- return delegate.getPathTranslated();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getContextPath()
- */
- public String getContextPath()
- {
- return delegate.getContextPath();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getQueryString()
- */
- public String getQueryString()
- {
- return delegate.getQueryString();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getRemoteUser()
- */
- public String getRemoteUser()
- {
- return delegate.getRemoteUser();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#isUserInRole(String)
- */
- public boolean isUserInRole(String role)
- {
- return delegate.isUserInRole(role);
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getUserPrincipal()
- */
- public Principal getUserPrincipal()
- {
- return delegate.getUserPrincipal();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getRequestedSessionId()
- */
- public String getRequestedSessionId()
- {
- return delegate.getRequestedSessionId();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getRequestURI()
- */
- public String getRequestURI()
- {
- return delegate.getRequestURI();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getRequestURL()
- */
- public StringBuffer getRequestURL()
- {
- return delegate.getRequestURL();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getServletPath()
- */
- public String getServletPath()
- {
- return delegate.getServletPath();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getSession(boolean)
- */
- public HttpSession getSession(boolean create)
- {
- return delegate.getSession(create);
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getSession()
- */
- public HttpSession getSession()
- {
- return delegate.getSession();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#isRequestedSessionIdValid()
- */
- public boolean isRequestedSessionIdValid()
- {
- return delegate.isRequestedSessionIdValid();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#isRequestedSessionIdFromCookie()
- */
- public boolean isRequestedSessionIdFromCookie()
- {
- return delegate.isRequestedSessionIdFromCookie();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#isRequestedSessionIdFromURL()
- */
- public boolean isRequestedSessionIdFromURL()
- {
- return delegate.isRequestedSessionIdFromURL();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#isRequestedSessionIdFromUrl()
- */
- public boolean isRequestedSessionIdFromUrl()
- {
- return delegate.isRequestedSessionIdFromUrl();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getAttribute(String)
- */
- public Object getAttribute(String name)
- {
- return delegate.getAttribute(name);
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getAttributeNames()
- */
- public Enumeration getAttributeNames()
- {
- return delegate.getAttributeNames();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getCharacterEncoding()
- */
- public String getCharacterEncoding()
- {
- return delegate.getCharacterEncoding();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#setCharacterEncoding(String)
- */
- public void setCharacterEncoding(String env) throws UnsupportedEncodingException
- {
- delegate.setCharacterEncoding(env);
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getContentLength()
- */
- public int getContentLength()
- {
- return delegate.getContentLength();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getContentType()
- */
- public String getContentType()
- {
- return delegate.getContentType();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getInputStream()
- */
- public ServletInputStream getInputStream() throws IOException
- {
- return delegate.getInputStream();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getParameter(String)
- */
- public String getParameter(String name)
- {
- return delegate.getParameter(name);
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getParameterNames()
- */
- public Enumeration getParameterNames()
- {
- return delegate.getParameterNames();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getParameterValues(String)
- */
- public String[] getParameterValues(String name)
- {
- return delegate.getParameterValues(name);
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getParameterMap()
- */
- public Map getParameterMap()
- {
- return delegate.getParameterMap();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getProtocol()
- */
- public String getProtocol()
- {
- return delegate.getProtocol();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getScheme()
- */
- public String getScheme()
- {
- return delegate.getScheme();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getServerName()
- */
- public String getServerName()
- {
- return delegate.getServerName();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getServerPort()
- */
- public int getServerPort()
- {
- return delegate.getServerPort();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getReader()
- */
- public BufferedReader getReader() throws IOException
- {
- return delegate.getReader();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getRemoteAddr()
- */
- public String getRemoteAddr()
- {
- return delegate.getRemoteAddr();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getRemoteHost()
- */
- public String getRemoteHost()
- {
- return delegate.getRemoteHost();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#setAttribute(String, Object)
- */
- public void setAttribute(String name, Object o)
- {
- delegate.setAttribute(name, o);
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#removeAttribute(String)
- */
- public void removeAttribute(String name)
- {
- delegate.removeAttribute(name);
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getLocale()
- */
- public Locale getLocale()
- {
- return delegate.getLocale();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getLocales()
- */
- public Enumeration getLocales()
- {
- return delegate.getLocales();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#isSecure()
- */
- public boolean isSecure()
- {
- return delegate.isSecure();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getRequestDispatcher(String)
- */
- public RequestDispatcher getRequestDispatcher(String path)
- {
- return delegate.getRequestDispatcher(path);
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getRealPath(String)
- */
- public String getRealPath(String path)
- {
- return delegate.getRealPath(path);
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getRemotePort()
- */
- public int getRemotePort()
- {
- return delegate.getRemotePort();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getLocalName()
- */
- public String getLocalName()
- {
- return delegate.getLocalName();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getLocalAddr()
- */
- public String getLocalAddr()
- {
- return delegate.getLocalAddr();
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getLocalPort()
- */
- public int getLocalPort()
- {
- return delegate.getLocalPort();
- }
-
- /**
- * Get the underlying request - the delegate
- */
- public HttpServletRequest getRequest()
- {
- return delegate;
- }
-}
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/HttpRequestWrapper.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/HttpRequestWrapper.java 2010-09-28
13:09:32 UTC (rev 4411)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/HttpRequestWrapper.java 2010-09-28
16:19:26 UTC (rev 4412)
@@ -24,6 +24,7 @@
import org.exoplatform.portal.application.PortalRequestContext;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
import java.util.Collections;
import java.util.Enumeration;
import java.util.LinkedList;
@@ -33,7 +34,7 @@
/**
* @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
*/
-public class HttpRequestWrapper extends BaseHttpRequestWrapper
+public class HttpRequestWrapper extends HttpServletRequestWrapper
{
private static final List<Locale> EMPTY_LOCALE_LIST = Collections.emptyList();
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/CaptchaValidator.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/CaptchaValidator.java 2010-09-28
13:09:32 UTC (rev 4411)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/CaptchaValidator.java 2010-09-28
16:19:26 UTC (rev 4412)
@@ -19,9 +19,8 @@
package org.exoplatform.portal.webui;
-import org.exoplatform.portal.application.PortalRequestContext;
-import org.exoplatform.portal.webui.util.Util;
import org.exoplatform.web.application.ApplicationMessage;
+import org.exoplatform.webui.application.portlet.PortletRequestContext;
import org.exoplatform.webui.core.UIComponent;
import org.exoplatform.webui.exception.MessageException;
import org.exoplatform.webui.form.UIForm;
@@ -32,8 +31,8 @@
import java.io.Serializable;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletSession;
/**
* @author <a href="mailto:theute@redhat.com">Thomas Heute</a>
@@ -46,9 +45,9 @@
public void validate(UIFormInput uiInput) throws Exception
{
- PortalRequestContext prContext = Util.getPortalRequestContext();
- HttpServletRequest request = prContext.getRequest();
- HttpSession session = request.getSession();
+ PortletRequestContext ctx = PortletRequestContext.getCurrentInstance();
+ PortletRequest req = ctx.getRequest();
+ PortletSession session = req.getPortletSession();
Captcha captcha = (Captcha) session.getAttribute(Captcha.NAME);
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/UICaptcha.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/UICaptcha.java 2010-09-28
13:09:32 UTC (rev 4411)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/UICaptcha.java 2010-09-28
16:19:26 UTC (rev 4412)
@@ -22,11 +22,12 @@
******************************************************************************/
package org.exoplatform.portal.webui;
-import java.util.Calendar;
-
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.form.UIFormStringInput;
+import javax.portlet.RenderResponse;
+import javax.portlet.ResourceURL;
+
/**
* @author <a href="mailto:theute@redhat.com">Thomas Heute</a>
* @version $Revision$
@@ -40,9 +41,18 @@
}
public void processRender(WebuiRequestContext context) throws Exception
- {
- context.getWriter().write("<div id='" + getId() +
"'><img src=\"" + context.getPortalContextPath() +
"/captcha?v=" +
- Calendar.getInstance().getTimeInMillis() + "\"
/><br/>");
+ {
+
+ RenderResponse resp = context.getResponse();
+
+ //
+ ResourceURL url = resp.createResourceURL();
+
+ // context.getPortalContextPath() + "/captcha?v=" +
Calendar.getInstance().getTimeInMillis()
+
+
+
+ context.getWriter().write("<div id='" + getId() +
"'><img src=\"" + url.toString() + "\"
/><br/>");
super.processRender(context);
context.getWriter().write("</div>");
}