use of org.iobserve.service.privacy.violation.transformation.analysisgraph.Vertex in project iobserve-analysis by research-iobserve.
the class DataProtectionWarner method computePrivacyLevelsAndAddEdge.
private void computePrivacyLevelsAndAddEdge(final PrivacyGraph graph, final OperationInterface operationInterface, final RepositoryComponent providingComponent, final RepositoryComponent requiringComponent) throws InvocationException, DBException {
for (final OperationSignature operationSignature : operationInterface.getSignatures__OperationInterface()) {
final IDataProtectionAnnotation operationSignaturePrivacyAnnotation = this.returntypeprivacy.get(operationSignature.getId());
EDataProtectionLevel inEdgeDataProtectionLevel = null;
EDataProtectionLevel outEdgePrivacyLevel = null;
/**
* Check parameter.
*/
for (final Parameter proxyParameter : operationSignature.getParameters__OperationSignature()) {
final Parameter parameter = this.repositoryResource.resolve(proxyParameter);
final ParameterModifier mod = parameter.getModifier__Parameter();
if (mod == ParameterModifier.IN || mod == ParameterModifier.INOUT) {
final String parameterName = parameter.getParameterName();
outEdgePrivacyLevel = this.updateDataProtectionLevel(outEdgePrivacyLevel, this.parameterprivacy.get(parameterName).getLevel());
}
if (mod == ParameterModifier.OUT || mod == ParameterModifier.INOUT) {
inEdgeDataProtectionLevel = this.updateDataProtectionLevel(inEdgeDataProtectionLevel, this.parameterprivacy.get(parameter.getParameterName()).getLevel());
}
}
/**
* Check return type.
*/
if (operationSignaturePrivacyAnnotation != null) {
inEdgeDataProtectionLevel = this.updateDataProtectionLevel(inEdgeDataProtectionLevel, operationSignaturePrivacyAnnotation.getLevel());
}
final Vertex providingComponentVertex = this.vertices.get(providingComponent.getId());
final Vertex requiringComponentVertex = this.vertices.get(requiringComponent.getId());
if (providingComponentVertex != null && requiringComponentVertex != null) {
// Add Edges
if (inEdgeDataProtectionLevel != null) {
final Edge edge = new Edge(providingComponentVertex, requiringComponentVertex);
edge.setDPC(Policy.getDataClassification(inEdgeDataProtectionLevel));
edge.setOperationSignature(operationSignature);
graph.addEdge(edge);
}
if (outEdgePrivacyLevel != null) {
final Edge edge = new Edge(requiringComponentVertex, providingComponentVertex);
edge.setDPC(Policy.getDataClassification(outEdgePrivacyLevel));
edge.setOperationSignature(operationSignature);
graph.addEdge(edge);
}
if (inEdgeDataProtectionLevel == null && outEdgePrivacyLevel == null) {
this.logger.error("Missing privacy level");
}
}
}
}
use of org.iobserve.service.privacy.violation.transformation.analysisgraph.Vertex in project iobserve-analysis by research-iobserve.
the class DataProtectionWarner method print.
private void print(final PrivacyGraph graph) {
java.lang.System.out.println("Graph-Name " + graph.getName());
java.lang.System.out.println("Vertices");
for (final Entry<String, Vertex> entry : graph.getVertices().entrySet()) {
final String entityName;
final AllocationContext context = entry.getValue().getAllocationContext();
if (context != null) {
entityName = context.getEntityName();
} else {
entityName = "<missing allocation context>";
}
java.lang.System.out.println("\t" + entry.getKey() + " = " + entry.getValue().getName() + " : " + entityName);
}
java.lang.System.out.println("Edges");
for (final Edge value : graph.getEdges()) {
final String entityName;
final OperationSignature context = value.getOperationSignature();
if (context != null) {
entityName = context.getEntityName();
} else {
entityName = "<missing operation signature>";
}
java.lang.System.out.println("\t" + entityName + " " + value.getSource().getName() + " -> " + value.getTarget().getName());
}
}
use of org.iobserve.service.privacy.violation.transformation.analysisgraph.Vertex in project iobserve-analysis by research-iobserve.
the class DataProtectionWarner method addDeployedComponents.
/**
* Adding deployment info.
*
* @param privacyGraph
* the graph containing privacy information
* @throws DBException
* @throws InvocationException
*/
private void addDeployedComponents(final PrivacyGraph privacyGraph) throws InvocationException, DBException {
DeploymentLock.lock();
for (final AllocationContext allocationContext : this.allocationRootElement.getAllocationContexts_Allocation()) {
final AssemblyContext proxyAssemblyContext = allocationContext.getAssemblyContext_AllocationContext();
final AssemblyContext assemblyContext = this.systemModelResource.resolve(proxyAssemblyContext);
final RepositoryComponent proxyComponent = assemblyContext.getEncapsulatedComponent__AssemblyContext();
final BasicComponent basicComponent = (BasicComponent) this.repositoryResource.resolve(proxyComponent);
/**
* Creating component vertices. *
*/
// TODO name should be allocation name or assembly name + instance count
final Vertex vertex = new Vertex(basicComponent.getEntityName(), this.computeStereotype(basicComponent));
vertex.setAllocationContext(allocationContext);
privacyGraph.addVertex(vertex);
this.vertices.put(basicComponent.getId(), vertex);
final ResourceContainer resourceContainer = this.resourceEnvironmentResource.resolve(allocationContext.getResourceContainer_AllocationContext());
final GeoLocation geo = this.geolocations.get(resourceContainer.getId());
if (geo == null) {
this.logger.info("Geolocation infomation not available {}", resourceContainer.getId());
} else {
final Vertex vGeo = new Vertex(geo.getIsocode().getName(), EStereoType.GEOLOCATION);
if (!this.vertices.containsKey(geo.getIsocode().getName())) {
// New Geolocation
privacyGraph.addVertex(vGeo);
privacyGraph.addEdge(vGeo, vertex);
this.vertices.put(geo.getIsocode().getName(), vGeo);
} else {
// Existing Geolocation
privacyGraph.addEdge(this.vertices.get(geo.getIsocode().getName()), vertex);
}
}
}
DeploymentLock.unlock();
}
use of org.iobserve.service.privacy.violation.transformation.analysisgraph.Vertex in project iobserve-analysis by research-iobserve.
the class PrivacyChecker method determineSetPotentialWarnings.
/**
* Computes potential warning WARNING TMP.
*
* @param graph
* the graph
* @param policy
* the policy model
* @return returns list of edges
*/
// TODO better method name
private List<Edge> determineSetPotentialWarnings(final PrivacyGraph graph, final Policy policy) {
final List<Edge> warnings = new ArrayList<>();
final Vertex excludedGeolocationVertice = graph.getVertexByName(policy.getEisocode().getName());
if (excludedGeolocationVertice != null) {
final Map<String, Vertex> componentVerticesDeployedAt = graph.getComponentVerticesDeployedAt(policy.getEisocode());
for (final String verticeName : componentVerticesDeployedAt.keySet()) {
final Vertex verticeAtExcludedGeolocation = componentVerticesDeployedAt.get(verticeName);
warnings.addAll(verticeAtExcludedGeolocation.getIncomingEdges());
final List<Edge> relevantDatatransfers = verticeAtExcludedGeolocation.getOutgoingEdgesClassifiedAtLeast(policy.getDataClassification());
warnings.addAll(relevantDatatransfers);
}
} else {
PrivacyChecker.LOGGER.debug("Policy's geo location not included in the runtime model");
}
return warnings;
}
use of org.iobserve.service.privacy.violation.transformation.analysisgraph.Vertex in project iobserve-analysis by research-iobserve.
the class PrivacyChecker method determineSetWARNING.
private List<Edge> determineSetWARNING(final List<Edge> potentialWarnings, final Policy policy) {
final List<Edge> warnings = new ArrayList<>();
for (final Edge edge : potentialWarnings) {
this.violatedByWalkthrough = false;
final Vertex startNode = edge.getTarget();
final List<Vertex> walkthrough = new ArrayList<>();
this.walkthroughFromToDatabase(startNode, policy.getDataClassification(), walkthrough);
if (this.violatedByWalkthrough) {
warnings.add(edge);
}
}
return warnings;
}
Aggregations