X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cadi%2Fcore%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fcadi%2Ffilter%2FCadiFilter.java;h=cd48556bc4d38533aa9a4e4a57c368ac83dc0e10;hb=refs%2Fchanges%2F87%2F65287%2F1;hp=affb8f965eaf0293103fa966d9314d28e0b0ea67;hpb=4b5a7d721d994a49057e9bfb403c7bff1b376660;p=aaf%2Fauthz.git diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/filter/CadiFilter.java b/cadi/core/src/main/java/org/onap/aaf/cadi/filter/CadiFilter.java index affb8f96..cd48556b 100644 --- a/cadi/core/src/main/java/org/onap/aaf/cadi/filter/CadiFilter.java +++ b/cadi/core/src/main/java/org/onap/aaf/cadi/filter/CadiFilter.java @@ -113,7 +113,7 @@ public class CadiFilter implements Filter { public CadiFilter(boolean init, PropAccess access, Object ... moreTafLurs) throws ServletException { this.access = access; additionalTafLurs = moreTafLurs; - if(init) { + if (init) { init(new AccessGetter(access)); } } @@ -129,7 +129,7 @@ public class CadiFilter implements Filter { public void init(FilterConfig filterConfig) throws ServletException { // need the Context for Logging, instantiating ClassLoader, etc ServletContextAccess sca=new ServletContextAccess(filterConfig); - if(access==null) { + if (access==null) { access = sca; } @@ -144,9 +144,9 @@ public class CadiFilter implements Filter { TrustChecker tc = TrustChecker.NOTRUST; // default position try { Class ctc = (Class) Class.forName("org.onap.aaf.cadi.aaf.v2_0.AAFTrustChecker"); - if(ctc!=null) { + if (ctc!=null) { Constructor contc = ctc.getConstructor(Access.class); - if(contc!=null) { + if (contc!=null) { tc = contc.newInstance(access); } } @@ -184,8 +184,8 @@ public class CadiFilter implements Filter { // In this case, the epiTaf will be changed to a non-NullTaf, and thus not instantiate twice. synchronized(CadiHTTPManip.noAdditional /*will always remain same Object*/) { ++count; - if(httpChecker == null) { - if(access==null) { + if (httpChecker == null) { + if (access==null) { access = new PropAccess(); } try { @@ -193,16 +193,16 @@ public class CadiFilter implements Filter { } catch (CadiException | LocatorException e1) { throw new ServletException(e1); } - } else if(access==null) { + } else if (access==null) { access= httpChecker.getAccess(); } /* * Setup Authn Path Exceptions */ - if(pathExceptions==null) { + if (pathExceptions==null) { String str = getter.get(Config.CADI_NOAUTHN, null, true); - if(str!=null) { + if (str!=null) { pathExceptions = str.split("\\s*:\\s*"); } } @@ -210,22 +210,22 @@ public class CadiFilter implements Filter { /* * SETUP Permission Converters... those that can take Strings from a Vendor Product, and convert to appropriate AAF Permissions */ - if(mapPairs==null) { + if (mapPairs==null) { String str = getter.get(Config.AAF_PERM_MAP, null, true); - if(str!=null) { + if (str!=null) { String mstr = getter.get(Config.AAF_PERM_MAP, null, true); - if(mstr!=null) { + if (mstr!=null) { String map[] = mstr.split("\\s*:\\s*"); - if(map.length>0) { + if (map.length>0) { MapPermConverter mpc=null; int idx; mapPairs = new ArrayList<>(); - for(String entry : map) { - if((idx=entry.indexOf('='))<0) { // it's a Path, so create a new converter + for (String entry : map) { + if ((idx=entry.indexOf('='))<0) { // it's a Path, so create a new converter access.log(Level.INIT,"Loading Perm Conversions for:",entry); mapPairs.add(new Pair(entry,mpc=new MapPermConverter())); } else { - if(mpc!=null) { + if (mpc!=null) { mpc.map().put(entry.substring(0,idx),entry.substring(idx+1)); } else { access.log(Level.ERROR,"cadi_perm_map is malformed; ",entry, "is skipped"); @@ -248,7 +248,7 @@ public class CadiFilter implements Filter { public void destroy() { // Synchronize, in case multiCadiFilters are used. synchronized(CadiHTTPManip.noAdditional) { - if(--count<=0 && httpChecker!=null) { + if (--count<=0 && httpChecker!=null) { httpChecker.destroy(); httpChecker=null; access=null; @@ -272,7 +272,7 @@ public class CadiFilter implements Filter { String tag = ""; try { HttpServletRequest hreq = (HttpServletRequest)request; - if(noAuthn(hreq)) { + if (noAuthn(hreq)) { startCode=System.nanoTime(); chain.doFilter(request, response); code = Timing.millis(startCode); @@ -281,11 +281,11 @@ public class CadiFilter implements Filter { startValidate=System.nanoTime(); TafResp tresp = httpChecker.validate(hreq, hresp, hreq); validate = Timing.millis(startValidate); - if(tresp.isAuthenticated()==RESP.IS_AUTHENTICATED) { + if (tresp.isAuthenticated()==RESP.IS_AUTHENTICATED) { user = tresp.getPrincipal().personalName(); tag = tresp.getPrincipal().tag(); CadiWrap cw = new CadiWrap(hreq, tresp, httpChecker.getLur(),getConverter(hreq)); - if(httpChecker.notCadi(cw, hresp)) { + if (httpChecker.notCadi(cw, hresp)) { startCode=System.nanoTime(); oauthFilter.doFilter(cw,response,chain); code = Timing.millis(startCode); @@ -308,11 +308,11 @@ public class CadiFilter implements Filter { * @return */ private boolean noAuthn(HttpServletRequest hreq) { - if(pathExceptions!=null) { + if (pathExceptions!=null) { String pi = hreq.getPathInfo(); - if(pi==null) return false; // JBoss sometimes leaves null - for(String pe : pathExceptions) { - if(pi.startsWith(pe))return true; + if (pi==null) return false; // JBoss sometimes leaves null + for (String pe : pathExceptions) { + if (pi.startsWith(pe))return true; } } return false; @@ -322,11 +322,11 @@ public class CadiFilter implements Filter { * Get Converter by Path */ private PermConverter getConverter(HttpServletRequest hreq) { - if(mapPairs!=null) { + if (mapPairs!=null) { String pi = hreq.getPathInfo(); - if(pi !=null) { - for(Pair p: mapPairs) { - if(pi.startsWith(p.name))return p.pc; + if (pi !=null) { + for (Pair p: mapPairs) { + if (pi.startsWith(p.name))return p.pc; } } }