class IpSecAlgorithm implements SolutionStrategy {

    @Override
    public boolean applySolution(TTopologyTemplate topology, SolutionInputData inputData) {
        IRepository repository = RepositoryFactory.getRepository();
        NamespaceManager namespaceManager = repository.getNamespaceManager();

        Map<QName, TNodeType> nodeTypes = repository.getQNameToElementMapping(NodeTypeId.class);

        TNodeTemplate[] elements = new TNodeTemplate[2];

        for (int index = 0; index < 2; index++) {
            ComponentFinding componentFinding = inputData.getFindings().get(index);
            elements[index] = getVmHost(topology, componentFinding.getComponentId());

            if (Objects.isNull(elements[index])) {
                elements[index] = topology.getNodeTemplate(componentFinding.getComponentId());
            }

            Map<QName, TNodeType> children = ModelUtilities.getChildrenOf(elements[index].getType(), nodeTypes);

            // simply use the first element
            Optional<Map.Entry<QName, TNodeType>> firstSecure = children.entrySet()
                .stream()
                .filter(
                    entry -> namespaceManager.isSecureCollection(entry.getKey().getNamespaceURI())
                ).findFirst();

            if (firstSecure.isPresent()) {
                ModelUtilities.updateNodeTemplate(
                    topology,
                    elements[index].getId(),
                    firstSecure.get().getKey(),
                    firstSecure.get().getValue()
                );
            } else {
                return false;
            }
        }

        // forward connection
        ModelUtilities.createRelationshipTemplateAndAddToTopology(elements[1], elements[0],
            ToscaBaseTypes.connectsToRelationshipType, "securely_connectsTo", topology);
        // backward connection
        ModelUtilities.createRelationshipTemplateAndAddToTopology(elements[0], elements[1],
            ToscaBaseTypes.connectsToRelationshipType, "securely_connectsTo", topology);

        return true;
    }

}