summaryrefslogtreecommitdiffstats
path: root/auth/auth-cmd/src/main
diff options
context:
space:
mode:
authorInstrumental <jonathan.gathman@att.com>2019-09-03 12:31:32 -0500
committerInstrumental <jonathan.gathman@att.com>2019-09-03 13:04:31 -0500
commit6309ef454e6960d95d13534645e1f15904de6862 (patch)
tree50086c164436cf2e65c8eb9a90180b1d4a34bbbc /auth/auth-cmd/src/main
parentc3b26083686b22724767c4056735d425e4360d0e (diff)
Update Fixes from testing
Issue-ID: AAF-961 Change-Id: I142e460607bf32a785037fa2360b1c0efc3948b1 Signed-off-by: Instrumental <jonathan.gathman@att.com>
Diffstat (limited to 'auth/auth-cmd/src/main')
-rw-r--r--auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/AAFcli.java22
-rw-r--r--auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/perm/Rename.java41
-rw-r--r--auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/role/ListByPerm.java27
-rw-r--r--auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/user/ListForPermission.java34
4 files changed, 82 insertions, 42 deletions
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 4cd628e8..6ca37c33 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
@@ -250,7 +250,13 @@ public class AAFcli {
pw.println("Press <Return> 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;
@@ -569,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);
diff --git a/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/perm/Rename.java b/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/perm/Rename.java
index dbadd8a0..5a7b5dee 100644
--- a/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/perm/Rename.java
+++ b/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/perm/Rename.java
@@ -22,6 +22,9 @@
package org.onap.aaf.auth.cmd.perm;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
import org.onap.aaf.auth.cmd.AAFcli;
import org.onap.aaf.auth.cmd.Cmd;
import org.onap.aaf.auth.cmd.Param;
@@ -31,6 +34,7 @@ import org.onap.aaf.cadi.LocatorException;
import org.onap.aaf.cadi.client.Future;
import org.onap.aaf.cadi.client.Rcli;
import org.onap.aaf.cadi.client.Retryable;
+import org.onap.aaf.cadi.config.Config;
import org.onap.aaf.misc.env.APIException;
import aaf.v2_0.PermRequest;
@@ -65,24 +69,31 @@ public class Rename extends Cmd {
// Set Start/End commands
setStartEnd(pr);
- Future<PermRequest> fp = client.update(
- "/authz/perm/"+origType+"/"+origInstance+"/"+origAction,
- getDF(PermRequest.class),
- pr
- );
- int rv;
- if (fp.get(AAFcli.timeout())) {
- rv = fp.code();
- pw().println("Updated Permission");
- } else {
- rv = fp.code();
- if (rv==202) {
- pw().println("Permission Update Accepted, but requires Approvals before actualizing");
+ try {
+ Future<PermRequest> fp = client.update(
+ "/authz/perm/"+
+ origType+ '/' +
+ URLEncoder.encode(origInstance,Config.UTF_8) + '/' +
+ origAction,
+ getDF(PermRequest.class),
+ pr
+ );
+ int rv;
+ if (fp.get(AAFcli.timeout())) {
+ rv = fp.code();
+ pw().println("Updated Permission");
} else {
- error(fp);
+ rv = fp.code();
+ if (rv==202) {
+ pw().println("Permission Update Accepted, but requires Approvals before actualizing");
+ } else {
+ error(fp);
+ }
}
+ return rv;
+ } catch (UnsupportedEncodingException e) {
+ throw new CadiException(e);
}
- return rv;
}
});
diff --git a/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/role/ListByPerm.java b/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/role/ListByPerm.java
index feb1dec8..5d291ace 100644
--- a/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/role/ListByPerm.java
+++ b/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/role/ListByPerm.java
@@ -22,6 +22,9 @@
package org.onap.aaf.auth.cmd.role;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
import org.onap.aaf.auth.cmd.Cmd;
import org.onap.aaf.auth.cmd.Param;
import org.onap.aaf.auth.rserv.HttpMethods;
@@ -29,6 +32,7 @@ import org.onap.aaf.cadi.CadiException;
import org.onap.aaf.cadi.LocatorException;
import org.onap.aaf.cadi.client.Future;
import org.onap.aaf.cadi.client.Rcli;
+import org.onap.aaf.cadi.config.Config;
import org.onap.aaf.misc.env.APIException;
import aaf.v2_0.Roles;
@@ -51,20 +55,25 @@ public class ListByPerm extends Cmd {
@Override
public int _exec(int idx0, final String ... args) throws CadiException, APIException, LocatorException {
- int idx = idx0;
+ int idx = idx0;
final String type=args[idx];
final String instance=args[++idx];
- final String action=args[++idx];
-
+ final String action = args[++idx];
+
return same(((List)parent).new ListRoles() {
@Override
public Integer code(Rcli<?> client) throws CadiException, APIException {
-
- Future<Roles> fp = client.read(
- "/authz/roles/perm/"+type+'/'+instance+'/'+action,
- getDF(Roles.class)
- );
- return list(fp,client, HEADER+type+'|'+instance+'|'+action);
+ try {
+ Future<Roles> fp = client.read(
+ "/authz/roles/perm/"+type+'/' +
+ URLEncoder.encode(instance,Config.UTF_8)+'/'+
+ action,
+ getDF(Roles.class)
+ );
+ return list(fp,client, HEADER+type+'|'+instance+'|'+action);
+ } catch (UnsupportedEncodingException e) {
+ throw new CadiException(e);
+ }
}
});
}
diff --git a/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/user/ListForPermission.java b/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/user/ListForPermission.java
index dff3dc5e..b40c96ce 100644
--- a/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/user/ListForPermission.java
+++ b/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/user/ListForPermission.java
@@ -21,6 +21,8 @@
package org.onap.aaf.auth.cmd.user;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
import java.util.Collections;
import java.util.Comparator;
@@ -33,6 +35,7 @@ import org.onap.aaf.cadi.LocatorException;
import org.onap.aaf.cadi.client.Future;
import org.onap.aaf.cadi.client.Rcli;
import org.onap.aaf.cadi.client.Retryable;
+import org.onap.aaf.cadi.config.Config;
import org.onap.aaf.misc.env.APIException;
import aaf.v2_0.Users;
@@ -63,19 +66,26 @@ public class ListForPermission extends Cmd {
if ("\\*".equals(instance))instance="*";
String action = args[idx++];
if ("\\*".equals(action))action="*";
- Future<Users> fp = client.read(
- "/authz/users/perm/"+type+'/'+instance+'/'+action,
- getDF(Users.class)
- );
- if (fp.get(AAFcli.timeout())) {
- if (aafcli.isTest())
- Collections.sort(fp.value.getUser(), (Comparator<User>) (u1, u2) -> u1.getId().compareTo(u2.getId()));
- ((org.onap.aaf.auth.cmd.user.List)parent).report(fp.value,false,HEADER,type+"|"+instance+"|"+action);
- if (fp.code()==404)return 200;
- } else {
- error(fp);
+ try {
+ Future<Users> fp = client.read(
+ "/authz/users/perm/" +
+ type + '/' +
+ URLEncoder.encode(instance,Config.UTF_8) + '/' +
+ action,
+ getDF(Users.class)
+ );
+ if (fp.get(AAFcli.timeout())) {
+ if (aafcli.isTest())
+ Collections.sort(fp.value.getUser(), (Comparator<User>) (u1, u2) -> u1.getId().compareTo(u2.getId()));
+ ((org.onap.aaf.auth.cmd.user.List)parent).report(fp.value,false,HEADER,type+"|"+instance+"|"+action);
+ if (fp.code()==404)return 200;
+ } else {
+ error(fp);
+ }
+ return fp.code();
+ } catch (UnsupportedEncodingException e) {
+ throw new CadiException(e);
}
- return fp.code();
}
});
}