Search in sources :

Example 1 with IDataProtectionAnnotation

use of org.iobserve.model.privacy.IDataProtectionAnnotation 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 IDataProtectionAnnotation

use of org.iobserve.model.privacy.IDataProtectionAnnotation in project iobserve-analysis by research-iobserve.

the class DataProtectionWarner method clearAndFillQueryMaps.

/**
 * Fills the hash maps used for queries.
 *
 * @throws DBException
 * @throws InvocationException
 */
private void clearAndFillQueryMaps() throws InvocationException, DBException {
    DeploymentLock.lock();
    this.vertices.clear();
    this.geolocations.clear();
    this.stereotypes.clear();
    this.parameterprivacy.clear();
    this.returntypeprivacy.clear();
    this.interfaces.clear();
    for (final GeoLocation location : this.privacyRootElement.getResourceContainerLocations()) {
        this.geolocations.put(this.resourceEnvironmentResource.resolve(location.getResourceContainer()).getId(), location);
    }
    for (final EncapsulatedDataSource stereotype : this.privacyRootElement.getEncapsulatedDataSources()) {
        if (stereotype != null) {
            final BasicComponent resolvedComponent = this.repositoryResource.resolve(stereotype.getComponent());
            this.stereotypes.put(resolvedComponent.getId(), stereotype);
        } else {
            this.logger.debug("missing {}", stereotype);
        }
    }
    for (final IDataProtectionAnnotation dataProectionAnnocation : this.privacyRootElement.getDataProectionLevels()) {
        if (dataProectionAnnocation instanceof ParameterDataProtection) {
            final ParameterDataProtection parameterDataProtection = (ParameterDataProtection) dataProectionAnnocation;
            final Parameter parameter = this.repositoryResource.resolve(parameterDataProtection.getParameter());
            this.parameterprivacy.put(parameter.getParameterName(), parameterDataProtection);
        }
        if (dataProectionAnnocation instanceof ReturnTypeDataProtection) {
            final ReturnTypeDataProtection returnTypeDataProection = (ReturnTypeDataProtection) dataProectionAnnocation;
            this.returntypeprivacy.put(this.repositoryResource.resolve(returnTypeDataProection.getOperationSignature()).getId(), returnTypeDataProection);
        }
    }
    for (final Interface inf : this.repositoryRootElement.getInterfaces__Repository()) {
        if (inf instanceof OperationInterface) {
            this.interfaces.put(inf.getEntityName(), (OperationInterface) inf);
        }
    }
    DeploymentLock.unlock();
}
Also used : ReturnTypeDataProtection(org.iobserve.model.privacy.ReturnTypeDataProtection) ParameterDataProtection(org.iobserve.model.privacy.ParameterDataProtection) BasicComponent(org.palladiosimulator.pcm.repository.BasicComponent) Parameter(org.palladiosimulator.pcm.repository.Parameter) GeoLocation(org.iobserve.model.privacy.GeoLocation) EncapsulatedDataSource(org.iobserve.model.privacy.EncapsulatedDataSource) IDataProtectionAnnotation(org.iobserve.model.privacy.IDataProtectionAnnotation) OperationInterface(org.palladiosimulator.pcm.repository.OperationInterface) Interface(org.palladiosimulator.pcm.repository.Interface) OperationInterface(org.palladiosimulator.pcm.repository.OperationInterface)

Aggregations

IDataProtectionAnnotation (org.iobserve.model.privacy.IDataProtectionAnnotation)2 Parameter (org.palladiosimulator.pcm.repository.Parameter)2 EDataProtectionLevel (org.iobserve.model.privacy.EDataProtectionLevel)1 EncapsulatedDataSource (org.iobserve.model.privacy.EncapsulatedDataSource)1 GeoLocation (org.iobserve.model.privacy.GeoLocation)1 ParameterDataProtection (org.iobserve.model.privacy.ParameterDataProtection)1 ReturnTypeDataProtection (org.iobserve.model.privacy.ReturnTypeDataProtection)1 Edge (org.iobserve.service.privacy.violation.transformation.analysisgraph.Edge)1 Vertex (org.iobserve.service.privacy.violation.transformation.analysisgraph.Vertex)1 BasicComponent (org.palladiosimulator.pcm.repository.BasicComponent)1 Interface (org.palladiosimulator.pcm.repository.Interface)1 OperationInterface (org.palladiosimulator.pcm.repository.OperationInterface)1 OperationSignature (org.palladiosimulator.pcm.repository.OperationSignature)1 ParameterModifier (org.palladiosimulator.pcm.repository.ParameterModifier)1