git-svn-id: https://projects.brucker.ch/su4sml/svn/infsec-import/trunk/src/su4sml@6121 3260e6d1-4efc-4170-b0a7-36055960796d
This commit is contained in:
parent
3bfeea80f1
commit
b3e3bed204
|
@ -44,12 +44,19 @@ val out = ref TextIO.stdOut
|
|||
fun closeFile () = if (!curFile = "")
|
||||
then ()
|
||||
else (TextIO.closeOut (!out);
|
||||
info ("closing "^(!curFile));
|
||||
(* info ("closing "^(!curFile));*)
|
||||
curFile := "")
|
||||
|
||||
|
||||
(* FIXME: set out to a real NullStream *)
|
||||
fun openNull file = (closeFile ();
|
||||
info ("skipping "^file);
|
||||
out := (TextIO.openOut "/dev/null");
|
||||
curFile := "/dev/null"
|
||||
)
|
||||
|
||||
|
||||
fun openFile file = (closeFile ();
|
||||
info ("opening "^file^"...");
|
||||
info ("opening "^file);
|
||||
Gcg_Helper.assureDir file;
|
||||
out := (TextIO.openOut file);
|
||||
curFile := file
|
||||
|
@ -57,7 +64,7 @@ fun openFile file = (closeFile ();
|
|||
|
||||
fun openFileIfNotExists file = (closeFile ();
|
||||
(if ((OS.FileSys.fileSize file) > 0)
|
||||
then openFile "/dev/null"
|
||||
then openNull file
|
||||
else openFile file
|
||||
) handle SysErr => ( openFile file ))
|
||||
|
||||
|
@ -128,7 +135,9 @@ fun generate model template
|
|||
(initOut();
|
||||
(*printTTree tree;*)
|
||||
write env tree;
|
||||
closeFile () )
|
||||
closeFile ();
|
||||
info "codegen finished successfully"
|
||||
)
|
||||
handle ex => (closeFile(); raise ex)
|
||||
end
|
||||
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
@// base template
|
||||
@// assumption: all classifiers are classes
|
||||
|
||||
@openfile generated/securemova/$classifier_package$.mova
|
||||
@// generated by su4sml GCG - Generic Code Generator
|
||||
load /home/doserj/projects/securemova/ocl-tool-v30/ocl-tool.maude @nl
|
||||
load /home/doserj/projects/securemova/ocl-tool-v30/securemova.maude @nl
|
||||
|
||||
@nl@nl
|
||||
(create-security-diagram $classifier_package$ .) @nl
|
||||
|
||||
|
||||
@foreach role_list
|
||||
(insert-role $classifier_package$ : $role_name$ .) @nl
|
||||
@foreach superrole_list
|
||||
|
@ -16,7 +15,7 @@
|
|||
@end
|
||||
|
||||
@foreach subject_list
|
||||
(insert-user $classifier_package$: $subject_name$ .) @nl
|
||||
(insert-user $classifier_package$ : $subject_name$ .) @nl
|
||||
@foreach role_list
|
||||
(insert-user-assignment $classifier_package$ | $subject_name$ <-> $role_name$ .) @nl
|
||||
@end
|
||||
|
@ -53,7 +52,7 @@
|
|||
(insert-authorization-constraint-assignment $classifier_package$ : $constraint_perm$ : auth$counter$ .) @nl
|
||||
@end
|
||||
|
||||
@//TODO: also support composite actions (not supported in cartridge yet...
|
||||
@//TODO: also support composite actions (not supported in cartridge yet...)
|
||||
@foreach entity_list
|
||||
@foreach createPermission_list
|
||||
(insert-atomic-create $classifier_package$ : $permission_name$ : $entity_name$ .) @nl
|
||||
|
|
|
@ -50,13 +50,13 @@ val tplStream = ref (TextIO.openString "@// dummy template\n");
|
|||
|
||||
fun opentFile file = (TextIO.closeIn (!tplStream) ;
|
||||
tplStream := (TextIO.openIn file))
|
||||
handle ex => error ("in Tpl_Parser.opentFile: \
|
||||
\couldn't open preprocessed template file: "^
|
||||
General.exnMessage ex)
|
||||
|
||||
handle ex => error ("in Tpl_Parser.opentFile: \
|
||||
\couldn't open preprocessed template file: "^
|
||||
General.exnMessage ex)
|
||||
|
||||
fun cleanUp tplFile = (TextIO.closeIn (!tplStream);
|
||||
OS.FileSys.remove tplFile)
|
||||
|
||||
|
||||
fun readNextLine () = TextIO.inputLine (!tplStream)
|
||||
|
||||
|
||||
|
@ -65,6 +65,7 @@ fun readNextLine () = TextIO.inputLine (!tplStream)
|
|||
(* This should really be relaxed... *)
|
||||
(* FIXME: add separate VariableLeaf *)
|
||||
(* FIXME: merge If and Else Nodes *)
|
||||
(* FIXME: add InfoLeaf to print informational messages during codegen *)
|
||||
datatype TemplateTree = RootNode of TemplateTree list
|
||||
| OpenFileLeaf of string
|
||||
| OpenFileIfNotExistsLeaf of string
|
||||
|
@ -135,7 +136,7 @@ fun tokenize line = let val l = joinEscapeSplitted "@" (fieldSplit #"@" line)
|
|||
fun getType l = let val sl = tokenize l
|
||||
in
|
||||
if (length sl = 1) orelse (length sl = 0)
|
||||
then "text" (* rather: comment *)
|
||||
then "text" (* rather: comment? *)
|
||||
else hd (tokenSplit #" " (String.concat sl))
|
||||
end
|
||||
handle ex => error ("in Tpl_Parser.getType: "^General.exnMessage ex)
|
||||
|
@ -194,9 +195,7 @@ fun codegen_home _ = getOpt (OS.Process.getEnv "CODEGEN_HOME", su4sml_home()^"sr
|
|||
*)
|
||||
fun call_cpp file =
|
||||
let val targetFile = OS.FileSys.tmpName ()
|
||||
val _ = info ("tmpfile "^targetFile)
|
||||
val _ = OS.Process.system ("cpp -P -C "^codegen_home()^"/"^file^" "^targetFile)
|
||||
val _ = info ("cpp done")
|
||||
in
|
||||
targetFile
|
||||
end
|
||||
|
@ -206,7 +205,7 @@ fun call_cpp file =
|
|||
(** parse template-file
|
||||
* @return the parsed template tree
|
||||
*)
|
||||
fun parse file = let val _ = info ("parsing template "^file)
|
||||
fun parse file = let val _ = info ("parsing template "^file)
|
||||
val mergedTpl = call_cpp file;
|
||||
val _ = opentFile mergedTpl;
|
||||
val pt = RootNode(buildTree (readNextLine()));
|
||||
|
|
|
@ -149,11 +149,11 @@ fun filter_subject cs = List.filter (classifier_has_stereotype "secuml.user") cs
|
|||
fun filter_role cs = List.filter (classifier_has_stereotype "secuml.role") cs
|
||||
|
||||
|
||||
fun mkRole (C as Rep.Class c) = Rep.short_name_of C
|
||||
fun mkRole (C as Rep.Class c) = Rep.string_of_path (Rep.name_of C)
|
||||
| mkRole _ = error ("in mkRole: argument is not a class")
|
||||
|
||||
(* FIXME: handle groups also *)
|
||||
fun mkSubject (C as Rep.Class c) = User (Rep.short_name_of C)
|
||||
fun mkSubject (C as Rep.Class c) = User (Rep.string_of_path (Rep.name_of C))
|
||||
| mkSubject _ = error ("in mkSubject: argument is not a class")
|
||||
|
||||
fun mkPermission cs (c as Rep.Class _) =
|
||||
|
@ -199,7 +199,7 @@ fun mkSubjectAssignment cs (c as (Rep.Class _)) =
|
|||
* removes the classes with SecureUML stereotypes.
|
||||
*)
|
||||
fun parse (cs:Rep_Core.Classifier list) =
|
||||
let val _ = info "parsing security configuration"
|
||||
let val _ = info "parsing security configuration"
|
||||
in
|
||||
(List.filter (classifier_has_no_stereotype ["secuml.permission",
|
||||
"secuml.role",
|
||||
|
|
|
@ -979,7 +979,8 @@ fun mkPackage tree =
|
|||
then let val trees = tree |> get "UML:Namespace.ownedElement"
|
||||
val atts = attributes tree
|
||||
val package_name = atts |> name
|
||||
val _ = info ("parsing package "^package_name)
|
||||
val _ = if tree is "UML:Model" then info ("parsing model "^package_name)
|
||||
else info ("parsing package "^package_name)
|
||||
in
|
||||
XMI.Package
|
||||
{ xmiid = atts |> xmiid,
|
||||
|
|
Loading…
Reference in New Issue