Commit 874cb12c by Currell Berry

fixed slf4j dependency. various fixes for deployment purposes.

parent 4020a9aa
......@@ -43,6 +43,18 @@
<artifactId>Saxon-HE</artifactId>
<version>9.7.0-1</version>
</dependency>
<!-- jgit pull in slf4j api anyway so I just go ahead and make this explicit -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.13</version>
</dependency>
<!-- slf4j simple just logs to stderr -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.13</version>
</dependency>
</dependencies>
<build>
......
......@@ -34,7 +34,7 @@ public class AuthenticationFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {
try {
authManager = new AuthenticationManager(System.getProperty("BPIM_PWFILE"));
authManager = new AuthenticationManager(System.getProperty("BERRYPIM_PWFILE"));
} catch (IOException | NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
......@@ -45,6 +45,9 @@ public class AuthenticationFilter implements Filter {
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
if(!authManager.getIsAuthenticationEnabled()) {
chain.doFilter(request, response);//just pass on
}
HttpServletRequest mRequest = (HttpServletRequest) request;
HttpServletResponse mResponse = (HttpServletResponse) response;
String userName = null;
......
......@@ -24,11 +24,11 @@ public class AuthenticationManager {
public boolean authenticationFeatureEnabled;
public AuthenticationManager(String passwordFilePath) throws IOException, NoSuchAlgorithmException {
String pwFileStr= readPWFileToString(passwordFilePath);
if(pwFileStr==null) {//then the person who started the app is not requesting authentication abilities.
if(passwordFilePath == null) {
System.out.println("NOTICE: AUTHENTICATION !NOT! ENABLED");
authenticationFeatureEnabled = false;
} else {
String pwFileStr = readPWFileToString(passwordFilePath);
authenticationFeatureEnabled = true;
authMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
pwHasher = new PasswordHasherLite();
......@@ -36,7 +36,7 @@ public class AuthenticationManager {
String line = strReader.readLine();
while (line != null) {
AuthInfoHolder holder = PasswordHasherLite.retrieveSaltAndHash(line);
authMap.put(holder.username,holder);
authMap.put(holder.username, holder);
line = strReader.readLine();
}
}
......@@ -50,9 +50,6 @@ public class AuthenticationManager {
public String readPWFileToString(String passwordFilePath) throws IOException {
//String configStr = Utility.convertStreamToString(ConfigXMLFileFinder.getConfigXMLStream());
//String filePath = Utility.runXPathOnString(configStr,"/config/pwfile/text()").trim();
if(passwordFilePath == null) {
return null;//indicates that we should not enforce auth on this session.
}
File passwordFile = new File(passwordFilePath);
if(passwordFile == null || !passwordFile.exists()) {
throw new FileNotFoundException("couldn't locate specified passwords file!");
......@@ -89,4 +86,8 @@ public class AuthenticationManager {
return this.authMap.get(username);
}
public boolean getIsAuthenticationEnabled() {
return authenticationFeatureEnabled;
}
}
......@@ -36,6 +36,10 @@ public class DataFilesManager {
fileContentsMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
File[] dataFilesAndFolders = rootFile.listFiles();
if(dataFilesAndFolders == null || dataFilesAndFolders.length==0) {
System.err.println("COULD NOT LOCATE DATA DIRECTORY!");
throw new IOException("data folder not found or empty");
}
for (File f : dataFilesAndFolders) {
if (f.isFile()) {
String contents = Utility.slurp(f.getPath());
......
......@@ -2,7 +2,6 @@ package com.cvberry.berrypimimpl;
import com.cvberry.berrypim.ControllerObject;
import com.cvberry.berrypim.TemplateEngine;
import com.cvberry.berrypim.widgets.PieChart;
import com.cvberry.util.AuthInfoHolder;
import com.cvberry.util.Utility;
import com.sun.management.OperatingSystemMXBean;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment