target = WalkingSecurity.get(state).getSysUserName();
boolean exists = WalkingSecurity.get(state).userExists(target);
boolean tableExists = WalkingSecurity.get(state).getTableExists();
TablePermission tabPerm;
if (perm.equals("random")) {
Random r = new Random();
int i = r.nextInt(TablePermission.values().length);
tabPerm = TablePermission.values()[i];
} else
tabPerm = TablePermission.valueOf(perm);
String tableName = WalkingSecurity.get(state).getTableName();
boolean hasPerm = WalkingSecurity.get(state).hasTablePermission(target, tableName, tabPerm);
boolean canGive;
String sourceUser;
AuthenticationToken sourceToken;
if ("system".equals(sourceUserProp)) {
sourceUser = WalkingSecurity.get(state).getSysUserName();
sourceToken = WalkingSecurity.get(state).getSysToken();
} else if ("table".equals(sourceUserProp)) {
sourceUser = WalkingSecurity.get(state).getTabUserName();
sourceToken = WalkingSecurity.get(state).getTabToken();
} else {
sourceUser = state.getUserName();
sourceToken = state.getToken();
}
Connector conn = state.getInstance().getConnector(sourceUser, sourceToken);
canGive = WalkingSecurity.get(state).canGrantTable(new Credentials(sourceUser, sourceToken).toThrift(state.getInstance()), target,
WalkingSecurity.get(state).getTableName(), WalkingSecurity.get(state).getNamespaceName());
// toggle
if (!"take".equals(action) && !"give".equals(action)) {
try {
boolean res;
if (hasPerm != (res = state.getConnector().securityOperations().hasTablePermission(target, tableName, tabPerm)))
throw new AccumuloException("Test framework and accumulo are out of sync for user " + conn.whoami() + " for perm " + tabPerm.name()
+ " with local vs. accumulo being " + hasPerm + " " + res);
if (hasPerm)
action = "take";
else