Commit 53db13b0 authored by Jonathan Shahen's avatar Jonathan Shahen

Updating code to reflect name changes for runctions, renaming of files, and a few comments

parent 38a4c5bc
......@@ -35,10 +35,10 @@ public class CalculateRplus {
Vector<CREntry> vCRE = rbac_instance.getCR().get(strRole);
for (int i = 0; i < vCRE.size(); i++) {
CREntry cre = vCRE.get(i);
if (cre.getPreCond().equals("FALSE")) {
if (cre.getAdminRole().equals("FALSE")) {
// iRevRoles++; // NEVER USED
} else {
RevocableRoles.add(cre.getStrRole());
RevocableRoles.add(cre.getTargetRole());
}
}
}
......
......@@ -76,7 +76,7 @@ public class WriteNuSMV {
/*
* The constructor should initialize the target file and the filename for the template.
*/
public WriteNuSMV(String fname, String tname, MohawkTiming timing, String timingPrefix) {
public WriteNuSMV(String fname, MohawkTiming timing, String timingPrefix) {
this.timing = timing;
this.timingPrefix = timingPrefix;
......@@ -117,7 +117,7 @@ public class WriteNuSMV {
Map<String, Vector<CAEntry>> mCA = rbac.getCA();
if (mCA != null)
return rbac.getCA().get(strRole);
return mCA.get(strRole);
else
return null;
......@@ -193,7 +193,7 @@ public class WriteNuSMV {
setupUserTransitionsv1(strTCodeTemplateV1);
break;
case 2:
setupUserTransitionsv2(strTCodeTemplateV1);
setupUserTransitionsv2(strTCodeTemplateV2);
break;
}
/* TIMING */timing.stopTimer(timingPrefix + " (Setting up CA-CR rules v" + userTransistionVersion + ")");
......@@ -219,7 +219,7 @@ public class WriteNuSMV {
public void setupUsers(ST inSmvSpec) {
int noRoles = rbac.getRoles().size();
int noRoles = rbac.getNumRoles();
Vector<String> vUsers = rbac.getUsers();
Vector<String> vAdmin = rbac.getAdmin();
......@@ -434,14 +434,14 @@ public class WriteNuSMV {
int iDestRoleIndex = 0;
try {
iDestRoleIndex = rbac.getRoleIndex(crentry.getStrRole());
iDestRoleIndex = rbac.getRoleIndex(crentry.getTargetRole());
if (crentry.getPreCond().equalsIgnoreCase("true")) {
if (crentry.getAdminRole().equalsIgnoreCase("true")) {
adminRoleIndex = -1;
} else if (crentry.getPreCond().equalsIgnoreCase("false")) {
} else if (crentry.getAdminRole().equalsIgnoreCase("false")) {
adminRoleIndex = -2;
} else {
adminRoleIndex = rbac.getRoleIndex(crentry.getPreCond());
adminRoleIndex = rbac.getRoleIndex(crentry.getAdminRole());
}
} catch (Exception e) {
e.printStackTrace();
......@@ -643,14 +643,14 @@ public class WriteNuSMV {
int iDestRoleIndex = 0;
try {
iDestRoleIndex = rbac.getRoleIndex(crentry.getStrRole());
iDestRoleIndex = rbac.getRoleIndex(crentry.getTargetRole());
if (crentry.getPreCond().equalsIgnoreCase("true")) {
if (crentry.getAdminRole().equalsIgnoreCase("true")) {
adminRoleIndex = -1;
} else if (crentry.getPreCond().equalsIgnoreCase("false")) {
} else if (crentry.getAdminRole().equalsIgnoreCase("false")) {
adminRoleIndex = -2;
} else {
adminRoleIndex = rbac.getRoleIndex(crentry.getPreCond());
adminRoleIndex = rbac.getRoleIndex(crentry.getAdminRole());
}
} catch (Exception e) {
e.printStackTrace();
......
......@@ -19,13 +19,14 @@ public class WriteRBACSpec {
// StringTemplate for RBAC instance
private ST STRBACSpec;
private String templateFilename = "rbac.st";
// RBAC instance to write to file.
private RBACInstance rbacinstance;
public WriteRBACSpec(String filename) {
public WriteRBACSpec() {
try {
String strTemplateString = this.getTemplateStr(filename);
String strTemplateString = this.getTemplateStr(templateFilename);
STRBACSpec = new ST(strTemplateString, '$', '$');
} catch (IOException e) {
e.printStackTrace();
......@@ -104,10 +105,10 @@ public class WriteRBACSpec {
if (i < 2) {
// if(rndGen.nextInt(2) == 1)
// vecCR.get(i).setPreCond("FALSE");
STCR.add("crrule", cre.getPreCond());
STCR.add("crrule", cre.getAdminRole());
}
STCR.add("crrule", cre.getStrRole());
STCR.add("crrule", cre.getTargetRole());
STRBACSpec.add("cr", STCR.render());
setOne = true;
}
......
......@@ -77,6 +77,18 @@ public class RBACInstance {
return getMapKey(mRoleIndex, inStrRole);
}
public String getUserFromIndex(Integer userIndex) throws Exception {
return mUserIndex.get(userIndex);
}
public String getRoleFromIndex(Integer roleIndex) throws Exception {
return mRoleIndex.get(roleIndex);
}
public Map<Integer, String> getRoleMap() {
return mRoleIndex;
}
private int getMapKey(Map<Integer, String> inMap, String inString) throws Exception {
for (int i = 0; i < inMap.size(); i++) {
......
......@@ -43,29 +43,25 @@ public class RBACSpecReader {
}
}
public RBACSpecReader(String filename) {
try {
File rbacfile = new File(filename);
public RBACSpecReader(String filename) throws IOException {
File rbacfile = new File(filename);
if (!rbacfile.exists()) {
System.out.println("The RBAC specification file " + rbacfile + " does not exists.");
return;
}
if (!rbacfile.exists()) {
System.out.println("The RBAC specification file " + rbacfile + " does not exists.");
return;
}
InputStream is = new FileInputStream(filename);
ANTLRInputStream input = new ANTLRInputStream(is);
MohawkLexer lexer = new MohawkLexer(input);
CommonTokenStream tokens = new CommonTokenStream(lexer);
MohawkParser parser = new MohawkParser(tokens);
InputStream is = new FileInputStream(filename);
ANTLRInputStream input = new ANTLRInputStream(is);
MohawkLexer lexer = new MohawkLexer(input);
CommonTokenStream tokens = new CommonTokenStream(lexer);
MohawkParser parser = new MohawkParser(tokens);
parser.initRbac();
parser.initRbac();
parser.init();
rbac = new RBACInstance(parser.vRoles, parser.vUsers, parser.vAdmin, parser.mUA, parser.mCR, parser.mCA,
parser.vSpec);
} catch (RecognitionException | IOException e) {
e.printStackTrace();
}
parser.init();
rbac = new RBACInstance(parser.vRoles, parser.vUsers, parser.vAdmin, parser.mUA, parser.mCR, parser.mCA,
parser.vSpec);
}
public RBACInstance getRBAC() {
......
......@@ -96,8 +96,7 @@ public class RolesAbsRefine {
}
public Boolean getResult(RBACInstance curInstance, Integer fileno) throws Exception {
WriteNuSMV nusmv = new WriteNuSMV("logs/smvinstancefile" + fileno + ".txt", "smvtemplate",
timing, timingPrefix);
WriteNuSMV nusmv = new WriteNuSMV("logs/smvinstancefile" + fileno + ".txt", timing, timingPrefix);
nusmv.fillAttributes(curInstance);
if (!skipSMVFile) {
......@@ -234,7 +233,7 @@ public class RolesAbsRefine {
try {
while (refine()) {
try {
WriteRBACSpec writer = new WriteRBACSpec("rbac.st");
WriteRBACSpec writer = new WriteRBACSpec();
writer.Write2File(nextinstance, "logs/rbacinstancefile" + fileno + ".txt");
} catch (IOException e1) {
e1.printStackTrace();
......
......@@ -56,7 +56,7 @@ public class RoleSlicer {
public RBACInstance getSlicedPolicy() throws Exception {
/* TIMING */timing.startTimer(timingPrefix + " (slicingTotal)");
System.out.println("[START] getSlicedPolicy()");
System.out.println("[START] RoleSlicer.getSlicedPolicy()");
System.out.println("[START] Slicing roles");
/* TIMING */timing.startTimer(timingPrefix + " (slicing roles)");
......
......@@ -20,7 +20,7 @@ public class MohawkRegressionTests {
@Test
public void runPositive1() {
String param = "-input data/regressiontests/positive1.spec -run all -mode bmc";
String param = "-input data/regressiontests/positive1.mohawk -run all -mode bmc";
ExecutionResult expectedResult = ExecutionResult.GOAL_REACHABLE;
MohawkInstance mohawk = new MohawkInstance();
......@@ -31,7 +31,7 @@ public class MohawkRegressionTests {
@Test
public void runPositive2() {
String param = "-input data/regressiontests/positive2.spec -run all -mode bmc";
String param = "-input data/regressiontests/positive2.mohawk -run all -mode bmc";
ExecutionResult expectedResult = ExecutionResult.GOAL_REACHABLE;
MohawkInstance mohawk = new MohawkInstance();
......@@ -42,7 +42,7 @@ public class MohawkRegressionTests {
@Test
public void runPositive3() {
String param = "-input data/regressiontests/positive3.spec -run all -mode bmc";
String param = "-input data/regressiontests/positive3.mohawk -run all -mode bmc";
ExecutionResult expectedResult = ExecutionResult.GOAL_REACHABLE;
MohawkInstance mohawk = new MohawkInstance();
......@@ -53,7 +53,7 @@ public class MohawkRegressionTests {
@Test
public void runPositive4() {
String param = "-input data/regressiontests/positive4.spec -run all -mode bmc";
String param = "-input data/regressiontests/positive4.mohawk -run all -mode bmc";
ExecutionResult expectedResult = ExecutionResult.GOAL_REACHABLE;
MohawkInstance mohawk = new MohawkInstance();
......@@ -64,7 +64,7 @@ public class MohawkRegressionTests {
@Test
public void runHeuristic1() {
String param = "-input data/regressiontests/heuristic1.spec -run all -mode bmc";
String param = "-input data/regressiontests/heuristic1.mohawk -run all -mode bmc";
ExecutionResult expectedResult = ExecutionResult.GOAL_UNREACHABLE;
MohawkInstance mohawk = new MohawkInstance();
......@@ -75,7 +75,7 @@ public class MohawkRegressionTests {
@Test
public void runHeuristic2() {
String param = "-input data/regressiontests/heuristic2.spec -run all -mode bmc";
String param = "-input data/regressiontests/heuristic2.mohawk -run all -mode bmc";
ExecutionResult expectedResult = ExecutionResult.GOAL_REACHABLE;
MohawkInstance mohawk = new MohawkInstance();
......@@ -86,7 +86,7 @@ public class MohawkRegressionTests {
@Test
public void runHeuristic3() {
String param = "-input data/regressiontests/heuristic3.spec -run all -mode bmc";
String param = "-input data/regressiontests/heuristic3.mohawk -run all -mode bmc";
ExecutionResult expectedResult = ExecutionResult.GOAL_REACHABLE;
MohawkInstance mohawk = new MohawkInstance();
......
......@@ -26,7 +26,7 @@ public class TestRunner implements Callable<TestingResult> {
if (settings.skipRefine) {
try {
WriteRBACSpec writer = new WriteRBACSpec("rbac.st");
WriteRBACSpec writer = new WriteRBACSpec();
writer.Write2File(absrefine.getInputRBACInstance(), "logs/rbacinstancefile" + 1 + ".txt");
} catch (IOException e1) {
e1.printStackTrace();
......
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