X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=auth%2Fauth-gui%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fauth%2Fgui%2Fpages%2FRoleDetail.java;h=7b01e8f2c7930683a325eee7109aaaf3a0770ded;hb=1296352d8eafee57f982a4342ad79ada4aa56d28;hp=d5a89c2c00d7201e17e88bf1d7a4885c26480a5f;hpb=4b5a7d721d994a49057e9bfb403c7bff1b376660;p=aaf%2Fauthz.git diff --git a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/RoleDetail.java b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/RoleDetail.java index d5a89c2c..7b01e8f2 100644 --- a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/RoleDetail.java +++ b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/RoleDetail.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -63,7 +63,7 @@ import aaf.v2_0.UserRoles; /** * Detail Page for Permissions - * + * * @author Jonathan * */ @@ -82,7 +82,7 @@ public class RoleDetail extends Page { /** * Implement the table content for Permissions Detail - * + * * @author Jonathan * */ @@ -106,14 +106,18 @@ public class RoleDetail extends Page { public void prefix(final AAF_GUI gui, final AuthzTrans trans, final Cache cache, final HTMLGen hgen) { final String pRole = trans.get(sRoleName, null); Validator v = new Validator(); - v.role(pRole); - if(v.err()) { + if(!v.isNull("Role",pRole).err()) { + if(!pRole.startsWith(trans.user())) { + v.role(pRole); + } + } + if (v.err()) { trans.warn().printf("Error in PermDetail Request: %s", v.errs()); return; } - - try { + + try { gui.clientAsUser(trans.getUserPrincipal(), new Retryable() { @Override public Boolean code(Rcli client) throws CadiException, ConnectException, APIException { @@ -121,17 +125,17 @@ public class RoleDetail extends Page { try { Future fr = client.read("/authz/roles/"+pRole+"?ns",gui.getDF(Roles.class)); Future fur = client.read("/authz/userRoles/role/"+pRole,gui.getDF(UserRoles.class)); - if(fr.get(AAF_GUI.TIMEOUT)) { + if (fr.get(AAF_GUI.TIMEOUT)) { List roles = fr.value.getRole(); - if(!roles.isEmpty()) { + if (!roles.isEmpty()) { Role role = fr.value.getRole().get(0); trans.put(sRole, role); Boolean mayWrite = trans.fish(new AAFPermission(role.getNs(),ACCESS,":role:"+role.getName(),"write")); trans.put(sMayWrite,mayWrite); Boolean mayApprove = trans.fish(new AAFPermission(role.getNs(),ACCESS,":role:"+role.getName(),"approve")); trans.put(sMayApprove, mayApprove); - - if(mayWrite || mayApprove) { + + if (mayWrite || mayApprove) { Mark js = new Mark(); Mark fn = new Mark(); hgen.js(js) @@ -149,7 +153,7 @@ public class RoleDetail extends Page { "dcb.checked= (d.orig != d.value)" ).end(fn) .end(js); - + Mark mark = new Mark(); hgen.incr(mark,"form","method=post"); trans.put(sMark, mark); @@ -159,8 +163,8 @@ public class RoleDetail extends Page { trans.error().printf("Error calling AAF for Roles in GUI, Role Detail %d: %s",fr.code(),fr.body()); return false; } - - if(fur.get(AAF_GUI.TIMEOUT)) { + + if (fur.get(AAF_GUI.TIMEOUT)) { trans.put(sUserRole, fur.value.getUserRole()); } else { trans.error().printf("Error calling AAF for UserRoles in GUI, Role Detail %d: %s",fr.code(),fr.body()); @@ -183,8 +187,8 @@ public class RoleDetail extends Page { final String pRole = trans.get(sRoleName, null); final Role role = trans.get(sRole,null); ArrayList rv = new ArrayList<>(); - - if(role!=null) { + + if (role!=null) { boolean mayWrite = trans.get(sMayWrite, false); boolean mayApprove = trans.get(sMayApprove, false); @@ -192,7 +196,7 @@ public class RoleDetail extends Page { rv.add(new AbsCell[]{ new TextCell("Role:","width=45%"), new TextCell(pRole)}); - if(mayWrite) { + if (mayWrite) { rv.add(new AbsCell[]{ new TextCell("Description:","width=45%"), new TextInputCell("description","textInput",desc,"id=descText","onkeypress=touchedDesc()"), @@ -211,9 +215,9 @@ public class RoleDetail extends Page { boolean protectedRole = role.getName().endsWith(".owner") || role.getName().endsWith(".admin"); boolean first = true; - for(Pkey r : role.getPerms()) { + for (Pkey r : role.getPerms()) { String key=r.getType() + '|' + r.getInstance() + '|' + r.getAction(); - if(mayWrite) { + if (mayWrite) { rv.add(new AbsCell[] { AbsCell.Null, protectedRole && r.getType().endsWith(".access") @@ -223,7 +227,7 @@ public class RoleDetail extends Page { new TextCell(key) }); } else { - if(first) { + if (first) { rv.add(new AbsCell[] { new TextCell("Associated Permissions:","width=45%"), new TextCell(key) @@ -237,11 +241,11 @@ public class RoleDetail extends Page { } } } - - if(mayApprove) { + + if (mayApprove) { rv.add(AbsCell.HLINE); - // + // rv.add(new AbsCell[] { new TextCell("Users in Role:","width=25%"), new TextCell("Delete","width=10%"), @@ -249,10 +253,10 @@ public class RoleDetail extends Page { }); List userroles = trans.get(sUserRole,null); - if(userroles!=null) { - for(UserRole ur : userroles) { + if (userroles!=null) { + for (UserRole ur : userroles) { String tag = "userrole"; - + rv.add(new AbsCell[] { AbsCell.Null, new CheckBoxCell(tag+".delete", ur.getUser()), @@ -263,10 +267,10 @@ public class RoleDetail extends Page { } } } - - // History + + // History rv.add(new AbsCell[] { - new RefCell("See History",RoleHistory.HREF + "?role=" + pRole,false) + new RefCell("See History",RoleHistory.HREF + "?role=" + pRole,false,"class=greenbutton") }); } else { rv.add(new AbsCell[]{ @@ -284,10 +288,10 @@ public class RoleDetail extends Page { @Override public void postfix(AAF_GUI state, AuthzTrans trans, final Cache cache, final HTMLGen hgen) { final Mark mark = trans.get(sMark, null); - if(mark!=null) { + if (mark!=null) { hgen.tagOnly("input", "type=submit", "value=Submit"); final String pNS = trans.get(sNS, null); - if(pNS!=null && pNS.length()>0) { + if (pNS!=null && pNS.length()>0) { hgen.leaf(mark,HTMLGen.A,"href="+NsDetail.HREF+"?ns="+pNS,"class=greenbutton").text("Back").end(mark); } hgen.end(mark); @@ -295,5 +299,5 @@ public class RoleDetail extends Page { } } -} +} \ No newline at end of file