X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fonap%2Fdmaap%2Fdbcapi%2Fresources%2FAAFAuthenticationFilter.java;h=c5c29fa969df07f32b7f1be15ac1670fa4b6168c;hb=refs%2Fchanges%2F37%2F85037%2F1;hp=8739511d311a5acd253534adb08981791cb63e31;hpb=0654d98f69b80b8d932dd33a5dcc56dbecc6a64e;p=dmaap%2Fdbcapi.git diff --git a/src/main/java/org/onap/dmaap/dbcapi/resources/AAFAuthenticationFilter.java b/src/main/java/org/onap/dmaap/dbcapi/resources/AAFAuthenticationFilter.java index 8739511..c5c29fa 100644 --- a/src/main/java/org/onap/dmaap/dbcapi/resources/AAFAuthenticationFilter.java +++ b/src/main/java/org/onap/dmaap/dbcapi/resources/AAFAuthenticationFilter.java @@ -21,7 +21,9 @@ package org.onap.dmaap.dbcapi.resources; 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; @@ -98,7 +100,7 @@ public class AAFAuthenticationFilter implements Filter { 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."); } @@ -109,6 +111,18 @@ public class AAFAuthenticationFilter implements Filter { } } + 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(); }