diff options
Diffstat (limited to 'auth/auth-cmd')
6 files changed, 76 insertions, 29 deletions
diff --git a/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/ns/List.java b/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/ns/List.java index 42306c85..add5aed8 100644 --- a/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/ns/List.java +++ b/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/ns/List.java @@ -166,7 +166,7 @@ public class List extends BaseCmd<NS> { case 0: return "NoCrd"; case 1: return "U/P"; case 2: return "U/P2"; - case 10: return "Cert"; + case 10: return "FQI"; case 200: return "x509"; default: return "n/a"; diff --git a/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/role/List.java b/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/role/List.java index f8a633af..2f84f583 100644 --- a/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/role/List.java +++ b/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/role/List.java @@ -104,7 +104,7 @@ public class List extends BaseCmd<Role> { if (roles==null || roles.getRole().isEmpty()) { pw().println("<No Roles Found>"); } else if (aafcli.isDetailed()){ - if (aafcli.isDetailed() && str[0].toLowerCase().contains(LIST_ROLES_BY_NAME)) { + if (str[0].toLowerCase().contains(LIST_ROLES_BY_NAME)) { String description = roles.getRole().get(0).getDescription(); if (description == null) description = ""; reportColHead("%-80s\n","Description: " + description); @@ -123,18 +123,24 @@ public class List extends BaseCmd<Role> { pw().format(roleFormat, "["+ns+"]"+roleName.substring(ns.length()),XXXX_XX_XX); } } else { - UserRole ur = get(roleName,urs); + String fullname; + if(ns==null) { + fullname = roleName; + } else { + fullname = ns+'.'+roleName; + } + UserRole ur = get(fullname,urs); if (ur!=null && now.compare(ur.getExpires().normalize())>0) { if (ns==null) { pw().format(roleExpiredFormat, roleName,Chrono.dateOnlyStamp(ur.getExpires())); } else { - pw().format(roleExpiredFormat, "["+ns+"]"+roleName.substring(ns.length()),Chrono.dateOnlyStamp(ur.getExpires())); + pw().format(roleExpiredFormat, "["+ns+"]."+roleName,Chrono.dateOnlyStamp(ur.getExpires())); } } else { if (ns==null) { pw().format(roleFormat, roleName,ur!=null?Chrono.dateOnlyStamp(ur.getExpires()):""); } else { - pw().format(roleFormat, "["+ns+"]"+roleName.substring(ns.length()),ur!=null?Chrono.dateOnlyStamp(ur.getExpires()):""); + pw().format(roleFormat, "["+ns+"]."+roleName,ur!=null?Chrono.dateOnlyStamp(ur.getExpires()):""); } } } diff --git a/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/role/ListByUser.java b/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/role/ListByUser.java index bdcf1e50..2471c21a 100644 --- a/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/role/ListByUser.java +++ b/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/role/ListByUser.java @@ -21,6 +21,9 @@ package org.onap.aaf.auth.cmd.role; +import java.util.Map; +import java.util.TreeMap; + import org.onap.aaf.auth.cmd.AAFcli; import org.onap.aaf.auth.cmd.Cmd; import org.onap.aaf.auth.cmd.Param; @@ -30,10 +33,14 @@ 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.util.Split; import org.onap.aaf.misc.env.APIException; +import aaf.v2_0.Perm; import aaf.v2_0.Perms; +import aaf.v2_0.Role; import aaf.v2_0.Roles; +import aaf.v2_0.UserRole; import aaf.v2_0.UserRoles; /** @@ -60,33 +67,63 @@ public class ListByUser extends Cmd { public Integer code(Rcli<?> client) throws CadiException, APIException { Perms perms=null; UserRoles urs=null; - Future<Roles> fr = client.read( - "/authz/roles/user/"+user+(aafcli.isDetailed()?"?ns":""), - getDF(Roles.class) - ); + Roles roles = null; + int code; Future<UserRoles> fur = client.read( "/authz/userRoles/user/"+user, getDF(UserRoles.class) ); - if (fr.get(AAFcli.timeout())) { - if (aafcli.isDetailed()) { - Future<Perms> fp = client.read( - "/authz/perms/user/"+user+(aafcli.isDetailed()?"?ns":""), - getDF(Perms.class) - ); - if (fp.get(AAFcli.timeout())) { - perms = fp.value; + if (fur.get(AAFcli.timeout())) { + urs = fur.value; + code = fur.code(); + } else { + error(fur); + return fur.code(); + } + + if (aafcli.isDetailed()) { + roles = new Roles(); + Future<Perms> fp = client.read( + "/authz/perms/user/"+user+"?ns&force", + getDF(Perms.class) + ); + if (fp.get(AAFcli.timeout())) { + Map<String, Role> rs = new TreeMap<>(); + perms = fp.value; + for( Perm p : perms.getPerm()) { + for(String sr : p.getRoles()) { + Role r = rs.get(sr); + if(r==null) { + r = new Role(); + String[] split = Split.split('|', sr); + if(split.length>1) { + r.setNs(split[0]); + r.setName(split[1]); + } else { + r.setName(sr); + } + rs.put(sr, r); + roles.getRole().add(r); + } + r.getPerms().add(p); + } } - } - if (fur.get(AAFcli.timeout())) { - urs = fur.value; - } - - ((List)parent).report(fr.value,perms,urs,HEADER,user); + } + code = fp.code(); } else { - error(fr); + roles = new Roles(); + java.util.List<Role> lr = roles.getRole(); + Role r; + for(UserRole ur : urs.getUserRole()) { + r = new Role(); + r.setName(ur.getRole()); + lr.add(r); + } } - return fr.code(); + + + ((List)parent).report(roles,perms,urs,HEADER,user); + return code; } }); } diff --git a/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/user/Cred.java b/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/user/Cred.java index a1cb3e7a..1dfcc17f 100644 --- a/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/user/Cred.java +++ b/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/user/Cred.java @@ -137,6 +137,8 @@ public class Cred extends Cmd { pw().println(text); } else if (fp.code()==406 && option==1) { pw().println("You cannot delete this Credential"); + } else if (fp.code()==409 && option==0) { + pw().println("You cannot add two Passwords for same day"); } else { pw().println(ATTEMPT_FAILED_SPECIFICS_WITHELD); } diff --git a/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/user/ID.java b/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/user/ID.java index 12035a16..46d5d052 100644 --- a/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/user/ID.java +++ b/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/user/ID.java @@ -53,7 +53,7 @@ public class ID extends Cmd { final CredRequest cr = new CredRequest(); cr.setId(args[idx++]); - cr.setType(0); + cr.setType(10); if (args.length>idx) cr.setEntry(args[idx]); @@ -92,9 +92,11 @@ public class ID extends Cmd { pw().print(cr.getId()); pw().println(']'); } else if (fp.code()==202) { - pw().println("ID Action Accepted, but requires Approvals before actualizing"); + pw().println("ID Action Accepted, but requires Approvals before actualizing"); + } else if (fp.code()==409 && option==0) { + pw().println("FQI already exists"); } else if (fp.code()==406 && option==1) { - pw().println("You cannot delete this ID"); + pw().println("FQI does not exist"); } else { pw().println(ATTEMPT_FAILED_SPECIFICS_WITHELD); } diff --git a/auth/auth-cmd/src/test/java/org/onap/aaf/auth/cmd/test/ns/JU_List.java b/auth/auth-cmd/src/test/java/org/onap/aaf/auth/cmd/test/ns/JU_List.java index 61f41585..e4100a02 100644 --- a/auth/auth-cmd/src/test/java/org/onap/aaf/auth/cmd/test/ns/JU_List.java +++ b/auth/auth-cmd/src/test/java/org/onap/aaf/auth/cmd/test/ns/JU_List.java @@ -136,7 +136,7 @@ public class JU_List { user.setType(2); Assert.assertEquals("U/P2", list.getType(user)); user.setType(10); - Assert.assertEquals("Cert", list.getType(user)); + Assert.assertEquals("FQI", list.getType(user)); user.setType(200); Assert.assertEquals("x509", list.getType(user)); } |