Search in sources :

Example 1 with Vertex

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");
            }
        }
    }
}
Also used : Vertex(org.iobserve.service.privacy.violation.transformation.analysisgraph.Vertex) EDataProtectionLevel(org.iobserve.model.privacy.EDataProtectionLevel) OperationSignature(org.palladiosimulator.pcm.repository.OperationSignature) ParameterModifier(org.palladiosimulator.pcm.repository.ParameterModifier) Parameter(org.palladiosimulator.pcm.repository.Parameter) Edge(org.iobserve.service.privacy.violation.transformation.analysisgraph.Edge) IDataProtectionAnnotation(org.iobserve.model.privacy.IDataProtectionAnnotation)

Example 2 with Vertex

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());
    }
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) Vertex(org.iobserve.service.privacy.violation.transformation.analysisgraph.Vertex) OperationSignature(org.palladiosimulator.pcm.repository.OperationSignature) Edge(org.iobserve.service.privacy.violation.transformation.analysisgraph.Edge)

Example 3 with Vertex

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();
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) Vertex(org.iobserve.service.privacy.violation.transformation.analysisgraph.Vertex) BasicComponent(org.palladiosimulator.pcm.repository.BasicComponent) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) GeoLocation(org.iobserve.model.privacy.GeoLocation) RepositoryComponent(org.palladiosimulator.pcm.repository.RepositoryComponent) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

Example 4 with Vertex

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;
}
Also used : Vertex(org.iobserve.service.privacy.violation.transformation.analysisgraph.Vertex) ArrayList(java.util.ArrayList) Edge(org.iobserve.service.privacy.violation.transformation.analysisgraph.Edge)

Example 5 with Vertex

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;
}
Also used : Vertex(org.iobserve.service.privacy.violation.transformation.analysisgraph.Vertex) ArrayList(java.util.ArrayList) Edge(org.iobserve.service.privacy.violation.transformation.analysisgraph.Edge)

Aggregations

Vertex (org.iobserve.service.privacy.violation.transformation.analysisgraph.Vertex)7 Edge (org.iobserve.service.privacy.violation.transformation.analysisgraph.Edge)6 AllocationContext (org.palladiosimulator.pcm.allocation.AllocationContext)3 OperationSignature (org.palladiosimulator.pcm.repository.OperationSignature)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 Set (java.util.Set)1 EDataProtectionLevel (org.iobserve.model.privacy.EDataProtectionLevel)1 GeoLocation (org.iobserve.model.privacy.GeoLocation)1 IDataProtectionAnnotation (org.iobserve.model.privacy.IDataProtectionAnnotation)1 ProbeManagementData (org.iobserve.service.privacy.violation.data.ProbeManagementData)1 WarningModel (org.iobserve.service.privacy.violation.data.WarningModel)1 ModelProbeController (org.iobserve.service.privacy.violation.filter.ModelProbeController)1 Test (org.junit.Test)1 AssemblyContext (org.palladiosimulator.pcm.core.composition.AssemblyContext)1 BasicComponent (org.palladiosimulator.pcm.repository.BasicComponent)1 Parameter (org.palladiosimulator.pcm.repository.Parameter)1 ParameterModifier (org.palladiosimulator.pcm.repository.ParameterModifier)1