summaryrefslogtreecommitdiffstats
path: root/cadi/core/src/main
diff options
context:
space:
mode:
authorInstrumental <jonathan.gathman@att.com>2018-10-22 08:30:19 -0500
committerInstrumental <jonathan.gathman@att.com>2018-10-22 08:31:14 -0500
commite3093b8d1b19ad92a4af90df39a2087f40a687d4 (patch)
treecc2037c3479ba4e74898d9a2525c9ae47ff1c97b /cadi/core/src/main
parentc03496d36fc7e0a2978c84cb443550c565eedb84 (diff)
Final Sonar reds
Issue-ID: AAF-580 Change-Id: I99de4518853504c2a211e92bce3dba70c8bc6a76 Signed-off-by: Instrumental <jonathan.gathman@att.com>
Diffstat (limited to 'cadi/core/src/main')
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/filter/MapBathConverter.java59
1 files changed, 25 insertions, 34 deletions
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<String> hpass=null;
try {
- if(rv==null || !rv.startsWith(BASIC)) {
- if(bath.startsWith(BASIC)) {
- cred = idFromBasic(bath,(hpass=new Holder<String>()));
- }
- }
-
- if(cred!=null) {
+ if(bath.startsWith(BASIC)) {
+ cred = idFromBasic(bath,(hpass=new Holder<String>()));
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;
}
}