Skip to content
Snippets Groups Projects
Commit df668abf authored by gmantele's avatar gmantele
Browse files

[TAP] Automatic research of the TAP configuration file is done only in the...

[TAP] Automatic research of the TAP configuration file is done only in the classpath, in WEB-INF and in META-INF. The rest is the Web Application directory is ignored, for security considerations (i.e. otherwise, the library would allow TAP administrators to make the configuration file public....only WEB-INF and META-INF are not public).
parent 624c1457
No related branches found
No related tags found
No related merge requests found
...@@ -84,7 +84,7 @@ public class ConfigurableTAPServlet extends HttpServlet { ...@@ -84,7 +84,7 @@ public class ConfigurableTAPServlet extends HttpServlet {
} }
// If no file has been found, cancel the servlet loading: // If no file has been found, cancel the servlet loading:
if (input == null) if (input == null)
throw new ServletException("Configuration file not found with the path: \"" + tapConfPath + "\"! Please provide a correct file path for the TAP configuration file."); throw new ServletException("Configuration file not found with the path: \"" + ((tapConfPath == null) ? DEFAULT_TAP_CONF_FILE : tapConfPath) + "\"! Please provide a correct file path in servlet init parameter (\"" + TAP_CONF_PARAMETER + "\") or put your configuration file named \"" + DEFAULT_TAP_CONF_FILE + "\" in a directory of the classpath or in WEB-INF or META-INF.");
/* 3. PARSE IT INTO A PROPERTIES SET */ /* 3. PARSE IT INTO A PROPERTIES SET */
Properties tapConf = new Properties(); Properties tapConf = new Properties();
...@@ -165,18 +165,16 @@ public class ConfigurableTAPServlet extends HttpServlet { ...@@ -165,18 +165,16 @@ public class ConfigurableTAPServlet extends HttpServlet {
serviceConn.setAvailable(true, "TAP service available."); serviceConn.setAvailable(true, "TAP service available.");
} }
protected final InputStream searchFile(final String filePath, final ServletConfig config){ protected final InputStream searchFile(String filePath, final ServletConfig config){
InputStream input = null; InputStream input = null;
// Try to search in the classpath (with just a file name or a relative path): // Try to search in the classpath (with just a file name or a relative path):
input = Thread.currentThread().getContextClassLoader().getResourceAsStream(filePath); input = Thread.currentThread().getContextClassLoader().getResourceAsStream(filePath);
// If not found, try searching in the WebContent directory (as this fileName is a file path relative to WebContent): // If not found, try searching in WEB-INF and META-INF (as this fileName is a file path relative to one of these directories):
if (input == null) if (input == null){
input = config.getServletContext().getResourceAsStream(filePath); if (filePath.startsWith("/"))
filePath = filePath.substring(1);
// LAST CHANCE: Only if it is not a path...
if (input == null && filePath.indexOf(File.separatorChar) < 0){
// ...try at the root of WEB-INF: // ...try at the root of WEB-INF:
input = config.getServletContext().getResourceAsStream("/WEB-INF/" + filePath); input = config.getServletContext().getResourceAsStream("/WEB-INF/" + filePath);
// ...and at the root of META-INF: // ...and at the root of META-INF:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment