Commit 5c23d539 authored by Jonathan Shahen's avatar Jonathan Shahen

HOTFIX: error occurred when slicing that would reorder the roles and there was...

HOTFIX: error occurred when slicing that would reorder the roles and there was an assumption that the last role is the admin role, so it incorrectly added an extra role to the sliced roles list instead of the admin role. This is fixed by iterating through the CA rules and adding a set of admin roles to the sliced RBAC instance. NOTE: the old code assumed that there could be only 1 admin role, this code allows for multiple admin roles (this might not be needed and if it isn't then the code can be optimized to search for the first CA with a Admin Role and then stop searching and adding every role to a set)
parent e30a44aa
......@@ -6,9 +6,7 @@
*/
package mohawk.rbac;
import java.util.HashMap;
import java.util.Map;
import java.util.Vector;
import java.util.*;
import java.util.logging.Logger;
import mohawk.global.pieces.mohawk.CAEntry;
......@@ -63,7 +61,7 @@ public class RBACInstance {
public int getNumRules() {
return mCR.size() + mCA.size();
}
public int getUserIndex(String inStrUser) throws Exception {
return getMapKey(mUserIndex, inStrUser);
}
......@@ -109,4 +107,16 @@ public class RBACInstance {
public Vector<String> getSpec() {
return vSpec;
}
public Vector<String> getAdminRoles() {
Set<String> roles = new HashSet<String>();
for (Vector<CAEntry> cas : mCA.values()) {
for (CAEntry ca : cas) {
roles.add(ca.getAdminRole());
}
}
return new Vector<String>(roles);
}
}
......@@ -24,12 +24,7 @@
package mohawk.refine;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.Vector;
import java.util.*;
import java.util.logging.Logger;
import mohawk.global.pieces.mohawk.*;
......@@ -164,7 +159,8 @@ public class FwdPruning {
while (FwdPruneHelper())
;
Roles_up.add(unsliced.getRoles().lastElement());
// Roles_up.add(unsliced.getRoles().lastElement());
Roles_up.add(unsliced.getAdminRoles().firstElement());
}
// This function has to be called only after initializing slicedRoles
......
......@@ -108,7 +108,7 @@ public class RoleSlicer {
strComparator strComp = new strComparator();
Collections.sort(slicedRoles, strComp);
slicedRoles.add(unsliced.getRoles().lastElement());
slicedRoles.addAll(unsliced.getAdminRoles());
createMapping(slicedRoles);
return slicedRoles;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment