Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
mohawk-2.0
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jon Shahen
mohawk-2.0
Commits
89185bf4
Commit
89185bf4
authored
Jan 08, 2016
by
Jonathan Shahen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add timing to old code and update the TestingResult to add the return code
parent
8c735bb6
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
325 additions
and
53 deletions
+325
-53
src/mohawk/helper/SMVSpecHelper.java
src/mohawk/helper/SMVSpecHelper.java
+8
-5
src/mohawk/output/WriteNuSMV.java
src/mohawk/output/WriteNuSMV.java
+247
-17
src/mohawk/refine/RolesAbsRefine.java
src/mohawk/refine/RolesAbsRefine.java
+18
-11
src/mohawk/slicer/RoleSlicer.java
src/mohawk/slicer/RoleSlicer.java
+35
-8
src/mohawk/testing/TestRunner.java
src/mohawk/testing/TestRunner.java
+1
-1
src/mohawk/testing/TestingSuite.java
src/mohawk/testing/TestingSuite.java
+16
-11
No files found.
src/mohawk/helper/SMVSpecHelper.java
View file @
89185bf4
...
@@ -85,18 +85,20 @@ public class SMVSpecHelper {
...
@@ -85,18 +85,20 @@ public class SMVSpecHelper {
}
}
try
{
try
{
WriteNuSMV
nusmv
=
new
WriteNuSMV
(
nusmvFile
.
getAbsolutePath
(),
"smvtemplate"
);
WriteNuSMV
nusmv
=
new
WriteNuSMV
(
nusmvFile
.
getAbsolutePath
(),
"smvtemplate"
,
settings
.
timing
,
"convertSpecToSMVFormat("
+
specFile
.
getName
()
+
")"
);
RBACSpecReader
reader
=
new
RBACSpecReader
(
specFile
.
getAbsolutePath
());
RBACSpecReader
reader
=
new
RBACSpecReader
(
specFile
.
getAbsolutePath
());
RBACInstance
rbac
=
reader
.
getRBAC
();
RBACInstance
rbac
=
reader
.
getRBAC
();
if
(
settings
.
sliceRBAC
)
{
if
(
settings
.
sliceRBAC
)
{
logger
.
info
(
"[Slicing] Slicing the Spec File"
);
logger
.
info
(
"[Slicing] Slicing the Spec File"
);
RoleSlicer
roleslicer
=
new
RoleSlicer
(
rbac
);
RoleSlicer
roleslicer
=
new
RoleSlicer
(
rbac
,
settings
.
timing
,
"convertSpecToSMVFormat("
+
specFile
.
getName
()
+
")"
);
rbac
=
roleslicer
.
getSlicedPolicy
();
rbac
=
roleslicer
.
getSlicedPolicy
();
logger
.
info
(
"[DETAILS] After Slicing -> Number of Roles: "
+
rbac
.
getNumRoles
()
+
"; Number of Rules: "
logger
.
info
(
"[DETAILS] After Slicing -> Number of Roles: "
+
rbac
.
getNumRoles
()
+
+
(
rbac
.
getCA
().
size
()
+
rbac
.
getCR
().
size
()));
"; Number of Rules: "
+
(
rbac
.
getCA
().
size
()
+
rbac
.
getCR
().
size
()));
}
}
if
(
settings
.
sliceRBACQuery
)
{
if
(
settings
.
sliceRBACQuery
)
{
...
@@ -109,7 +111,8 @@ public class SMVSpecHelper {
...
@@ -109,7 +111,8 @@ public class SMVSpecHelper {
if
(
settings
.
skipRefine
)
{
if
(
settings
.
skipRefine
)
{
nusmv
.
fillAttributes
(
rbac
);
nusmv
.
fillAttributes
(
rbac
);
}
else
{
}
else
{
RolesAbsRefine
absrefine
=
new
RolesAbsRefine
(
rbac
);
RolesAbsRefine
absrefine
=
new
RolesAbsRefine
(
rbac
,
settings
.
timing
,
"convertSpecToSMVFormat("
+
specFile
.
getName
()
+
")"
);
RBACInstance
rbac_refined
=
absrefine
.
refineOnly
();
RBACInstance
rbac_refined
=
absrefine
.
refineOnly
();
nusmv
.
fillAttributes
(
rbac_refined
);
nusmv
.
fillAttributes
(
rbac_refined
);
...
...
src/mohawk/output/WriteNuSMV.java
View file @
89185bf4
...
@@ -14,6 +14,7 @@ import java.util.logging.Level;
...
@@ -14,6 +14,7 @@ import java.util.logging.Level;
import
org.stringtemplate.v4.ST
;
import
org.stringtemplate.v4.ST
;
import
mohawk.global.pieces.mohawk.*
;
import
mohawk.global.pieces.mohawk.*
;
import
mohawk.global.timing.MohawkTiming
;
import
mohawk.rbac.RBACInstance
;
import
mohawk.rbac.RBACInstance
;
/*
/*
...
@@ -55,14 +56,22 @@ public class WriteNuSMV {
...
@@ -55,14 +56,22 @@ public class WriteNuSMV {
*/
*/
public
Level
logLevel
=
Level
.
WARNING
;
public
Level
logLevel
=
Level
.
WARNING
;
public
Integer
userTransistionVersion
=
1
;
public
boolean
includeRuleComment
=
true
;
public
boolean
includeRuleComment
=
true
;
public
Integer
roleWithRules
;
public
Integer
roleWithRules
;
public
Integer
roleWithoutRules
;
public
Integer
roleWithoutRules
;
// Timing
public
MohawkTiming
timing
;
public
String
timingPrefix
;
/*
/*
* The constructor should initialize the target file and the filename for the template.
* The constructor should initialize the target file and the filename for the template.
*/
*/
public
WriteNuSMV
(
String
fname
,
String
tname
)
{
public
WriteNuSMV
(
String
fname
,
String
tname
,
MohawkTiming
timing
,
String
timingPrefix
)
{
this
.
timing
=
timing
;
this
.
timingPrefix
=
timingPrefix
;
filename
=
fname
;
filename
=
fname
;
done
=
false
;
done
=
false
;
roleWithRules
=
0
;
roleWithRules
=
0
;
...
@@ -147,29 +156,54 @@ public class WriteNuSMV {
...
@@ -147,29 +156,54 @@ public class WriteNuSMV {
* Maybe This function should be passed an object that represents the RBAC state. The parameters should be plugged
* Maybe This function should be passed an object that represents the RBAC state. The parameters should be plugged
* into the template based on the RBAC state.
* into the template based on the RBAC state.
*/
*/
public
void
fillAttributes
(
RBACInstance
inRbac
)
throws
IO
Exception
{
public
void
fillAttributes
(
RBACInstance
inRbac
)
throws
Exception
{
/* TIMING */
timing
.
startTimer
(
timingPrefix
+
" (fillAttributes)"
);
rbac
=
inRbac
;
rbac
=
inRbac
;
// StringTemplate StrTSmvspec = new StringTemplate(strtemplate);
// StringTemplate StrTSmvspec = new StringTemplate(strtemplate);
// StringTemplate strTrans = new StringTemplate(transtemplate);
// StringTemplate strTrans = new StringTemplate(transtemplate);
System
.
out
.
println
(
"Setting up user arrays"
);
this
.
setupUsers
(
strTCodeTemplate
);
System
.
out
.
println
(
"[START] WriteNuSMV.fillAttributes()"
);
System
.
out
.
println
(
"Setting up UA"
);
this
.
setupUA
(
strTCodeTemplate
);
System
.
out
.
println
(
"[START] Setting up user arrays..."
);
System
.
out
.
println
(
"Setting up CA-CR rules"
);
/* TIMING */
timing
.
startTimer
(
timingPrefix
+
" (Setting up user arrays)"
);
this
.
setupUserTransitions
(
strTCodeTemplate
);
setupUsers
(
strTCodeTemplate
);
/* TIMING */
timing
.
stopTimer
(
timingPrefix
+
" (Setting up user arrays)"
);
System
.
out
.
println
(
"[START] Setting up UA..."
);
/* TIMING */
timing
.
startTimer
(
timingPrefix
+
" (Setting up UA)"
);
setupUA
(
strTCodeTemplate
);
/* TIMING */
timing
.
stopTimer
(
timingPrefix
+
" (Setting up UA)"
);
System
.
out
.
println
(
"[START] Setting up CA-CR rules..."
);
/* TIMING */
timing
.
startTimer
(
timingPrefix
+
" (Setting up CA-CR rules v"
+
userTransistionVersion
+
")"
);
switch
(
userTransistionVersion
)
{
case
1
:
setupUserTransitionsv1
(
strTCodeTemplate
);
break
;
case
2
:
setupUserTransitionsv2
(
strTCodeTemplate
);
break
;
}
/* TIMING */
timing
.
stopTimer
(
timingPrefix
+
" (Setting up CA-CR rules v"
+
userTransistionVersion
+
")"
);
// Setup LTLSPEC
// Setup LTLSPEC
System
.
out
.
println
(
"Setting up SPEC"
);
System
.
out
.
println
(
"[START] Setting up SPEC..."
);
/* TIMING */
timing
.
startTimer
(
timingPrefix
+
" (Setting up SPEC)"
);
String
strUser
=
rbac
.
getSpec
().
get
(
0
);
String
strUser
=
rbac
.
getSpec
().
get
(
0
);
String
strRole
=
rbac
.
getSpec
().
get
(
1
);
String
strRole
=
rbac
.
getSpec
().
get
(
1
);
setupSpec
(
strTCodeTemplate
,
strUser
,
strRole
);
setupSpec
(
strTCodeTemplate
,
strUser
,
strRole
);
/* TIMING */
timing
.
stopTimer
(
timingPrefix
+
" (Setting up SPEC)"
);
// this.setupTransactions(this.strCodeTemplate, this.strCodeTemplate);
// this.setupTransactions(this.strCodeTemplate, this.strCodeTemplate);
System
.
out
.
println
(
"[START] Rendering SMV Code..."
);
/* TIMING */
timing
.
startTimer
(
timingPrefix
+
" (Rendering SMV Code)"
);
smvcode
=
strTCodeTemplate
.
render
();
smvcode
=
strTCodeTemplate
.
render
();
/* TIMING */
timing
.
stopTimer
(
timingPrefix
+
" (Rendering SMV Code)"
);
done
=
true
;
done
=
true
;
/* TIMING */
timing
.
stopTimer
(
timingPrefix
+
" (fillAttributes)"
);
}
}
public
void
setupUsers
(
ST
inSmvSpec
)
{
public
void
setupUsers
(
ST
inSmvSpec
)
{
...
@@ -241,7 +275,203 @@ public class WriteNuSMV {
...
@@ -241,7 +275,203 @@ public class WriteNuSMV {
}
}
}
}
public
void
setupUserTransitions
(
ST
strTCodeTemplate
)
{
public
void
setupUserTransitionsv2
(
ST
strTCodeTemplate
)
throws
Exception
{
Vector
<
String
>
vUsers
=
rbac
.
getUsers
();
String
strTransitions
=
this
.
setupEachUserv2
(
vUsers
);
strTCodeTemplate
.
add
(
"transitions"
,
strTransitions
);
}
public
String
setupEachUserv2
(
Vector
<
String
>
vUsers
)
throws
Exception
{
Vector
<
String
>
vRoles
=
rbac
.
getRoles
();
String
strUserSection
=
null
;
for
(
int
i
=
0
;
i
<
vRoles
.
size
();
i
++)
{
String
strRole
=
vRoles
.
get
(
i
);
Vector
<
CAEntry
>
vCA
=
getMatchingCA
(
strRole
);
Vector
<
CREntry
>
vCR
=
getMatchingCR
(
strRole
);
StringBuilder
transitions
=
null
;
String
strTmpUser
=
null
;
ST
strTTrans
=
new
ST
(
strTransTemplate
,
'$'
,
'$'
);
if
(
vCA
!=
null
)
{
for
(
int
j
=
0
;
j
<
vCA
.
size
();
j
++)
{
String
strTmpTrans
=
addCAEntryv2
(
vUsers
,
vCA
.
get
(
j
));
if
(
transitions
==
null
)
{
transitions
=
new
StringBuilder
();
transitions
=
transitions
.
append
(
strTmpTrans
);
}
else
{
transitions
.
append
(
"\n"
);
transitions
.
append
(
strTmpTrans
);
// transitions = transitions + "\n" + strTmpTrans;
}
}
}
if
(
vCR
!=
null
)
{
for
(
int
j
=
0
;
j
<
vCR
.
size
();
j
++)
{
String
strTmpTrans
=
addCREntryv2
(
vUsers
,
vCR
.
get
(
j
));
if
(
transitions
==
null
)
{
transitions
=
new
StringBuilder
();
transitions
=
transitions
.
append
(
strTmpTrans
);
}
else
{
transitions
.
append
(
"\n"
);
transitions
.
append
(
strTmpTrans
);
// transitions = transitions + "\n" + strTmpTrans;
}
}
}
if
(
transitions
!=
null
)
{
strTTrans
.
add
(
"rolename"
,
strRole
);
strTTrans
.
add
(
"transition"
,
transitions
);
strTTrans
.
add
(
"trueWord"
,
getTrue
());
strTmpUser
=
""
;
for
(
String
u
:
vUsers
)
{
strTTrans
.
add
(
"roleindex1"
,
u
+
"["
+
i
+
"]"
);
strTTrans
.
add
(
"roleindex2"
,
u
+
"["
+
i
+
"]"
);
strTmpUser
+=
strTTrans
.
render
()
+
"\n"
;
}
roleWithRules
++;
}
else
{
strTmpUser
=
""
;
for
(
String
u
:
vUsers
)
{
strTmpUser
+=
"-- "
+
strRole
+
"\nnext("
+
u
+
"["
+
i
+
"]) := "
+
u
+
"["
+
i
+
"];\n"
;
}
roleWithoutRules
++;
}
if
(
strUserSection
==
null
)
{
strUserSection
=
strTmpUser
;
}
else
{
strUserSection
=
strUserSection
+
"\n\n"
+
strTmpUser
;
}
}
return
strUserSection
;
}
public
String
addCAEntryv2
(
Vector
<
String
>
vUsers
,
CAEntry
inCAEntry
)
throws
Exception
{
Vector
<
String
>
vAdminUsers
=
rbac
.
getAdmin
();
PreCondition
pcPreCond
=
inCAEntry
.
getPreConditions
();
String
strTransition
=
null
;
String
strPreCond
=
null
;
String
strCond
=
null
;
int
iDestRoleIndex
=
0
;
int
adminRoleIndex
=
0
;
iDestRoleIndex
=
rbac
.
getRoleIndex
(
inCAEntry
.
getRole
());
adminRoleIndex
=
rbac
.
getRoleIndex
(
inCAEntry
.
getAdminRole
());
if
(
pcPreCond
.
size
()
!=
0
)
{
for
(
int
iroleindex
:
pcPreCond
.
keySet
())
{
int
value
=
pcPreCond
.
getConditional
(
iroleindex
);
if
(
value
==
1
)
{
strCond
=
"$user$["
+
iroleindex
+
"]=$True$"
;
}
else
{
strCond
=
"$user$["
+
iroleindex
+
"]=$False$"
;
}
if
(
strPreCond
==
null
)
{
strPreCond
=
strCond
;
}
else
{
strPreCond
=
strPreCond
+
" & "
+
strCond
;
}
}
}
else
{
strPreCond
=
getTrue
();
}
String
strTemp
=
"user = $user$ & "
+
"admin = $admin$ & "
+
"$admin$[$adminRoleIndex$] = $True$ & "
+
strPreCond
+
" & "
+
"role = "
+
iDestRoleIndex
+
" & "
+
"act = ADD: "
+
getTrue
()
+
";"
;
for
(
String
vAdminUser
:
vAdminUsers
)
{
for
(
String
vUser
:
vUsers
)
{
ST
strTTrans
=
new
ST
(
strTemp
,
'$'
,
'$'
);
strTTrans
.
add
(
"user"
,
shortenUser
(
vUser
));
strTTrans
.
add
(
"admin"
,
shortenUser
(
vAdminUser
));
strTTrans
.
add
(
"True"
,
getTrue
());
strTTrans
.
add
(
"False"
,
getFalse
());
strTTrans
.
add
(
"adminRoleIndex"
,
adminRoleIndex
);
if
(
strTransition
==
null
)
{
strTransition
=
strTTrans
.
render
();
}
else
{
strTransition
=
strTransition
+
"\n"
+
strTTrans
.
render
();
}
}
}
if
(
includeRuleComment
)
{
strTransition
=
"-- CA Rule: "
+
inCAEntry
+
"\n"
+
strTransition
;
}
return
strTransition
;
}
public
String
addCREntryv2
(
Vector
<
String
>
vUsers
,
CREntry
crentry
)
{
int
adminRoleIndex
=
0
;
Vector
<
String
>
vAdminUsers
=
rbac
.
getAdmin
();
String
strTransition
=
null
;
int
iDestRoleIndex
=
0
;
try
{
iDestRoleIndex
=
rbac
.
getRoleIndex
(
crentry
.
getStrRole
());
if
(
crentry
.
getPreCond
().
equalsIgnoreCase
(
"true"
))
{
adminRoleIndex
=
-
1
;
}
else
if
(
crentry
.
getPreCond
().
equalsIgnoreCase
(
"false"
))
{
adminRoleIndex
=
-
2
;
}
else
{
adminRoleIndex
=
rbac
.
getRoleIndex
(
crentry
.
getPreCond
());
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
String
strTemp
;
strTemp
=
"user = $user$ & admin = $admin$ & $precondition$ & role = "
+
iDestRoleIndex
+
" & act = REMOVE: "
+
getFalse
()
+
";"
;
for
(
String
vAdminUser
:
vAdminUsers
)
{
for
(
String
vUser
:
vUsers
)
{
ST
strTTrans
=
new
ST
(
strTemp
,
'$'
,
'$'
);
strTTrans
.
add
(
"user"
,
shortenUser
(
vUser
));
strTTrans
.
add
(
"admin"
,
shortenUser
(
vAdminUser
));
if
(
adminRoleIndex
==
-
1
)
strTTrans
.
add
(
"precondition"
,
getTrue
());
else
if
(
adminRoleIndex
==
-
2
)
strTTrans
.
add
(
"precondition"
,
getFalse
());
else
strTTrans
.
add
(
"precondition"
,
vAdminUser
+
"["
+
adminRoleIndex
+
"]="
+
getTrue
());
if
(
strTransition
==
null
)
{
strTransition
=
strTTrans
.
render
();
}
else
{
strTransition
=
strTransition
+
"\n"
+
strTTrans
.
render
();
}
}
}
if
(
includeRuleComment
)
{
strTransition
=
"-- CR Rule: "
+
crentry
+
"\n"
+
strTransition
;
}
return
strTransition
;
}
// OLD Versions
public
void
setupUserTransitionsv1
(
ST
strTCodeTemplate
)
{
Vector
<
String
>
vUsers
=
rbac
.
getUsers
();
Vector
<
String
>
vUsers
=
rbac
.
getUsers
();
for
(
int
i
=
0
;
i
<
vUsers
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
vUsers
.
size
();
i
++)
{
...
@@ -249,13 +479,13 @@ public class WriteNuSMV {
...
@@ -249,13 +479,13 @@ public class WriteNuSMV {
System
.
out
.
println
(
"Writing for user "
+
vUsers
.
get
(
i
));
System
.
out
.
println
(
"Writing for user "
+
vUsers
.
get
(
i
));
}
}
String
strUser
=
vUsers
.
get
(
i
);
String
strUser
=
vUsers
.
get
(
i
);
String
strTransitions
=
this
.
setupEachUser
(
strUser
);
String
strTransitions
=
this
.
setupEachUser
v1
(
strUser
);
strTCodeTemplate
.
add
(
"transitions"
,
strTransitions
);
strTCodeTemplate
.
add
(
"transitions"
,
strTransitions
);
}
}
}
}
public
String
setupEachUser
(
String
inUser
)
{
public
String
setupEachUser
v1
(
String
inUser
)
{
Vector
<
String
>
vRoles
=
rbac
.
getRoles
();
Vector
<
String
>
vRoles
=
rbac
.
getRoles
();
String
strUserSection
=
null
;
String
strUserSection
=
null
;
...
@@ -270,7 +500,7 @@ public class WriteNuSMV {
...
@@ -270,7 +500,7 @@ public class WriteNuSMV {
if
(
vCA
!=
null
)
{
if
(
vCA
!=
null
)
{
for
(
int
j
=
0
;
j
<
vCA
.
size
();
j
++)
{
for
(
int
j
=
0
;
j
<
vCA
.
size
();
j
++)
{
String
strTmpTrans
=
addCAEntry
(
inUser
,
vCA
.
get
(
j
));
String
strTmpTrans
=
addCAEntry
v1
(
inUser
,
vCA
.
get
(
j
));
if
(
transitions
==
null
)
{
if
(
transitions
==
null
)
{
transitions
=
new
StringBuilder
();
transitions
=
new
StringBuilder
();
transitions
=
transitions
.
append
(
strTmpTrans
);
transitions
=
transitions
.
append
(
strTmpTrans
);
...
@@ -284,7 +514,7 @@ public class WriteNuSMV {
...
@@ -284,7 +514,7 @@ public class WriteNuSMV {
if
(
vCR
!=
null
)
{
if
(
vCR
!=
null
)
{
for
(
int
j
=
0
;
j
<
vCR
.
size
();
j
++)
{
for
(
int
j
=
0
;
j
<
vCR
.
size
();
j
++)
{
String
strTmpTrans
=
addCREntry
(
inUser
,
vCR
.
get
(
j
));
String
strTmpTrans
=
addCREntry
v1
(
inUser
,
vCR
.
get
(
j
));
if
(
transitions
==
null
)
{
if
(
transitions
==
null
)
{
transitions
=
new
StringBuilder
();
transitions
=
new
StringBuilder
();
transitions
=
transitions
.
append
(
strTmpTrans
);
transitions
=
transitions
.
append
(
strTmpTrans
);
...
@@ -319,7 +549,7 @@ public class WriteNuSMV {
...
@@ -319,7 +549,7 @@ public class WriteNuSMV {
return
strUserSection
;
return
strUserSection
;
}
}
public
String
addCAEntry
(
String
inUser
,
CAEntry
inCAEntry
)
{
public
String
addCAEntry
v1
(
String
inUser
,
CAEntry
inCAEntry
)
{
Vector
<
String
>
vAdminUsers
=
rbac
.
getAdmin
();
Vector
<
String
>
vAdminUsers
=
rbac
.
getAdmin
();
String
strTransition
=
null
;
String
strTransition
=
null
;
...
@@ -394,7 +624,7 @@ public class WriteNuSMV {
...
@@ -394,7 +624,7 @@ public class WriteNuSMV {
return
strTransition
;
return
strTransition
;
}
}
public
String
addCREntry
(
String
inUser
,
CREntry
crentry
)
{
public
String
addCREntry
v1
(
String
inUser
,
CREntry
crentry
)
{
int
adminRoleIndex
=
0
;
int
adminRoleIndex
=
0
;
Vector
<
String
>
vAdminUsers
=
rbac
.
getAdmin
();
Vector
<
String
>
vAdminUsers
=
rbac
.
getAdmin
();
...
...
src/mohawk/refine/RolesAbsRefine.java
View file @
89185bf4
...
@@ -12,6 +12,7 @@ import mohawk.collections.RoleDepTree;
...
@@ -12,6 +12,7 @@ import mohawk.collections.RoleDepTree;
import
mohawk.global.nusmv.NuSMV
;
import
mohawk.global.nusmv.NuSMV
;
import
mohawk.global.pieces.mohawk.*
;
import
mohawk.global.pieces.mohawk.*
;
import
mohawk.global.results.ExecutionResult
;
import
mohawk.global.results.ExecutionResult
;
import
mohawk.global.timing.MohawkTiming
;
import
mohawk.math.CalculateDiameter
;
import
mohawk.math.CalculateDiameter
;
import
mohawk.output.WriteNuSMV
;
import
mohawk.output.WriteNuSMV
;
import
mohawk.output.WriteRBACSpec
;
import
mohawk.output.WriteRBACSpec
;
...
@@ -46,10 +47,15 @@ public class RolesAbsRefine {
...
@@ -46,10 +47,15 @@ public class RolesAbsRefine {
private
NuSMVMode
mode
;
// mode
private
NuSMVMode
mode
;
// mode
public
boolean
skipSMVFile
=
false
;
public
boolean
skipSMVFile
=
false
;
private
Integer
returnValue
=
null
;
private
Integer
returnValue
=
null
;
public
RolesAbsRefine
(
RBACInstance
inRbac
)
{
// Timing
public
MohawkTiming
timing
;
public
String
timingPrefix
;
public
RolesAbsRefine
(
RBACInstance
inRbac
,
MohawkTiming
timing
,
String
timingPrefix
)
{
this
.
timing
=
timing
;
this
.
timingPrefix
=
timingPrefix
;
mode
=
NuSMVMode
.
BMC
;
// Default mode is BMC
mode
=
NuSMVMode
.
BMC
;
// Default mode is BMC
k
=
2
;
k
=
2
;
...
@@ -89,8 +95,9 @@ public class RolesAbsRefine {
...
@@ -89,8 +95,9 @@ public class RolesAbsRefine {
return
sAdminRoles
;
return
sAdminRoles
;
}
}
public
Boolean
getResult
(
RBACInstance
curInstance
,
Integer
fileno
)
throws
IOException
,
InterruptedException
{
public
Boolean
getResult
(
RBACInstance
curInstance
,
Integer
fileno
)
throws
Exception
{
WriteNuSMV
nusmv
=
new
WriteNuSMV
(
"logs/smvinstancefile"
+
fileno
+
".txt"
,
"smvtemplate"
);
WriteNuSMV
nusmv
=
new
WriteNuSMV
(
"logs/smvinstancefile"
+
fileno
+
".txt"
,
"smvtemplate"
,
timing
,
timingPrefix
);
nusmv
.
fillAttributes
(
curInstance
);
nusmv
.
fillAttributes
(
curInstance
);
if
(!
skipSMVFile
)
{
if
(!
skipSMVFile
)
{
...
@@ -196,25 +203,25 @@ public class RolesAbsRefine {
...
@@ -196,25 +203,25 @@ public class RolesAbsRefine {
}
}
public
boolean
refineRoles
()
{
public
boolean
refineRoles
()
{
if
(
nextsetroles
.
size
()
==
allroles
.
size
())
if
(
nextsetroles
.
size
()
==
allroles
.
size
())
{
return
false
;
}
return
false
;
// Set<String> incrementRoles = rdeptree.getRoles(refinementstep);
// Set<String> incrementRoles = rdeptree.getRoles(refinementstep);
Set
<
String
>
incrementRoles
=
new
HashSet
<
String
>();
// =
Set
<
String
>
incrementRoles
=
new
HashSet
<
String
>();
// = rdeptree.getRoles(refinementstep);
// rdeptree.getRoles(refinementstep);
for
(
int
i
=
0
;
i
<
k
;
i
++)
{
for
(
int
i
=
0
;
i
<
k
;
i
++)
{
Set
<
String
>
sNextQueue
=
this
.
rdeptree
.
getRoles
(
lastpriority
);
Set
<
String
>
sNextQueue
=
this
.
rdeptree
.
getRoles
(
lastpriority
);
if
(
sNextQueue
!=
null
)
{
if
(
sNextQueue
!=
null
)
{
incrementRoles
.
addAll
(
sNextQueue
);
incrementRoles
.
addAll
(
sNextQueue
);
lastpriority
++;
lastpriority
++;
}
else
}
else
{
break
;
break
;
}
}
}
if
(
incrementRoles
.
size
()
==
0
)
if
(
incrementRoles
.
size
()
==
0
)
{
return
false
;
return
false
;
else
}
else
{
nextsetroles
.
addAll
(
incrementRoles
);
nextsetroles
.
addAll
(
incrementRoles
);
}
refinementstep
++;
refinementstep
++;
...
...
src/mohawk/slicer/RoleSlicer.java
View file @
89185bf4
...
@@ -7,6 +7,7 @@ import java.util.*;
...
@@ -7,6 +7,7 @@ import java.util.*;
import
java.util.logging.Logger
;
import
java.util.logging.Logger
;
import
mohawk.global.pieces.mohawk.*
;
import
mohawk.global.pieces.mohawk.*
;
import
mohawk.global.timing.MohawkTiming
;
import
mohawk.rbac.RBACInstance
;
import
mohawk.rbac.RBACInstance
;
/**
/**
...
@@ -33,13 +34,18 @@ public class RoleSlicer {
...
@@ -33,13 +34,18 @@ public class RoleSlicer {
private
Vector
<
String
>
vPositiveDeps
;
private
Vector
<
String
>
vPositiveDeps
;
private
Vector
<
String
>
vNegativeDeps
;
private
Vector
<
String
>
vNegativeDeps
;
// Timing
public
MohawkTiming
timing
;
public
String
timingPrefix
;
/*
/*
* This is a map between role indices of unsliced roles and and sliced roles.
* This is a map between role indices of unsliced roles and and sliced roles.
*/
*/
private
Map
<
Integer
,
Integer
>
mapRoleIndex
;
private
Map
<
Integer
,
Integer
>
mapRoleIndex
;
public
RoleSlicer
(
RBACInstance
inRbac
)
{
public
RoleSlicer
(
RBACInstance
inRbac
,
MohawkTiming
timing
,
String
timingPrefix
)
{
this
.
timing
=
timing
;
this
.
timingPrefix
=
timingPrefix
;
unsliced
=
inRbac
;
unsliced
=
inRbac
;
strRole
=
unsliced
.
getSpec
().
get
(
1
);
strRole
=
unsliced
.
getSpec
().
get
(
1
);
strUser
=
unsliced
.
getSpec
().
get
(
0
);
strUser
=
unsliced
.
getSpec
().
get
(
0
);
...
@@ -48,20 +54,41 @@ public class RoleSlicer {
...
@@ -48,20 +54,41 @@ public class RoleSlicer {
}
}
public
RBACInstance
getSlicedPolicy
()
throws
Exception
{
public
RBACInstance
getSlicedPolicy
()
throws
Exception
{
/* TIMING */
timing
.
startTimer
(
timingPrefix
+
" (slicingTotal)"
);
System
.
out
.
println
(
"Slicing roles"
);
System
.
out
.
println
(
"[START] getSlicedPolicy()"
);
System
.
out
.
println
(
"[START] Slicing roles"
);
/* TIMING */
timing
.
startTimer
(
timingPrefix
+
" (slicing roles)"
);
slicedRoles
=
createSlicedRoles
();
slicedRoles
=
createSlicedRoles
();
System
.
out
.
println
(
"Slicing users"
);
/* TIMING */
timing
.
stopTimer
(
timingPrefix
+
" (slicing roles)"
);
System
.
out
.
println
(
"[START] Slicing users"
);
/* TIMING */
timing
.
startTimer
(
timingPrefix
+
" (slicing users)"
);
slicedUsers
=
sliceUsers
();
slicedUsers
=
sliceUsers
();
System
.
out
.
println
(
"Slicing admin"
);
/* TIMING */
timing
.
stopTimer
(
timingPrefix
+
" (slicing users)"
);
System
.
out
.
println
(
"[START] Slicing admin"
);
/* TIMING */
timing
.
startTimer
(
timingPrefix
+
" (slicing admin)"
);
slicedAdmin
=
unsliced
.
getAdmin
();