Search in sources :

Example 6 with Edge

use of org.iobserve.service.privacy.violation.transformation.analysisgraph.Edge in project iobserve-analysis by research-iobserve.

the class ModelProbeController method computeReceivedWarnings.

private Map<AllocationContext, Set<OperationSignature>> computeReceivedWarnings(final List<Edge> edges) {
    final Map<AllocationContext, Set<OperationSignature>> receivedWarnings = new HashMap<>();
    this.logger.debug("Compute received warnings {}", edges.size());
    for (final Edge edge : edges) {
        this.logger.debug("Compute received warnings for edge={}", edge.getName());
        // multiple methods per allocation possible
        final AllocationContext allocation = edge.getSource().getAllocationContext();
        if (allocation != null) {
            this.logger.debug("Compute received warnings for {} {}", allocation.getEntityName(), edge.getOperationSignature().getEntityName());
            Set<OperationSignature> methodSignatures = receivedWarnings.get(allocation);
            // if not present, add new entry
            if (methodSignatures == null) {
                methodSignatures = new HashSet<>();
            }
            if (edge.getOperationSignature() != null) {
                methodSignatures.add(edge.getOperationSignature());
                receivedWarnings.put(allocation, methodSignatures);
            } else {
                this.logger.debug("Received warning without operation signature");
            }
        } else {
            this.logger.debug("Compute received warnings No ALLOCATION for the specified edge {}", edge.getName());
        }
    }
    return receivedWarnings;
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) OperationSignature(org.palladiosimulator.pcm.repository.OperationSignature) Edge(org.iobserve.service.privacy.violation.transformation.analysisgraph.Edge)

Example 7 with Edge

use of org.iobserve.service.privacy.violation.transformation.analysisgraph.Edge in project iobserve-analysis by research-iobserve.

the class DataProtectionWarner method checkGraph.

private WarningModel checkGraph(final PrivacyGraph graph) throws FileNotFoundException, InstantiationException, IllegalAccessException, ClassNotFoundException, IOException {
    final WarningModel warnings = new WarningModel();
    final PrivacyChecker privacyChecker = new PrivacyChecker(this.policyList, this.policyPackage);
    final List<Edge> edges = privacyChecker.check(graph);
    for (final Edge edge : edges) {
        warnings.addMessage(edge.getPrint() + "");
        warnings.addWarningEdge(edge);
    }
    warnings.setDate(new Date());
    return warnings;
}
Also used : PrivacyChecker(org.iobserve.service.privacy.violation.transformation.privacycheck.PrivacyChecker) WarningModel(org.iobserve.service.privacy.violation.data.WarningModel) Edge(org.iobserve.service.privacy.violation.transformation.analysisgraph.Edge) Date(java.util.Date)

Example 8 with Edge

use of org.iobserve.service.privacy.violation.transformation.analysisgraph.Edge in project iobserve-analysis by research-iobserve.

the class NonAdaptiveModelProbeController method idenitifyProtectedOperations.

/**
 * Identify the set of allocations which are mentioned by the warnings collect all operation
 * signatures which are considered relevant for data protection.
 *
 * @param warningEdges
 *            the privacy analysis warnings model edges
 * @return map of {@link AllocationContext}s and {@link OperationSignature}s relevant for data
 *         protection
 */
private Map<AllocationContext, Set<OperationSignature>> idenitifyProtectedOperations(final List<Edge> warningEdges) {
    final Map<AllocationContext, Set<OperationSignature>> protectedOperationsPerAllocation = new HashMap<>();
    if (warningEdges != null && warningEdges.isEmpty()) {
        for (final Edge edge : warningEdges) {
            // multiple methods per allocation possible
            final AllocationContext allocation = edge.getSource().getAllocationContext();
            Set<OperationSignature> operationSignatures = protectedOperationsPerAllocation.get(allocation);
            // if not present, add new entry
            if (operationSignatures == null) {
                operationSignatures = new HashSet<>();
            }
            if (edge.getOperationSignature() != null) {
                operationSignatures.add(edge.getOperationSignature());
                protectedOperationsPerAllocation.put(allocation, operationSignatures);
            } else {
                this.logger.debug("Recevied warning without operation signature");
            }
        }
    }
    return protectedOperationsPerAllocation;
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) Set(java.util.Set) HashMap(java.util.HashMap) OperationSignature(org.palladiosimulator.pcm.repository.OperationSignature) Edge(org.iobserve.service.privacy.violation.transformation.analysisgraph.Edge)

Example 9 with Edge

use of org.iobserve.service.privacy.violation.transformation.analysisgraph.Edge in project iobserve-analysis by research-iobserve.

the class ModelProbeControllerTest method testComputedMethodsToActivateAndToDeactivate.

@Test
public void testComputedMethodsToActivateAndToDeactivate() {
    this.modelProbeController = new ModelProbeController();
    final OperationSignature operationSignature1 = Mockito.mock(OperationSignature.class);
    final OperationSignature operationSignature2 = Mockito.mock(OperationSignature.class);
    final AllocationContext allocationContext1 = Mockito.mock(AllocationContext.class);
    final AllocationContext allocationContext2 = Mockito.mock(AllocationContext.class);
    final WarningModel warnings1 = new WarningModel();
    final Edge edge1 = new Edge(new Vertex("test vertex 1", EStereoType.DATASOURCE), new Vertex("test vertex 2", EStereoType.DATASOURCE));
    edge1.setOperationSignature(operationSignature1);
    edge1.getSource().setAllocationContext(allocationContext1);
    final Edge edge2 = new Edge(new Vertex("test vertex 3", EStereoType.DATASOURCE), new Vertex("test vertex 4", EStereoType.DATASOURCE));
    edge2.setOperationSignature(operationSignature2);
    edge2.getSource().setAllocationContext(allocationContext2);
    warnings1.addWarningEdge(edge1);
    warnings1.addWarningEdge(edge2);
    final Map<AllocationContext, Set<OperationSignature>> methodsToActivate1 = new HashMap<>();
    final Set<OperationSignature> methodsSet1 = new HashSet<>();
    methodsSet1.add(operationSignature1);
    methodsToActivate1.put(allocationContext1, methodsSet1);
    final Set<OperationSignature> methodsSet2 = new HashSet<>();
    methodsSet2.add(operationSignature2);
    methodsToActivate1.put(allocationContext2, methodsSet2);
    final ProbeManagementData expectedOutcome1 = new ProbeManagementData(methodsToActivate1, new HashMap<AllocationContext, Set<OperationSignature>>());
    // deactivate 1, keep 1, add 1 to existing and add double set / allocation to output port
    final OperationSignature operationSignature3 = Mockito.mock(OperationSignature.class);
    final OperationSignature operationSignature4 = Mockito.mock(OperationSignature.class);
    final OperationSignature operationSignature5 = Mockito.mock(OperationSignature.class);
    final AllocationContext allocationContext3 = Mockito.mock(AllocationContext.class);
    final Edge edge3 = new Edge(new Vertex("test vertex 5", EStereoType.DATASOURCE), new Vertex("test vertex 6", EStereoType.DATASOURCE));
    edge3.setOperationSignature(operationSignature3);
    edge3.getSource().setAllocationContext(allocationContext2);
    final Edge edge4 = new Edge(new Vertex("test vertex 7", EStereoType.DATASOURCE), new Vertex("test vertex 8", EStereoType.DATASOURCE));
    edge4.setOperationSignature(operationSignature4);
    edge4.getSource().setAllocationContext(allocationContext3);
    final Edge edge5 = new Edge(new Vertex("test vertex 9", EStereoType.DATASOURCE), new Vertex("test vertex 10", EStereoType.DATASOURCE));
    edge5.setOperationSignature(operationSignature5);
    edge5.getSource().setAllocationContext(allocationContext3);
    final WarningModel warnings2 = new WarningModel();
    warnings2.addWarningEdge(edge2);
    warnings2.addWarningEdge(edge3);
    warnings2.addWarningEdge(edge4);
    warnings2.addWarningEdge(edge5);
    final Map<AllocationContext, Set<OperationSignature>> methodsToActivate2 = new HashMap<>();
    final Set<OperationSignature> methodsSet3 = new HashSet<>();
    methodsSet3.add(operationSignature3);
    methodsToActivate2.put(allocationContext2, methodsSet3);
    final Set<OperationSignature> methodsSet4 = new HashSet<>();
    methodsSet4.add(operationSignature4);
    methodsSet4.add(operationSignature5);
    methodsToActivate2.put(allocationContext3, methodsSet4);
    final Map<AllocationContext, Set<OperationSignature>> methodsToDeactivate2 = new HashMap<>();
    methodsToDeactivate2.put(allocationContext1, methodsSet1);
    final ProbeManagementData expectedOutcome2 = new ProbeManagementData(methodsToActivate2, methodsToDeactivate2);
    final List<WarningModel> input = new LinkedList<>();
    input.add(warnings1);
    input.add(warnings2);
    final List<ProbeManagementData> output = new LinkedList<>();
    StageTester.test(this.modelProbeController).and().send(input).to(this.modelProbeController.getInputPort()).receive(output).from(this.modelProbeController.getOutputPort()).start();
    Assert.assertTrue(output.get(0).getMethodsToActivate().equals(expectedOutcome1.getMethodsToActivate()));
    Assert.assertTrue(output.get(0).getMethodsToDeactivate().equals(expectedOutcome1.getMethodsToDeactivate()));
    Assert.assertTrue(output.get(1).getMethodsToActivate().equals(expectedOutcome2.getMethodsToActivate()));
    Assert.assertTrue(output.get(1).getMethodsToDeactivate().equals(expectedOutcome2.getMethodsToDeactivate()));
}
Also used : Vertex(org.iobserve.service.privacy.violation.transformation.analysisgraph.Vertex) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) ModelProbeController(org.iobserve.service.privacy.violation.filter.ModelProbeController) ProbeManagementData(org.iobserve.service.privacy.violation.data.ProbeManagementData) WarningModel(org.iobserve.service.privacy.violation.data.WarningModel) LinkedList(java.util.LinkedList) AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) OperationSignature(org.palladiosimulator.pcm.repository.OperationSignature) Edge(org.iobserve.service.privacy.violation.transformation.analysisgraph.Edge) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

Edge (org.iobserve.service.privacy.violation.transformation.analysisgraph.Edge)9 Vertex (org.iobserve.service.privacy.violation.transformation.analysisgraph.Vertex)6 OperationSignature (org.palladiosimulator.pcm.repository.OperationSignature)5 AllocationContext (org.palladiosimulator.pcm.allocation.AllocationContext)4 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 Set (java.util.Set)3 ArrayList (java.util.ArrayList)2 WarningModel (org.iobserve.service.privacy.violation.data.WarningModel)2 Date (java.util.Date)1 LinkedHashSet (java.util.LinkedHashSet)1 LinkedList (java.util.LinkedList)1 EDataProtectionLevel (org.iobserve.model.privacy.EDataProtectionLevel)1 IDataProtectionAnnotation (org.iobserve.model.privacy.IDataProtectionAnnotation)1 ProbeManagementData (org.iobserve.service.privacy.violation.data.ProbeManagementData)1 ModelProbeController (org.iobserve.service.privacy.violation.filter.ModelProbeController)1 PrivacyChecker (org.iobserve.service.privacy.violation.transformation.privacycheck.PrivacyChecker)1 Test (org.junit.Test)1 Parameter (org.palladiosimulator.pcm.repository.Parameter)1 ParameterModifier (org.palladiosimulator.pcm.repository.ParameterModifier)1