CADI Integration 25/74725/3
authorKotta, Shireesha (sk434m) <sk434m@att.com>
Mon, 17 Dec 2018 15:30:21 +0000 (10:30 -0500)
committerKotta, Shireesha (sk434m) <shireesha.kotta@att.com>
Mon, 17 Dec 2018 15:56:08 +0000 (10:56 -0500)
Issue-ID: PORTAL-474

System to system authorization using CADI

Change-Id: I3a62840b4108851bf3f18f5c09f1ea21bd0c6844
Signed-off-by: Kotta, Shireesha (sk434m) <sk434m@att.com>
ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/CadiAuthFilter.java
ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/AuthUtil.java

index 0fdc14d..143eb0f 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START==========================================
  * ONAP Portal SDK
  * ===================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2018 AT&T Intellectual Property. All rights reserved.
  * ===================================================================
  *
  * Unless otherwise specified, all software contained herein is licensed
@@ -52,6 +52,7 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import org.onap.aaf.cadi.filter.CadiFilter;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
 import org.onap.portalsdk.core.onboarding.util.AuthUtil;
 import org.onap.portalsdk.core.onboarding.util.PortalApiConstants;
 import org.onap.portalsdk.core.onboarding.util.PortalApiProperties;
@@ -61,11 +62,14 @@ public class CadiAuthFilter extends CadiFilter {
        private static String include_url_endpoints ="";
        private static String exclude_url_endpoints = "";
        public static final String AUTHORIZATION = "Authorization";
+       private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(CadiAuthFilter.class);
        
        public void init(FilterConfig filterConfig) throws ServletException {
                super.init(filterConfig);
                include_url_endpoints = filterConfig.getInitParameter("include_url_endpoints");
                exclude_url_endpoints = filterConfig.getInitParameter("exclude_url_endpoints");
+               logger.debug(EELFLoggerDelegate.debugLogger, "inculde_url_endpoints values: "+ include_url_endpoints);
+               logger.debug(EELFLoggerDelegate.debugLogger, "exculde_url_endpoints values: "+ exclude_url_endpoints);
        }
 
        public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
@@ -83,11 +87,13 @@ public class CadiAuthFilter extends CadiFilter {
                                        Arrays.asList(excludeUrlEndPointString.split(",")));
                        ArrayList<String> includeUrlEndPointList = new ArrayList<String>(
                                        Arrays.asList(includeUrlEndPointString.split(",")));
-                       if (excludeFilter(request, excludeUrlEndPointList))
+                       if (excludeFilter(request, excludeUrlEndPointList)){
+                               logger.debug(EELFLoggerDelegate.debugLogger, "Request excluded from cadifilter");
                                chain.doFilter(request, response);
-                       else if (includeFilter(request, includeUrlEndPointList))
+                       }else if (includeFilter(request, includeUrlEndPointList)){
+                               logger.debug(EELFLoggerDelegate.debugLogger, "Request is entering cadifilter");
                                super.doFilter(request, response, chain);
-                       else
+                       }else
                                chain.doFilter(request, response);
                }
        }
index a7aa676..14ad234 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START==========================================
  * ONAP Portal SDK
  * ===================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2018 AT&T Intellectual Property. All rights reserved.
  * ===================================================================
  *
  * Unless otherwise specified, all software contained herein is licensed
@@ -142,6 +142,7 @@ public class AuthUtil {
                                str = decodeFunctionCode(instance);
                        finalInstanceList.add(str);
                }
+               logger.debug(EELFLoggerDelegate.debugLogger, "List of AllInstances: "+ finalInstanceList);
                return finalInstanceList;
        }
 
@@ -185,6 +186,11 @@ public class AuthUtil {
                        if (!isauthorized)
                                isauthorized = matchPattern(requestUri, str);
                }
+               logger.debug(EELFLoggerDelegate.debugLogger, "isAccessAllowed for the request uri: "+requestUri + "is"+ isauthorized);
+               if (isauthorized) {
+                       logger.debug(EELFLoggerDelegate.debugLogger,
+                                       "Request is Authorized");
+               }
                return isauthorized;
        }
 }
\ No newline at end of file