X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=sidecar%2Frproxy%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Frproxy%2FReverseProxyAuthorizationFilter.java;h=f9392497b7cec39db659d51821e4032a441ac4c7;hb=0d9b3896ad594816b1eb7048949114e6a18c4bd4;hp=6374c9d82d294b28a901c79b33e40cbb7a61dd1b;hpb=69f4409bb70e8891a08219133bfc09c07aecbde6;p=aaf%2Fcadi.git diff --git a/sidecar/rproxy/src/main/java/org/onap/aaf/rproxy/ReverseProxyAuthorizationFilter.java b/sidecar/rproxy/src/main/java/org/onap/aaf/rproxy/ReverseProxyAuthorizationFilter.java index 6374c9d..f939249 100644 --- a/sidecar/rproxy/src/main/java/org/onap/aaf/rproxy/ReverseProxyAuthorizationFilter.java +++ b/sidecar/rproxy/src/main/java/org/onap/aaf/rproxy/ReverseProxyAuthorizationFilter.java @@ -20,6 +20,7 @@ package org.onap.aaf.rproxy; import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import java.io.File; import java.io.FileInputStream; @@ -30,6 +31,7 @@ import java.net.URI; import java.net.URISyntaxException; import java.security.Principal; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import javax.annotation.Resource; import javax.servlet.Filter; @@ -58,7 +60,7 @@ public class ReverseProxyAuthorizationFilter implements Filter { private static final Logger LOGGER = LoggerFactory.getLogger(ReverseProxyAuthorizationFilter.class); - private ReverseProxyAuthorization[] reverseProxyAuthorizations = new ReverseProxyAuthorization[] {}; + private List reverseProxyAuthorizations = new ArrayList<>(); @Resource private ReverseProxyURIAuthorizationProperties reverseProxyURIAuthorizationProperties; @@ -72,7 +74,10 @@ public class ReverseProxyAuthorizationFilter implements Filter { try (InputStream inputStream = new FileInputStream(new File(reverseProxyURIAuthorizationProperties.getConfigurationFile())); JsonReader jsonReader = new JsonReader(new InputStreamReader(inputStream))) { - reverseProxyAuthorizations = new Gson().fromJson(jsonReader, ReverseProxyAuthorization[].class); + List untrimmedList = new Gson().fromJson(jsonReader, + new TypeToken>() {}.getType()); + untrimmedList.removeAll(Collections.singleton(null)); + reverseProxyAuthorizations = untrimmedList; } catch (IOException e) { throw new ServletException("Authorizations config file not found.", e); }