From e3093b8d1b19ad92a4af90df39a2087f40a687d4 Mon Sep 17 00:00:00 2001 From: Instrumental Date: Mon, 22 Oct 2018 08:30:19 -0500 Subject: Final Sonar reds Issue-ID: AAF-580 Change-Id: I99de4518853504c2a211e92bce3dba70c8bc6a76 Signed-off-by: Instrumental --- .../org/onap/aaf/cadi/filter/MapBathConverter.java | 59 +++++++++------------- 1 file changed, 25 insertions(+), 34 deletions(-) (limited to 'cadi/core/src/main') diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/filter/MapBathConverter.java b/cadi/core/src/main/java/org/onap/aaf/cadi/filter/MapBathConverter.java index 93074932..ce101e24 100644 --- a/cadi/core/src/main/java/org/onap/aaf/cadi/filter/MapBathConverter.java +++ b/cadi/core/src/main/java/org/onap/aaf/cadi/filter/MapBathConverter.java @@ -138,48 +138,39 @@ public class MapBathConverter { public String convert(Access access, final String bath) { String rv = map.get(bath); - String cred=null; + + String cred; String tcred=null; Holder hpass=null; try { - if(rv==null || !rv.startsWith(BASIC)) { - if(bath.startsWith(BASIC)) { - cred = idFromBasic(bath,(hpass=new Holder())); - } - } - - if(cred!=null) { + if(bath.startsWith(BASIC)) { + cred = idFromBasic(bath,(hpass=new Holder())); if(rv==null) { - rv = map.get(cred); + rv = map.get(cred); } - // for SAFETY REASONS, we WILL NOT allow a non validated cred to - // pass a password from file. Should be caught from Instation, but... - if(rv!=null) { - if(!rv.startsWith(BASIC)) { - tcred = rv; - rv = BASIC + Symm.base64noSplit.encode(rv+':'+hpass.value); - } - } - } + } else { + cred = bath; + } + + if(rv==null) { + // Nothing here, just return original + rv = bath; + } else { + if(rv.startsWith(BASIC)) { + tcred = idFromBasic(rv,null); + } else { + if(hpass!=null) { + tcred = rv; + rv = BASIC + Symm.base64noSplit.encode(rv+':'+hpass.value); + } + } + if(tcred != null) { + access.printf(Level.AUDIT, "ID %s converted to %s",cred,tcred); + } + } } catch (IOException | CadiException e) { access.log(e,"Invalid Authorization"); } - - if(rv==null) { - rv=bath; - } else { - try { - if(cred==null) { - cred = idFromBasic(bath,null); - } - if(tcred==null) { - tcred = idFromBasic(rv,null); - } - } catch (IOException | CadiException e) { - access.log(Level.ERROR,"Invalid Basic Authentication for conversion"); - } - access.printf(Level.AUDIT, "ID %s converted to %s",cred,tcred); - } return rv==null?bath:rv; } } -- cgit 1.2.3-korg