de.uni.freiburg.iig.telematik.sepia.serialize.AnalysisContextSerializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of SEPIA Show documentation
Show all versions of SEPIA Show documentation
SEPIA provides implementations for various types of Petri nets. Along Place/Transition-nets, it supports Petri nets with distinguishable token colors and defines coloured workflow nets, where coloured tokens are interpreted as data elements used during process execution. To support information flow analysis of processes, SEPIA defines so-called IF-Nets, tailored for security-oriented workflow modeling which enable users to assign security-levels (HIGH, LOW) to transitions, data elements and persons/agents participating in the process execution.
The newest version!
package de.uni.freiburg.iig.telematik.sepia.serialize;
import java.io.IOException;
import java.util.Arrays;
import java.util.Map;
import org.w3c.dom.Element;
import de.invation.code.toval.misc.soabase.SOABase;
import de.uni.freiburg.iig.telematik.sepia.parser.pnml.ifnet.AnalysisContextParser;
import de.uni.freiburg.iig.telematik.sepia.petrinet.ifnet.concepts.AnalysisContext;
import de.uni.freiburg.iig.telematik.sewol.accesscontrol.acl.ACLModel;
public class AnalysisContextSerializer {
public static final String TYPE_URI = "http://ifnml.process-security.de/grammar/v1.0/analysiscontext";
private AnalysisContext analysisContext = null;
private XMLSerializationSupport support = null;
public AnalysisContextSerializer(AnalysisContext analysisContext){
this.analysisContext = analysisContext;
support = new XMLSerializationSupport("analysiscontext");
}
private void addContent() {
support.getRootElement().setAttribute("id", analysisContext.getName());
support.getRootElement().setAttribute("type", TYPE_URI);
// Add AC model name
Element acModelElement = support.createElement("acmodel");
acModelElement.setTextContent(analysisContext.getACModel().getName());
support.getRootElement().appendChild(acModelElement);
// Add subject descriptors
Element subjectDescriptorsElement = support.createElement("subjectdescriptors");
Map descriptors = analysisContext.getSubjectDescriptors();
for (String activity : descriptors.keySet()) {
Element subjectDescriptorElement = support.createElement("subjectdescriptor");
subjectDescriptorElement.appendChild(support.createTextElement("activity", activity));
subjectDescriptorElement.appendChild(support.createTextElement("subject", descriptors.get(activity)));
subjectDescriptorsElement.appendChild(subjectDescriptorElement);
}
support.getRootElement().appendChild(subjectDescriptorsElement);
}
public String serialize() throws SerializationException {
addContent();
return support.serialize();
}
public void serialize(String path, String fileName) throws SerializationException, IOException {
addContent();
support.serialize(path, fileName, getFileExtension());
}
protected String getFileExtension(){
return "acon";
}
public static void main(String[] args) throws Exception {
SOABase context = new SOABase("context1");
context.setActivities(Arrays.asList("act1","act2"));
context.setSubjects(Arrays.asList("Gerd"));
ACLModel acl = new ACLModel("acl1", context);
acl.addActivityPermission("Gerd", "act1");
AnalysisContext c = new AnalysisContext("analysisContext1", acl, true);
c.setSubjectDescriptor("act1", "Gerd");
AnalysisContextSerializer serializer = new AnalysisContextSerializer(c);
serializer.serialize("/Users/stocker/Desktop/", "test");
AnalysisContext parsedContext = AnalysisContextParser.parse("/Users/stocker/Desktop/test.acon", true, Arrays.asList(acl));
System.out.println(parsedContext);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy