[gatein-commits] gatein SVN: r2141 - in portal/trunk: examples/extension/war/src/main/webapp/login/jsp and 2 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Mar 10 20:22:59 EST 2010


Author: julien_viet
Date: 2010-03-10 20:22:58 -0500 (Wed, 10 Mar 2010)
New Revision: 2141

Modified:
   portal/trunk/component/web/src/main/java/org/exoplatform/web/login/ErrorLoginServlet.java
   portal/trunk/component/web/src/main/java/org/exoplatform/web/login/InitiateLoginServlet.java
   portal/trunk/examples/extension/war/src/main/webapp/login/jsp/login.jsp
   portal/trunk/examples/portal/war/src/main/webapp/login/jsp/login.jsp
   portal/trunk/web/portal/src/main/webapp/login/jsp/login.jsp
Log:
GTNPORTAL-854 : Login Exception when input invalid password in Sign In form


Modified: portal/trunk/component/web/src/main/java/org/exoplatform/web/login/ErrorLoginServlet.java
===================================================================
--- portal/trunk/component/web/src/main/java/org/exoplatform/web/login/ErrorLoginServlet.java	2010-03-11 00:50:04 UTC (rev 2140)
+++ portal/trunk/component/web/src/main/java/org/exoplatform/web/login/ErrorLoginServlet.java	2010-03-11 01:22:58 UTC (rev 2141)
@@ -27,6 +27,7 @@
 import org.exoplatform.web.security.security.CookieTokenService;
 
 import java.io.IOException;
+import java.util.Enumeration;
 
 import javax.servlet.ServletContext;
 import javax.servlet.ServletException;

Modified: portal/trunk/component/web/src/main/java/org/exoplatform/web/login/InitiateLoginServlet.java
===================================================================
--- portal/trunk/component/web/src/main/java/org/exoplatform/web/login/InitiateLoginServlet.java	2010-03-11 00:50:04 UTC (rev 2140)
+++ portal/trunk/component/web/src/main/java/org/exoplatform/web/login/InitiateLoginServlet.java	2010-03-11 01:22:58 UTC (rev 2141)
@@ -89,7 +89,7 @@
 
                // This allows the customer to define another login page without
                // changing the portal
-               context.getRequestDispatcher("/login/jsp/login.jsp").include(req, resp);
+               showLoginForm(req, resp);
             }
             else
             {
@@ -104,7 +104,7 @@
             // This allows the customer to define another login page without
             // changing the portal
             log.debug("Login initiated with no credentials in session and no token cookie, redirecting to login page");
-            context.getRequestDispatcher("/login/jsp/login.jsp").include(req, resp);
+            showLoginForm(req, resp);
          }
       }
       else
@@ -120,6 +120,19 @@
       }
    }
 
+   private void showLoginForm(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+   {
+      try
+      {
+         req.setAttribute("org.gatein.portal.login.initial_uri", "javax.servlet.forward.request_uri");
+         getServletContext().getRequestDispatcher("/login/jsp/login.jsp").include(req, resp);
+      }
+      finally
+      {
+         req.removeAttribute("org.gatein.portal.login.initial_uri");
+      }
+   }
+
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
    {
       doGet(req, resp);

Modified: portal/trunk/examples/extension/war/src/main/webapp/login/jsp/login.jsp
===================================================================
--- portal/trunk/examples/extension/war/src/main/webapp/login/jsp/login.jsp	2010-03-11 00:50:04 UTC (rev 2140)
+++ portal/trunk/examples/extension/war/src/main/webapp/login/jsp/login.jsp	2010-03-11 01:22:58 UTC (rev 2141)
@@ -39,6 +39,8 @@
   ResourceBundleService service = (ResourceBundleService) portalContainer.getComponentInstanceOfType(ResourceBundleService.class);
   ResourceBundle res = service.getResourceBundle(service.getSharedResourceBundleNames(), request.getLocale()) ;
   
+  String uri = (String)request.getAttribute("org.gatein.portal.login.initial_uri");
+
   Cookie cookie = new Cookie(InitiateLoginServlet.COOKIE_NAME, "");
 	cookie.setPath(request.getContextPath());
 	cookie.setMaxAge(0);
@@ -68,8 +70,10 @@
           %>
             <font color="red">Sign in failed. Wrong username or password.</font><%}%>
           <form name="loginForm" action="<%= contextPath + "/login"%>" method="post" style="margin: 0px;">    
-          		<input type="hidden" name="uri" value="<%=session.getAttribute("initialURI") %>"/>   
-          		<table> 
+                <% if (uri != null) { %>
+                <input type="hidden" name="initialURI" value="<%=uri%>"/>
+                <% } %>
+          		<table>
 	              <tr class="FieldContainer">
 		              <td class="FieldLabel"><%=res.getString("UILoginForm.label.UserName")%></td>
 		              <td><input class="UserName" name="username" value="<%=username%>"/></td>

Modified: portal/trunk/examples/portal/war/src/main/webapp/login/jsp/login.jsp
===================================================================
--- portal/trunk/examples/portal/war/src/main/webapp/login/jsp/login.jsp	2010-03-11 00:50:04 UTC (rev 2140)
+++ portal/trunk/examples/portal/war/src/main/webapp/login/jsp/login.jsp	2010-03-11 01:22:58 UTC (rev 2141)
@@ -39,6 +39,8 @@
   ResourceBundleService service = (ResourceBundleService) portalContainer.getComponentInstanceOfType(ResourceBundleService.class);
   ResourceBundle res = service.getResourceBundle(service.getSharedResourceBundleNames(), request.getLocale()) ;
   
+  String uri = (String)request.getAttribute("org.gatein.portal.login.initial_uri");
+
   Cookie cookie = new Cookie(InitiateLoginServlet.COOKIE_NAME, "");
 	cookie.setPath(request.getContextPath());
 	cookie.setMaxAge(0);
@@ -68,8 +70,10 @@
           %>
             <font color="red">Sign in failed. Wrong username or password.</font><%}%>
           <form name="loginForm" action="<%= contextPath + "/login"%>" method="post" style="margin: 0px;">    
-          		<input type="hidden" name="uri" value="<%=session.getAttribute("initialURI") %>"/>   
-          		<table> 
+                <% if (uri != null) { %>
+                <input type="hidden" name="initialURI" value="<%=uri%>"/>
+                <% } %>
+          		<table>
 	              <tr class="FieldContainer">
 		              <td class="FieldLabel"><%=res.getString("UILoginForm.label.UserName")%></td>
 		              <td><input class="UserName" name="username" value="<%=username%>"/></td>

Modified: portal/trunk/web/portal/src/main/webapp/login/jsp/login.jsp
===================================================================
--- portal/trunk/web/portal/src/main/webapp/login/jsp/login.jsp	2010-03-11 00:50:04 UTC (rev 2140)
+++ portal/trunk/web/portal/src/main/webapp/login/jsp/login.jsp	2010-03-11 01:22:58 UTC (rev 2141)
@@ -29,9 +29,9 @@
 <%
   String contextPath = request.getContextPath() ;
 
-  String username = (String)request.getParameter("j_username");
+  String username = request.getParameter("j_username");
   if(username == null) username = "";
- 	String password = (String)request.getParameter("j_password");
+ 	String password = request.getParameter("j_password");
  	if(password == null) password = "";
 
   ResourceBundleService service = (ResourceBundleService) PortalContainer.getCurrentInstance(session.getServletContext())
@@ -42,7 +42,9 @@
 	cookie.setPath(request.getContextPath());
 	cookie.setMaxAge(0);
 	response.addCookie(cookie);
-	
+
+  String uri = (String)request.getAttribute("org.gatein.portal.login.initial_uri");
+
   response.setCharacterEncoding("UTF-8"); 
   response.setContentType("text/html; charset=UTF-8");
 %>
@@ -69,8 +71,10 @@
             if(username.length() > 0 || password.length() > 0) {
           %>
           <font color="red"><%=res.getString("UILoginForm.label.SigninFail")%></font><%}%>
-          <form name="loginForm" action="<%= contextPath + "/login"%>" method="post" style="margin: 0px;">    
-          		<input type="hidden" name="initialURI" value="<%=request.getAttribute("javax.servlet.forward.request_uri")%>"/>
+          <form name="loginForm" action="<%= contextPath + "/login"%>" method="post" style="margin: 0px;">
+                <% if (uri != null) { %>
+          		<input type="hidden" name="initialURI" value="<%=uri%>"/>
+                <% } %>
           		<table> 
 	              <tr class="FieldContainer">
 		              <td class="FieldLabel"><%=res.getString("UILoginForm.label.UserName")%></td>



More information about the gatein-commits mailing list