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