Commit a30015c2 authored by Jonathan Shahen's avatar Jonathan Shahen

Allowing for a choice between version for outputting the NuSMV format;...

Allowing for a choice between version for outputting the NuSMV format; WARNING: version 2 is not complete and should not be used until it is finished and tested
parent cdd36ea1
......@@ -47,16 +47,24 @@ public class WriteNuSMV {
// RBAC Instance
private RBACInstance rbac;
private ST strTCodeTemplate;
/**
* This setting changes how the user transitions are computed
* The result should be functionally the same, but organized differently
* WARNING: version 2 DOES NOT WORK and is incomplete, it must be finished up later
*/
public Integer userTransistionVersion = 1;
private String strTransTemplate;
private ST strTCodeTemplateV1;
private ST strTCodeTemplateV2;
private String strTransTemplateV1;
private String strTransTemplateV2;
/**
* Controls the output for this class
*/
public Level logLevel = Level.WARNING;
public Integer userTransistionVersion = 1;
public boolean includeRuleComment = true;
public Integer roleWithRules;
public Integer roleWithoutRules;
......@@ -79,8 +87,11 @@ public class WriteNuSMV {
try {
// String template = ConvertTo.readFile(this.getClass().getResource("smvtemplate.st"));
strTCodeTemplate = new ST(getTemplateStr("smvtemplate.st"), '$', '$');
strTransTemplate = getTemplateStr("transitions.st");
strTCodeTemplateV1 = new ST(getTemplateStr("smvtemplatev1.st"), '$', '$');
strTransTemplateV1 = getTemplateStr("transitionsv1.st");
strTCodeTemplateV2 = new ST(getTemplateStr("smvtemplatev2.st"), '<', '>');
strTransTemplateV2 = getTemplateStr("transitionsv2.st");
} catch (IOException e) {
e.printStackTrace();
}
......@@ -167,22 +178,22 @@ public class WriteNuSMV {
System.out.println("[START] Setting up user arrays...");
/* TIMING */timing.startTimer(timingPrefix + " (Setting up user arrays)");
setupUsers(strTCodeTemplate);
setupUsers(strTCodeTemplateV1);
/* TIMING */timing.stopTimer(timingPrefix + " (Setting up user arrays)");
System.out.println("[START] Setting up UA...");
/* TIMING */timing.startTimer(timingPrefix + " (Setting up UA)");
setupUA(strTCodeTemplate);
setupUA(strTCodeTemplateV1);
/* TIMING */timing.stopTimer(timingPrefix + " (Setting up UA)");
System.out.println("[START] Setting up CA-CR rules...");
System.out.println("[START] Setting up CA-CR rules (Using version " + userTransistionVersion + ") ...");
/* TIMING */timing.startTimer(timingPrefix + " (Setting up CA-CR rules v" + userTransistionVersion + ")");
switch (userTransistionVersion) {
case 1:
setupUserTransitionsv1(strTCodeTemplate);
setupUserTransitionsv1(strTCodeTemplateV1);
break;
case 2:
setupUserTransitionsv2(strTCodeTemplate);
setupUserTransitionsv2(strTCodeTemplateV1);
break;
}
/* TIMING */timing.stopTimer(timingPrefix + " (Setting up CA-CR rules v" + userTransistionVersion + ")");
......@@ -192,13 +203,13 @@ public class WriteNuSMV {
/* TIMING */timing.startTimer(timingPrefix + " (Setting up SPEC)");
String strUser = rbac.getSpec().get(0);
String strRole = rbac.getSpec().get(1);
setupSpec(strTCodeTemplate, strUser, strRole);
setupSpec(strTCodeTemplateV1, strUser, strRole);
/* TIMING */timing.stopTimer(timingPrefix + " (Setting up SPEC)");
// this.setupTransactions(this.strCodeTemplate, this.strCodeTemplate);
System.out.println("[START] Rendering SMV Code...");
/* TIMING */timing.startTimer(timingPrefix + " (Rendering SMV Code)");
smvcode = strTCodeTemplate.render();
smvcode = strTCodeTemplateV1.render();
/* TIMING */timing.stopTimer(timingPrefix + " (Rendering SMV Code)");
done = true;
......@@ -293,7 +304,7 @@ public class WriteNuSMV {
Vector<CREntry> vCR = getMatchingCR(strRole);
StringBuilder transitions = null;
String strTmpUser = null;
ST strTTrans = new ST(strTransTemplate, '$', '$');
ST strTTrans = new ST(strTransTemplateV1, '$', '$');
if (vCA != null) {
for (int j = 0; j < vCA.size(); j++) {
......@@ -496,7 +507,7 @@ public class WriteNuSMV {
Vector<CREntry> vCR = getMatchingCR(strRole);
StringBuilder transitions = null;
String strTmpUser = null;
ST strTTrans = new ST(strTransTemplate, '$', '$');
ST strTTrans = new ST(strTransTemplateV1, '$', '$');
if (vCA != null) {
for (int j = 0; j < vCA.size(); j++) {
......
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