Commit 561c54ae authored by Jonathan Shahen's avatar Jonathan Shahen

Removing unused files; fixing all those "unused" warnings

parent 65a0b9ac
/**
* RBAC2SMV - Tool for converting a RBAC specification
* to NuSMV specification
*/
package mohawk.collections;
import java.util.Map;
/**
* @author Karthick Jayaram
*
* This binary tree is meant for maintaining the parse tree for preconditions. All the leaf nodes represent an
* operand. All intermediate nodes represent an operation - AND / OR.
*/
public class BTree {
Node nHead;
Node nTail;
Map<Integer, String> mapRoleIndex;
BitVector bvRoleVec;
int uiSize;
public BTree(Map<Integer, String> inRoleIndex) {
nHead = null;
uiSize = 0;
mapRoleIndex = inRoleIndex;
// Initialize bit vector
if (!mapRoleIndex.isEmpty()) {
int iBVSize = mapRoleIndex.size();
bvRoleVec = new BitVector(iBVSize, false);
}
}
public Node add2Left(Node inNode) {
if (nHead == null) {
// Adding the first element to the binary tree
nHead = inNode;
nTail = inNode;
uiSize++;
} else {
nTail.nLeft = inNode;
nTail = inNode;
uiSize++;
}
return inNode;
}
public Node add2Right(Node inNode) {
if (nHead == null) {
// Adding the first element to the binary tree
nHead = inNode;
nTail = inNode;
nHead.nLeft = null;
nHead.nRight = null;
uiSize++;
} else {
nTail.nRight = inNode;
nTail = inNode;
uiSize++;
}
return inNode;
}
public void printTree() {
printNode(nHead);
}
// Recursive print.
public void printNode(Node inNode) {
if (inNode.iType == 1) {
System.out.println(inNode.iOperation);
} else if (inNode.iType == 2) {
System.out.println(inNode.sOperand);
} else {
System.out.println("NULL");
}
if (inNode.nLeft != null) {
printNode(inNode.nLeft);
}
if (inNode.nRight != null) {
printNode(inNode.nRight);
}
}
private int getMapIndex(String inRole) throws Exception {
for (int i = 0; i < mapRoleIndex.size(); i++) {
if (mapRoleIndex.get(i).equals(inRole)) { return i; }
}
throw new Exception("Error - BTree::getMapIndex - Role not found in map");
}
public BitVector getBV() throws Exception {
if (this.nHead != null) {
return getBV(this.nHead);
} else {
throw new Exception("Error - BTree::getBV - nHead is null");
}
}
public BitVector getBV(Node inNode) throws Exception {
BitVector result = new BitVector(uiSize, false);
if (inNode.iType == 2) {
result.putAt(getMapIndex(inNode.sOperand), true);
return result;
} else if (inNode.iType == 1) {
BitVector result1 = getBV(inNode.nLeft);
BitVector result2 = getBV(inNode.nRight);
if (inNode.iOperation == 0) {
result = result1.andBV(result2);
return result;
} else {
result = result1.orBV(result2);
return result;
}
} else {
throw new Exception("Error - BitVector::getBV - The control is not expected to come here");
}
}
}
/**
* RBAC2SMV - Tool for converting a RBAC specification
* to NuSMV specification
*/
package mohawk.collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Vector;
/**
* @author kjayaram
*
*/
public class BTreeDriver {
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
Vector<BitVector> vecUA;
Map<Integer, String> map = new HashMap<Integer, String>();
map.put(0, "Hello");
map.put(1, "World");
// BTree btree = new BTree(map);
Node node1 = new Node(null, null, 1, 1);
Node node2 = new Node(null, null, 2, "Hello");
Node node3 = new Node(null, null, 2, "World");
// Node node4 = new Node(null, null, 1, 2);
// btree.add2Right(node1);
// btree.add2Right(node2);
// btree.add2Right(node4);
// btree.add2Left(node3);
// btree.printTree();
PreCondProcessor proc = new PreCondProcessor(map);
proc.add(0);
proc.add("Hello");
proc.add(1);
proc.add("World");
proc.add(3);
proc.add(2);
proc.add(0);
proc.add("Hello");
proc.add(2);
proc.add("World");
proc.add(3);
proc.result().printBV();
}
}
/**
* RBAC2SMV - Tool for converting a RBAC specification
* to NuSMV specification
*
* @author Karthick Jayaraman
*/
package mohawk.collections;
/**
* @author kjayaram
*
*/
public class BVException extends Exception {
/**
*
*/
private static final long serialVersionUID = 1L;
public BVException() {
}
}
/**
* RBAC2SMV - Tool for converting a RBAC specification
* to NuSMV specification
*
* @author Karthick Jayaraman
*/
package mohawk.collections;
import java.util.Vector;
/**
* @author kjayaram
*
*/
public class IntVector {
/*
* Each integer in the vector represents a condition on the role. 0 - No condition on the role 1 - Role is part of
* pre condition 2 - Negation of role is part of precondition. i.e The role should not be present.
*/
private Vector<Integer> vecIV;
private int size;
public IntVector(int inSize, int inValue) {
size = inSize;
vecIV = new Vector<Integer>(size);
for (int i = 0; i < size; i++)
vecIV.add(inValue);
}
public int size() {
return size;
}
public void printIV() {
int size = vecIV.size();
System.out.println("Size of the bit vector: " + size);
for (int i = 0; i < size; i++)
System.out.print(vecIV.get(i).toString() + " ");
System.out.println();
}
// Get the value at a specified index
public int atIndex(int inIndex) {
return vecIV.get(inIndex);
}
// Set the value at a specified index
public void putAt(int inIndex, int inValue) {
vecIV.set(inIndex, inValue);
}
// logical AND operation
public IntVector andIV(IntVector inOperand2) throws Exception {
if (size != inOperand2.size) { throw new Exception("Error - IntVector::andIV - Operand sizes do not match"); }
IntVector result = new IntVector(size, 0);
for (int i = 0; i < size; i++) {
if (atIndex(i) != inOperand2.atIndex(i))
result.putAt(i, 0);
}
return result;
}
// logical OR operation
public IntVector orIV(IntVector inOperand2) throws Exception {
if (size != inOperand2.size) { throw new Exception("Error - IntVector::orIV - Operand sizes do not match"); }
IntVector result = new IntVector(size, 0);
for (int i = 0; i < size; i++) {
if (atIndex(i) == 1 || inOperand2.atIndex(i) == 1)
result.putAt(i, 1);
}
return result;
}
}
/**
* RBAC2SMV - Tool for converting a RBAC specification
* to NuSMV specification
*/
package mohawk.collections;
/**
* @author Karthick Jayaraman
*
*/
public class Node {
Node nLeft;
Node nRight;
// 1 - Node is of type OP 2 - Node is of type Operand
int iType;
// A node can either store an OP or and Operand
int iOperation;
String sOperand;
public Node() {
nLeft = null;
nRight = null;
iType = 0;
iOperation = 0;
sOperand = null;
}
public Node(Node inLeft, Node inRight, int inType, int inOperation) {
nLeft = inLeft;
nRight = inRight;
iType = inType;
iOperation = inOperation;
}
public Node(Node inLeft, Node inRight, int inType, String inOperand) {
nLeft = inLeft;
nRight = inRight;
iType = inType;
sOperand = inOperand;
}
}
/**
* RBAC2SMV - Tool for converting a RBAC specification
* to NuSMV specification
*
* @author Karthick Jayaraman
*/
package mohawk.collections;
import java.util.Map;
import java.util.Stack;
public class PreCondProcessor {
Stack<BitVector> stckRoles;
Stack<Integer> stckOperators;
Map<Integer, String> mRoleIndex;
public PreCondProcessor(Map<Integer, String> inRoleIndex) {
mRoleIndex = inRoleIndex;
stckRoles = new Stack<BitVector>();
stckOperators = new Stack<Integer>();
}
private int getMapKey(Map<Integer, String> inMap, String inString) {
for (int i = 0; i < inMap.size(); i++) {
if (inMap.get(i).equals(inString)) { return i; }
}
System.out.println("Error - PreCondProcessor::getMapIndex - Value not found in map");
return 0;
}
public void add(String strRole) {
int iRoleIndex = getMapKey(mRoleIndex, strRole);
BitVector bvRole = new BitVector(mRoleIndex.size(), false);
bvRole.putAt(iRoleIndex, true);
stckRoles.add(bvRole);
}
public void add(int iOperation) throws Exception {
if (stckOperators.empty()) {
stckOperators.add(iOperation);
} else {
// int iStckOper = stckOperators.peek();
// 0 - ( 2 - AND 1 - OR 3 - ). AND has precedence over OR
if (iOperation == 3) {
// Pop out all arguments until an opening "(" is seen.
while (true) {
int iStckOper = stckOperators.pop();
if (iStckOper == 0) {
break;
}
BitVector bvOperand1 = stckRoles.pop();
BitVector bvOperand2 = stckRoles.pop();
if (iStckOper == 1) {
bvOperand2 = bvOperand1.orBV(bvOperand2);
} else {
bvOperand2 = bvOperand1.andBV(bvOperand2);
}
stckRoles.add(bvOperand2);
}
} else {
stckOperators.add(iOperation);
}
}
}
public void process() throws Exception {
while (!stckOperators.empty()) {
BitVector bvOperand1 = stckRoles.pop();
BitVector bvOperand2 = stckRoles.pop();
int iOper = stckOperators.pop();
if (iOper == 1) {
bvOperand2 = bvOperand2.orBV(bvOperand1);
} else {
bvOperand2 = bvOperand2.andBV(bvOperand1);
}
stckRoles.add(bvOperand2);
}
}
public BitVector result() throws Exception {
process();
return stckRoles.pop();
}
}
......@@ -3,11 +3,7 @@
*/
package mohawk.math;
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.*;
......@@ -31,7 +27,7 @@ public class CalculateRplus {
public Set<String> CalIrrevocableRoles() {
int iRevRoles = rbac_instance.getNumRoles() - rbac_instance.getCR().keySet().size();
// int iRevRoles = rbac_instance.getNumRoles() - rbac_instance.getCR().keySet().size(); // NEVER USED
Set<String> RevocableRoles = new HashSet<String>();
Set<String> IrrevocableRoles = new HashSet<String>(rbac_instance.getRoles());
......@@ -40,7 +36,7 @@ public class CalculateRplus {
for (int i = 0; i < vCRE.size(); i++) {
CREntry cre = vCRE.get(i);
if (cre.getPreCond().equals("FALSE")) {
iRevRoles++;
// iRevRoles++; // NEVER USED
} else {
RevocableRoles.add(cre.getStrRole());
}
......
......@@ -130,7 +130,7 @@ public class RBAC2SMV {
return size;
}
private static int getCRSize(Map<String, Vector<CREntry>> mCR) {
public static int getCRSize(Map<String, Vector<CREntry>> mCR) {
int size = 0;
Collection<Vector<CREntry>> carules = mCR.values();
Iterator<Vector<CREntry>> iterator = carules.iterator();
......
......@@ -39,7 +39,7 @@ public class RolesAbsRefine {
private Map<String, Vector<CAEntry>> mAllCA;
private Map<String, Vector<CREntry>> mAllCR;
private Map<String, Vector<Integer>> mAllUA;
private int refinementstep;
public int refinementstep;
private String strRole;
private int k;
private int lastpriority;
......@@ -98,8 +98,8 @@ public class RolesAbsRefine {
// NuSMV bmc
Boolean result;
if (mode == NuSMVMode.BMC) {
CalculateDiameter diameter = new CalculateDiameter();
int bound = diameter.GetDiameter(curInstance);
// CalculateDiameter diameter = new CalculateDiameter(); // NEVER USED
int bound = CalculateDiameter.GetDiameter(curInstance);
System.out.println(String.format("Estimate Diameter - No of Roles %d Diameter %d",
curInstance.getNumRoles(), bound));
......
......@@ -3,14 +3,7 @@
*/
package mohawk.slicer;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Vector;
import java.util.*;
import java.util.logging.Logger;
import mohawk.global.pieces.mohawk.*;
......@@ -24,7 +17,7 @@ public class RoleSlicer {
public final static Logger logger = Logger.getLogger("mohawk");
private RBACInstance unsliced;
private RBACInstance sliced;
// private RBACInstance sliced; // NEVER USED
private String strRole;
private String strUser;
......@@ -34,7 +27,7 @@ public class RoleSlicer {
private Map<String, Vector<Integer>> slicedUA;
private Map<String, Vector<CREntry>> slicedCR;
private Map<String, Vector<CAEntry>> slicedCA;
private Vector<String> slicedSpec;
// private Vector<String> slicedSpec; // NEVER USED
// Helpers for identifying dependencies
private Vector<String> vPositiveDeps;
......@@ -69,7 +62,8 @@ public class RoleSlicer {
System.out.println("Slicing CR");
slicedCR = sliceCR();
return new RBACInstance(slicedRoles, slicedUsers, slicedAdmin, slicedUA, slicedCR, slicedCA, unsliced.getSpec());
return new RBACInstance(slicedRoles, slicedUsers, slicedAdmin, slicedUA, slicedCR, slicedCA,
unsliced.getSpec());
}
/*
......
......@@ -3,10 +3,7 @@
*/
package mohawk.slicer;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Vector;
import java.util.*;
import java.util.logging.Logger;
import mohawk.global.pieces.mohawk.CAEntry;
......@@ -21,9 +18,9 @@ public class SliceQueryRole {
public final static Logger logger = Logger.getLogger("mohawk");
private RBACInstance unsliced;
private RBACInstance sliced;
// private RBACInstance sliced; // NEVER USED
private String strRole;
private String strUser;
// private String strUser; // NEVER USED
private Vector<String> slicedRoles;
private Vector<String> slicedUsers;
......@@ -31,24 +28,22 @@ public class SliceQueryRole {
private Map<String, Vector<Integer>> slicedUA;
private Map<String, Vector<CREntry>> slicedCR;
private Map<String, Vector<CAEntry>> slicedCA;
private Vector<String> slicedSpec;
// private Vector<String> slicedSpec; // NEVER USED
// Helpers for identifying dependencies
private Vector<String> vPositiveDeps;
private Vector<String> vNegativeDeps;
// private Vector<String> vPositiveDeps; // NEVER USED
// private Vector<String> vNegativeDeps; // NEVER USED
/*
* This is a map between role indices of unsliced roles and and sliced roles.
*/
private Map<Integer, Integer> mapRoleIndex;
// private Map<Integer, Integer> mapRoleIndex; // NEVER USED
public SliceQueryRole(RBACInstance inRbac) {
unsliced = inRbac;
strRole = unsliced.getSpec().get(1);
strUser = unsliced.getSpec().get(0);
mapRoleIndex = new HashMap<Integer, Integer>();
// strUser = unsliced.getSpec().get(0); // NEVER USED
// mapRoleIndex = new HashMap<Integer, Integer>(); // NEVER USED
}
public RBACInstance getSlicedPolicy() throws Exception {
......@@ -63,7 +58,8 @@ public class SliceQueryRole {
System.out.println("Slicing CA");
slicedCA = sliceCA();
return new RBACInstance(slicedRoles, slicedUsers, slicedAdmin, slicedUA, slicedCR, slicedCA, unsliced.getSpec());
return new RBACInstance(slicedRoles, slicedUsers, slicedAdmin, slicedUA, slicedCR, slicedCA,
unsliced.getSpec());
}
/*
......
......@@ -78,6 +78,7 @@ public class TestingSuite {
public void runTests() throws IOException {
logger.entering(getClass().getName(), "runTests()");
logger.info("[runTests] Results File: " + testingResultsFile);
FileWriter resultsFW = results.getFileWriter(new File(testingResultsFile), false);
if (resultsFW == null) {
......
......@@ -4,10 +4,7 @@
package mohawk.util;
import java.io.File;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.Vector;
import java.util.*;
import mohawk.global.pieces.mohawk.CAEntry;
import mohawk.global.pieces.mohawk.CREntry;
......@@ -27,7 +24,7 @@ public class RoleAnalysis {
* @param args
*/
public static void main(String[] args) {
int oldroles, oldusers, oldcarules, oldcrrules;
// int oldroles, oldusers, oldcarules, oldcrrules; // NEVER USED
if (args.length < 2) {
System.out.println("Usage: java -jar ./rbac2smv.jar RoleAnalysis rbacspec nusmvfile");
......@@ -44,10 +41,10 @@ public class RoleAnalysis {
RBACSpecReader rbacreader = new RBACSpecReader(args[0]);
rbac = rbacreader.getRBAC();
oldroles = rbac.getRoles().size();
oldusers = rbac.getUsers().size();
oldcarules = getCASize(rbac.getCA());
oldcrrules = getCRSize(rbac.getCR());
// oldroles = rbac.getRoles().size(); // NEVER USED
// oldusers = rbac.getUsers().size(); // NEVER USED
// oldcarules = getCASize(rbac.getCA()); // NEVER USED
// oldcrrules = getCRSize(rbac.getCR()); // NEVER USED
Vector<CAEntry> AllDisjuncts = rbac.getCA().get(rbac.getSpec().get(1));
Map<String, Vector<CAEntry>> mCA = rbac.getCA();
......
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