import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.FileInputStream;
import java.io.IOException;
+import java.util.Properties;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
try {
String cadiPropertiesFile = dmaapConfig.getProperty(CADI_PROPERTIES);
if(cadiPropertiesFile != null && !cadiPropertiesFile.isEmpty()) {
- cadiFilter = new CadiFilter(new PropAccess(cadiPropertiesFile));
+ cadiFilter = new CadiFilter(loadCadiProperties(cadiPropertiesFile));
} else {
throw new ServletException("Cannot initialize CADI filter.CADI properties not available.");
}
}
}
+ private PropAccess loadCadiProperties(String propertiesFilePath) throws ServletException {
+ try {
+ Properties props = new Properties();
+ props.load(new FileInputStream(propertiesFilePath));
+ return new PropAccess(props);
+ } catch (IOException e) {
+ String msg = "Could not load CADI properties file: " + propertiesFilePath;
+ LOGGER.error(msg, e);
+ throw new ServletException(msg);
+ }
+ }
+
DmaapConfig getConfig() {
return (DmaapConfig) DmaapConfig.getConfig();
}