]> source.dussan.org Git - vaadin-framework.git/commitdiff
#3157: Spring security form login fix
authorHenri Sara <henri.sara@itmill.com>
Thu, 23 Jul 2009 12:51:18 +0000 (12:51 +0000)
committerHenri Sara <henri.sara@itmill.com>
Thu, 23 Jul 2009 12:51:18 +0000 (12:51 +0000)
svn changeset:8409/svn branch:6.0

src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java
src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java

index 0ab80610ccc5eda203a999baa75627e1a8d5e4fd..945542729f07c6985932f1e201642274fb3f5373 100644 (file)
@@ -106,7 +106,7 @@ public class ApplicationConfiguration {
 
     /**
      * Inits the ApplicationConfiguration by reading the DOM and instantiating
-     * ApplicationConenctions accordingly. Call {@link #startNextApplication()}
+     * ApplicationConnections accordingly. Call {@link #startNextApplication()}
      * to actually start the applications.
      * 
      * @param widgetset
index f2da32cbc4ccfe56bedd238e17d3147c9a09509e..5bcb2873ff1fb0a4ea35e13244db23bd37f950f9 100755 (executable)
@@ -761,7 +761,7 @@ public class ApplicationConnection {
     /**
      * This method assures that all pending variable changes are sent to server.
      * Method uses synchronized xmlhttprequest and does not return before the
-     * changes are sent. No UIDL updates are processed and thut UI is left in
+     * changes are sent. No UIDL updates are processed and thus UI is left in
      * inconsistent state. This method should be called only when closing
      * windows - normally sendPendingVariableChanges() should be used.
      */
@@ -899,11 +899,11 @@ public class ApplicationConnection {
      * Build the variable burst and send it to server.
      * 
      * When sync is forced, we also force sending of all pending variable-bursts
-     * at the same time. This is ok as we can assume that DOM will newer be
+     * at the same time. This is ok as we can assume that DOM will never be
      * updated after this.
      * 
      * @param pendingVariables
-     *            Vector of variablechanges to send
+     *            Vector of variable changes to send
      * @param forceSync
      *            Should we use synchronous request?
      */
index 1008dffd492c051a906e387a64b8dd1d10a3f90f..706d343b2df19984ea49c7a64c3b38ae83f49cb6 100644 (file)
@@ -366,6 +366,24 @@ public abstract class AbstractApplicationServlet extends HttpServlet {
         RequestType requestType = getRequestType(request);
 
         try {
+            // If a duplicate "close application" URL is received for an
+            // application that is not open, redirect to the application's main
+            // page.
+            // This is needed as e.g. Spring Security remembers the last
+            // URL from the application, which is the logout URL, and repeats
+            // it.
+            // We can tell apart a real onunload request from a repeated one
+            // based on the real one having content (at least the UIDL security
+            // key).
+            if (requestType == RequestType.UIDL
+                    && request.getParameterMap().containsKey(
+                            ApplicationConnection.PARAM_UNLOADBURST)
+                    && request.getContentLength() < 1
+                    && getExistingApplication(request, false) == null) {
+                redirectToApplication(request, response);
+                return;
+            }
+
             // Find out which application this request is related to
             application = findApplicationInstance(request, requestType);
             if (application == null) {
@@ -1191,6 +1209,21 @@ public abstract class AbstractApplicationServlet extends HttpServlet {
         return string;
     }
 
+    /**
+     * Write a redirect response to the main page of the application.
+     * 
+     * @param request
+     * @param response
+     * @throws IOException
+     *             if sending the redirect fails due to an input/output error or
+     *             a bad application URL
+     */
+    private void redirectToApplication(HttpServletRequest request,
+            HttpServletResponse response) throws IOException {
+        String applicationUrl = getApplicationUrl(request).toExternalForm();
+        response.sendRedirect(response.encodeRedirectURL(applicationUrl));
+    }
+
     /**
      * 
      * @param request