X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=auth%2Fauth-cmd%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fauth%2Fcmd%2FAAFcli.java;h=fd3b6cd33096127647061eff956142e622ea9c8e;hb=dd4ea724c16294e13d4efe1f373b2c27b111b72a;hp=edbe206889556f62ee7076322c96fb185a8b3c2a;hpb=429f7665740bfe50fee172a54177c49369e42ecb;p=aaf%2Fauthz.git diff --git a/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/AAFcli.java b/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/AAFcli.java index edbe2068..fd3b6cd3 100644 --- a/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/AAFcli.java +++ b/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/AAFcli.java @@ -4,7 +4,7 @@ * =========================================================================== * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. * - * Modifications Copyright (C) 2018 IBM. + * Modifications Copyright (C) 2019 IBM. * =========================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -123,6 +123,10 @@ public class AAFcli { cmds.add(new Mgmt(this)); } + public AuthzEnv env() { + return env; + } + public static int timeout() { return TIMEOUT; } @@ -211,8 +215,7 @@ public class AAFcli { } } else if ("expect".equalsIgnoreCase(largs[idx])) { expect.clear(); - if (largs.length > idx++) { - if (!"nothing".equals(largs[idx])) { + if ((largs.length > idx++)&&(!"nothing".equals(largs[idx]))) { for (String str : largs[idx].split(",")) { try { if ("Exception".equalsIgnoreCase(str)) { @@ -225,8 +228,7 @@ public class AAFcli { } } ++idx; - } - } + } continue; // Sleep, typically for reports, to allow DB to update // Milliseconds @@ -246,7 +248,13 @@ public class AAFcli { pw.println("Press to continue..."); ++idx; // Sonar insists we do something with the string, though it's only a pause. Not very helpful... - String sonar = new BufferedReader(new InputStreamReader(System.in)).readLine(); + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + String sonar; + try { + sonar = br.readLine(); + } finally { + br.close(); + } sonar=""; // this useless code brought to you by Sonar. pw.print(sonar); continue; @@ -256,7 +264,8 @@ public class AAFcli { } else if ("set".equalsIgnoreCase(largs[idx])) { while (largs.length > ++idx) { int equals = largs[idx].indexOf('='); - String tag, value; + String tag; + String value; if (equals < 0) { tag = largs[idx]; value = access.getProperty(Config.AAF_APPPASS,null); @@ -337,7 +346,7 @@ public class AAFcli { } finally { clearSingleLineProperties(); } - rv = expect.isEmpty() ? true : expect.contains(ret); + rv = expect.isEmpty() || expect.contains(ret); if (verbose) { if (rv) { pw.println(); @@ -366,7 +375,8 @@ public class AAFcli { char last = 0; for (int i = 0; i < line.length(); ++i) { char ch; - if (Character.isWhitespace(ch = line.charAt(i))) { + ch = line.charAt(i); + if (Character.isWhitespace(ch)) { if (start || last==',') { continue; // trim } else if (quote != 0) { @@ -538,7 +548,7 @@ public class AAFcli { String line; while ((line = reader.readLine()) != null) { - showDetails = (line.contains("-d"))?true:false; + showDetails = (line.contains("-d")); if (line.equalsIgnoreCase("quit") || line.equalsIgnoreCase("q") || line.equalsIgnoreCase("exit")) { break; @@ -565,12 +575,16 @@ public class AAFcli { } } else if (rdr != null) { BufferedReader br = new BufferedReader(rdr); - String line; - while ((line = br.readLine()) != null) { - if (!aafcli.eval(line) && exitOnFailure) { - rv = 1; - break; + try { + String line; + while ((line = br.readLine()) != null) { + if (!aafcli.eval(line) && exitOnFailure) { + rv = 1; + break; + } } + } finally { + br.close(); } } else { // just run the command line aafcli.verbose(false);