From 03e0bd66a3a322e09b6f4cdbec7ec0fb266e0113 Mon Sep 17 00:00:00 2001 From: Vitaly Litvak Date: Mon, 4 Jan 2016 10:19:36 +0300 Subject: For #1606 - share HTTP sessions between all web applications --- src/org/traccar/web/WebServer.java | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/org') diff --git a/src/org/traccar/web/WebServer.java b/src/org/traccar/web/WebServer.java index 58f4c7f29..85cc5f75c 100644 --- a/src/org/traccar/web/WebServer.java +++ b/src/org/traccar/web/WebServer.java @@ -24,9 +24,11 @@ import javax.sql.DataSource; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.server.SessionManager; import org.eclipse.jetty.server.handler.ErrorHandler; import org.eclipse.jetty.server.handler.HandlerList; import org.eclipse.jetty.server.handler.ResourceHandler; +import org.eclipse.jetty.server.session.HashSessionManager; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jetty.webapp.WebAppContext; @@ -53,6 +55,7 @@ public class WebServer { private final Config config; private final DataSource dataSource; private final HandlerList handlers = new HandlerList(); + private final SessionManager sessionManager = new HashSessionManager(); private void initServer() { @@ -119,6 +122,7 @@ public class WebServer { WebAppContext app = new WebAppContext(); app.setContextPath("/"); + app.getSessionHandler().setSessionManager(sessionManager); app.setWar(config.getString("web.application")); handlers.addHandler(app); } @@ -126,6 +130,7 @@ public class WebServer { private void initApi() { ServletContextHandler servletHandler = new ServletContextHandler(ServletContextHandler.SESSIONS); servletHandler.setContextPath("/api"); + servletHandler.getSessionHandler().setSessionManager(sessionManager); servletHandler.addServlet(new ServletHolder(new AsyncSocketServlet()), "/socket"); @@ -144,6 +149,8 @@ public class WebServer { private void initOldApi() { ServletContextHandler servletHandler = new ServletContextHandler(ServletContextHandler.SESSIONS); servletHandler.setContextPath("/api"); + servletHandler.getSessionHandler().setSessionManager(sessionManager); + servletHandler.addServlet(new ServletHolder(new AsyncServlet()), "/async/*"); servletHandler.addServlet(new ServletHolder(new ServerServlet()), "/server/*"); servletHandler.addServlet(new ServletHolder(new UserServlet()), "/user/*"); -- cgit v1.2.3 From 2343c85411614b0e16bb8a24eaafd8f33e1cfa71 Mon Sep 17 00:00:00 2001 From: Vitaly Litvak Date: Mon, 4 Jan 2016 10:20:22 +0300 Subject: For #1606 - always start PermissionsManager when WebServer is going to be started (do not check the type of web application) --- src/org/traccar/Context.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/org') diff --git a/src/org/traccar/Context.java b/src/org/traccar/Context.java index c833d0c2e..55561b921 100644 --- a/src/org/traccar/Context.java +++ b/src/org/traccar/Context.java @@ -168,10 +168,7 @@ public final class Context { } if (config.getBoolean("web.enable")) { - if (config.getString("web.type", "new").equals("new") - || config.getString("web.type", "new").equals("api")) { - permissionsManager = new PermissionsManager(dataManager); - } + permissionsManager = new PermissionsManager(dataManager); webServer = new WebServer(config, dataManager.getDataSource()); } -- cgit v1.2.3