From 018589c78d8f69b48ce4e0f3e178f3503e8a96c0 Mon Sep 17 00:00:00 2001 From: joethei Date: Mon, 3 Jun 2019 00:24:00 +0200 Subject: [PATCH] fixes to war building --- README.md | 2 +- pom.xml | 2 +- .../de/hsel/spm/baudas/web/AuthorizationFilter.java | 2 +- .../java/de/hsel/spm/baudas/web/DatasetManagement.java | 2 +- src/main/java/de/hsel/spm/baudas/web/LoginServlet.java | 10 +++++++++- src/main/webapp/version.jsp | 3 ++- 6 files changed, 15 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 645a7fc..b11aae7 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ ## minimal Requirements -- Java 11 +- Java 8 - Maven 3 - Tomcat 9 diff --git a/pom.xml b/pom.xml index 066381a..65068b4 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ war - 11 + 1.8 checkstyle.xml UTF-8 src/main diff --git a/src/main/java/de/hsel/spm/baudas/web/AuthorizationFilter.java b/src/main/java/de/hsel/spm/baudas/web/AuthorizationFilter.java index 5b39252..c929911 100644 --- a/src/main/java/de/hsel/spm/baudas/web/AuthorizationFilter.java +++ b/src/main/java/de/hsel/spm/baudas/web/AuthorizationFilter.java @@ -54,7 +54,7 @@ public class AuthorizationFilter implements Filter { HttpServletResponse res = (HttpServletResponse) response; HttpSession session = req.getSession(false); String url = req.getRequestURI(); - if (url.contains("login") || url.contains("logo") || url.contains("js/")) { + if (url.contains("login") || url.contains("logo") || url.contains("js/") || url.contains("version.jsp")) { chain.doFilter(request, response); } else if (session == null || session.getAttribute("authentication") == null || !((boolean) session.getAttribute("authentication"))) { //checking whether the session exists and if authentication succeed diff --git a/src/main/java/de/hsel/spm/baudas/web/DatasetManagement.java b/src/main/java/de/hsel/spm/baudas/web/DatasetManagement.java index 33b8cdf..3c8fa9d 100644 --- a/src/main/java/de/hsel/spm/baudas/web/DatasetManagement.java +++ b/src/main/java/de/hsel/spm/baudas/web/DatasetManagement.java @@ -120,7 +120,7 @@ public class DatasetManagement { @Contract(pure = true) @NotNull private static String getFileName(@NotNull UUID uuid) { - return uuid + ".csv"; + return System.getProperty("catalina.base") + "/" + uuid + ".csv"; } diff --git a/src/main/java/de/hsel/spm/baudas/web/LoginServlet.java b/src/main/java/de/hsel/spm/baudas/web/LoginServlet.java index 25ce233..eaa9439 100644 --- a/src/main/java/de/hsel/spm/baudas/web/LoginServlet.java +++ b/src/main/java/de/hsel/spm/baudas/web/LoginServlet.java @@ -11,8 +11,12 @@ import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.io.IOException; import java.io.PrintWriter; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; /** * authenticates users. @@ -34,7 +38,11 @@ public class LoginServlet extends HttpServlet { */ @Override protected void doPost(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response) throws ServletException, IOException { - String pw = Files.readString(Paths.get("password.txt")); + List list = new ArrayList<>(); + try (Stream lines = Files.lines(Paths.get("password.txt"), StandardCharsets.UTF_8)) { + lines.forEach(list::add); + } + String pw = list.get(0); String password = request.getParameter("password"); if (pw.equals(password)) { diff --git a/src/main/webapp/version.jsp b/src/main/webapp/version.jsp index 64f838f..ecbba3b 100644 --- a/src/main/webapp/version.jsp +++ b/src/main/webapp/version.jsp @@ -5,4 +5,5 @@ Servlet version: <%= application.getMajorVersion() %>.<%= application.getMinorVe JSP version: <%= JspFactory.getDefaultFactory().getEngineInfo().getSpecificationVersion() %>
Java version: <%= System.getProperty("java.version") %>
Weka version: <%= Version.VERSION %>
-File root: <%= new File("").getAbsolutePath() %> \ No newline at end of file +File root: <%= new File("").getAbsolutePath() %>
+Catalina base : <%= System.getProperty("catalina.base") %> \ No newline at end of file