Commit 2c43ebd8 authored by Paff's avatar Paff
Browse files

bug fixing

example for tutorial
parent cb1182e2
......@@ -6,11 +6,15 @@ import java.util.List;
import java.util.Set;
import org.jgrapht.alg.DirectedNeighborIndex;
import org.jgrapht.traverse.DepthFirstIterator;
import org.jgrapht.traverse.GraphIterator;
import interfaces2.STEntry;
import interfaces2.resolvers.AmbigousException;
import mc.IErrorCode;
import mc.ast.ASTNode;
import mc.umlp.arcd.ets.entries.ComponentEntry;
import mc.umlp.arcd.ets.entries.PortEntry;
import secarc._ast.ASTSecArcRefRole;
import secarc._ast.ASTSecArcRole;
import secarc.error.MontiSecArcAnalysisErrorCodes;
......@@ -18,6 +22,7 @@ import secarc.ets.analysis.checker.Analysis;
import secarc.ets.analysis.checker.ISecAnalysisRoleChecker;
import secarc.ets.check.MontiSecArcAnalysisConstants;
import secarc.ets.entries.RoleEntry;
import secarc.ets.entries.SecComponentEntry;
import secarc.ets.graph.ArchitectureGraph;
import secarc.ets.graph.Edge;
import secarc.ets.graph.Vertex;
......@@ -93,6 +98,24 @@ public class RoleAccess extends Analysis implements ISecAnalysisRoleChecker {
for(RoleEntry role : resultSet) {
allPredescessor.addAll(directedNeighborIndex.predecessorListOf(Vertex.of(role)));
}
//If a role has access to a port, it has also access to the component behind the port
GraphIterator<Vertex<? extends STEntry>, Edge> iterator = null;
List<ComponentEntry> components = new ArrayList<ComponentEntry>();
for(Vertex<? extends STEntry> vertex : allPredescessor) {
if(!(vertex.getArchitectureElement() instanceof PortEntry)) {
continue;
}
iterator = new DepthFirstIterator<Vertex<? extends STEntry>, Edge>(graph.getRawGraph(), vertex);
while(iterator.hasNext()) {
element = iterator.next().getArchitectureElement();
if(element instanceof SecComponentEntry) {
components.add((ComponentEntry) element);
break;
}
}
}
StringBuilder sBuilder = new StringBuilder("The role " + entry.getName() + " has access to the following ports and components: ");
......@@ -105,6 +128,11 @@ public class RoleAccess extends Analysis implements ISecAnalysisRoleChecker {
sBuilder.append(", ");
sBuilder.append(vertex.getArchitectureElement().getName());
}
for(STEntry component : components) {
sBuilder.append(", ");
sBuilder.append(component.getName());
}
addReport(sBuilder.toString(), node.get_SourcePositionStart());
......
......@@ -281,7 +281,7 @@ public class AnalysisCriticalPortTransformationVisitor extends ConcreteVisitor {
*/
public void visit(ASTArcPort node) {
try {
PortEntry entry = (PortEntry) resolver.resolve(node.getName(), PortEntry.KIND, getNameSpaceFor(node));
PortEntry entry = (PortEntry) resolver.resolve(node.printName(), PortEntry.KIND, getNameSpaceFor(node));
if(entry != null && !this.entries.contains(entry)) {
removeNodes.add(node);
}
......
......@@ -113,7 +113,6 @@ public class PreAnalysisCriticalPortTransformationVisitor extends ConcreteVisito
if(componentEntry != null) {
graphConnectorEdges = ArchitectureGraphBuilder.forArchitecture(componentEntry).buildGraphConnectorEdge();
}
}
/**
......@@ -124,7 +123,7 @@ public class PreAnalysisCriticalPortTransformationVisitor extends ConcreteVisito
public void visit(ASTArcPort node) {
PortEntry entry = null;
try {
entry = (PortEntry) resolver.resolve(node.getName(), PortEntry.KIND, getNameSpaceFor(node));
entry = (PortEntry) resolver.resolve(node.printName(), PortEntry.KIND, getNameSpaceFor(node));
if(entry == null) {
return;
}
......
......@@ -10,7 +10,7 @@ component Store {
access stockManager, storeManager, cashier;
trustlevel +1;
trustlevel +2;
port
in String inIdentifier,
......
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