Exemple #1
0
import selectors
import socket
from typing import Tuple
import ssl
import time
import codecs
from FreeTAKServer.controllers.serializers.protobuf_serializer import ProtobufSerializer
from FreeTAKServer.controllers.serializers.xml_serializer import XmlSerializer
from FreeTAKServer.controllers.XMLCoTController import XMLCoTController
from FreeTAKServer.model.SpecificCoT.SendOther import SendOther
from FreeTAKServer.model.FTSModel.Event import Event
from FreeTAKServer.controllers.DatabaseControllers.DatabaseController import DatabaseController
from FreeTAKServer.model.ClientInformation import ClientInformation
from FreeTAKServer.model.SpecificCoT.SendDisconnect import SendDisconnect
from FreeTAKServer.controllers.CreateLoggerController import CreateLoggerController
logger = CreateLoggerController("FederationServer").getLogger()


class FederationServerService(ServerServiceInterface, ServiceBase):

    def __init__(self):
        self._define_responsibility_chain()
        self.pipe = None
        self.federates: {str: Federate} = {}
        self.sel = selectors.DefaultSelector()

    def _send_connected_clients(self, connection):
        try:
            clients = self.db.query_user()
        except Exception as e:
            logger.warning("error thrown in getting clients from DataBase to send to federates " + str(e))
Exemple #2
0
import traceback
import defusedxml.ElementTree as ET
from logging.handlers import RotatingFileHandler
from pathlib import Path, PurePath
from FreeTAKServer.controllers.configuration.DataPackageServerConstants import DataPackageServerConstants
from FreeTAKServer.controllers.configuration.SQLcommands import SQLcommands
from FreeTAKServer.controllers.configuration.LoggingConstants import LoggingConstants
from FreeTAKServer.controllers.CreateLoggerController import CreateLoggerController
from FreeTAKServer.controllers.DatabaseControllers.DatabaseController import DatabaseController
from FreeTAKServer.controllers.configuration.DatabaseConfiguration import DatabaseConfiguration
import eventlet
from FreeTAKServer.controllers.configuration.MainConfig import MainConfig
from flask_cors import CORS, cross_origin

loggingConstants = LoggingConstants()
logger = CreateLoggerController("DataPackageServer").getLogger()
from flask_sqlalchemy import SQLAlchemy
from flask import Flask, request, send_file
from flask.logging import default_handler

dbController = DatabaseController()

log = logging.getLogger('werkzeug')
log.setLevel(logging.ERROR)

USINGSSL = False

sql = SQLcommands()
const = DataPackageServerConstants()
log = LoggingConstants()
from FreeTAKServer.model.SpecificCoT.SendDisconnect import SendDisconnect
from .SendCoTAbstractController import SendCoTAbstractController
from FreeTAKServer.controllers.configuration.LoggingConstants import LoggingConstants
from FreeTAKServer.controllers.CreateLoggerController import CreateLoggerController

loggingConstants = LoggingConstants()
logger = CreateLoggerController("SendDisconnectController").getLogger()


class SendDisconnectController(SendCoTAbstractController):
    def __init__(self, RawCoT):
        try:
            tempObject = super().Event.disconnect()
            object = SendDisconnect()
            self.fill_object(object, tempObject, RawCoT, addToDB=False)
        except Exception as e:
            logger.error(
                "there has been an exception in the creation of the send disconnect object "
                + str(e))
            return -1
Exemple #4
0
#######################################################
#
# XMLCoTController.py
# Python implementation of the Class XMLCoTController
# Generated by Enterprise Architect
# Created on:      20-May-2020 1:07:38 PM
# Original author: Natha Paquette
#
#######################################################
from lxml import etree

from FreeTAKServer.controllers.configuration.LoggingConstants import LoggingConstants
from FreeTAKServer.controllers.CreateLoggerController import CreateLoggerController
from FreeTAKServer.controllers.SpecificCoTControllers import *

logger = CreateLoggerController("XMLCoTController").getLogger()
loggingConstants = LoggingConstants()


class XMLCoTController:
    def __init__(self):
        pass

    def determineCoTGeneral(self, data):
        # this will establish the CoTs general type
        if data.type == 'RawConnectionInformation':
            #this handels the event of a connection CoT
            try:
                return ("clientConnected", data)

            except Exception as e:
Exemple #5
0
from FreeTAKServer.model.SpecificCoT.SendGeoChat import SendGeoChat
from .SendCoTAbstractController import SendCoTAbstractController
from FreeTAKServer.controllers.configuration.LoggingConstants import LoggingConstants
from FreeTAKServer.controllers.CreateLoggerController import CreateLoggerController

loggingConstants = LoggingConstants()
logger = CreateLoggerController("SendGeoChatController").getLogger()


class SendGeoChatController(SendCoTAbstractController):
    def __init__(self, RawCoT=None, AddToDB=True):
        try:
            tempObject = super().Event.GeoChat()
            object = SendGeoChat()
            if RawCoT is not None:
                self.fill_object(object, tempObject, RawCoT, addToDB=AddToDB)
            else:
                pass
        except Exception as e:
            logger.error("there has been an exception in the creation"
                         " of the send Geo Chat object " + str(e))
            return -1
#######################################################
#
# ReceiveConnections.py
# Python implementation of the Class ReceiveConnections
# Generated by Enterprise Architect
# Created on:      19-May-2020 6:21:05 PM
# Original author: Natha Paquette
#
#######################################################
import socket
from FreeTAKServer.controllers.configuration.LoggingConstants import LoggingConstants
from FreeTAKServer.model.RawConnectionInformation import RawConnectionInformation as sat
from FreeTAKServer.controllers.CreateLoggerController import CreateLoggerController
from FreeTAKServer.controllers.configuration.ReceiveConnectionsConstants import ReceiveConnectionsConstants
loggingConstants = LoggingConstants()
logger = CreateLoggerController("ReceiveConnections").getLogger()
import logging
import logging.handlers
import ssl
import time
#TODO: move health check values to constants and create controller for HealthCheck data


class ReceiveConnections:
    def __init__(self):
        pass

    def listen(self, sock, sslstatus=False):
        #logger = CreateLoggerController("ReceiveConnections").getLogger()
        #listen for client connections
        sock.listen(0)
# ClientInformationController.py
# Python implementation of the Class ClientInformationController
# Generated by Enterprise Architect
# Created on:      19-May-2020 6:56:00 PM
#
#######################################################
from lxml import etree
from FreeTAKServer.controllers.BasicModelInstantiate import BasicModelInstantiate
import uuid
from FreeTAKServer.controllers.configuration.LoggingConstants import LoggingConstants
from FreeTAKServer.controllers.CreateLoggerController import CreateLoggerController
from FreeTAKServer.model.FTSModel.Event import Event
from FreeTAKServer.model.ClientInformation import ClientInformation
from FreeTAKServer.controllers.XMLCoTController import XMLCoTController

logger = CreateLoggerController("ClientInformationController").getLogger()

loggingConstants = LoggingConstants()


class ClientInformationController(BasicModelInstantiate):
    def __init__(self):
        pass

    '''
    connection setup is obsolete with intstantiateClientInformationModelFromController
    '''

    def intstantiateClientInformationModelFromConnection(
            self, rawClientInformation, queue):
        try:
from FreeTAKServer.controllers.configuration.LoggingConstants import LoggingConstants
from FreeTAKServer.controllers.CreateLoggerController import CreateLoggerController
from FreeTAKServer.model.FTSModel.Event import Event as event
from FreeTAKServer.controllers.configuration.MainConfig import MainConfig
from abc import ABC
from FreeTAKServer.controllers.serializers import xml_serializer

loggingConstants = LoggingConstants()
logger = CreateLoggerController("SendCoTAbstract").getLogger()


class SendCoTAbstractController(ABC):
    Event = event

    def __init__(self, object):
        pass

    def fill_object(self,
                    object,
                    tempObject,
                    RawCoT,
                    addToDB=MainConfig.SaveCoTToDB):
        try:
            object.modelObject = self.create_model_object(
                tempObject, RawCoT.xmlString)

        except Exception as e:
            if tempObject.type != "other":
                self.handel_serialization_exception(object, RawCoT)
                logger.error(
                    'an undocumented CoT has been sent returning the error ' +
Exemple #9
0
from FreeTAKServer.controllers.services.FederationServiceAbstract import FederationServiceAbstract
from FreeTAKServer.controllers.services.FederationServiceController import FederationServiceController
from FreeTAKServer.controllers.configuration.LoggingConstants import LoggingConstants
from FreeTAKServer.controllers.CreateLoggerController import CreateLoggerController

loggingConstants = LoggingConstants()
logger = CreateLoggerController("FederationClient").getLogger()
import ssl
import socket
from queue import Queue


class FederationClientServiceController(FederationServiceAbstract):
    """this controller is instantiated upon the startup of FTS and is used to
    establish and control federations. this is NOT always running and has no while loops
    """
    def __init__(self, pipe):
        super().__init__(pipe)
        self.dataQueue = Queue()

    def create_client_federation(self, ip, port):
        try:
            sock = self._establish_connection(ip, port)
            federate = FederationServiceController(ip, port, sock).start()
            self.federateClients.add_client(federate)
        except Exception as e:
            logger.error(
                'exception has been thrown in the creation of client federation '
                + str(e))

    def remove_client_federation(self, Federate):
Exemple #10
0
from FreeTAKServer.model.SpecificCoT.SendChecklist import SendChecklist
from .SendCoTAbstractController import SendCoTAbstractController
from FreeTAKServer.controllers.configuration.LoggingConstants import LoggingConstants
from FreeTAKServer.controllers.CreateLoggerController import CreateLoggerController

loggingConstants = LoggingConstants()
logger = CreateLoggerController("SendChecklistController").getLogger()


class SendChecklistController(SendCoTAbstractController):
    def __init__(self, RawCoT):
        try:
            tempObject = super().Event.disconnect()
            object = SendChecklist()
            self.fill_object(object, tempObject, RawCoT, addToDB=False)
        except Exception as e:
            logger.error(
                "there has been an exception in the creation of the send Checklist object "
                + str(e))
            return -1
from FreeTAKServer.model.SpecificCoT.SendDropPoint import SendDropPoint
from .SendCoTAbstractController import SendCoTAbstractController
from FreeTAKServer.controllers.configuration.LoggingConstants import LoggingConstants
from FreeTAKServer.controllers.CreateLoggerController import CreateLoggerController

loggingConstants = LoggingConstants()
logger = CreateLoggerController("SendDropPointController").getLogger()


class SendDropPointController(SendCoTAbstractController):
    def __init__(self, RawCoT=None):
        try:
            tempObject = super().Event.dropPoint()
            object = SendDropPoint()
            if RawCoT is not None:
                self.fill_object(object, tempObject, RawCoT)
            else:
                pass
        except Exception as e:
            logger.error(
                "there has been an exception in the creation of the send drop point object "
                + str(e))
            return -1
from FreeTAKServer.model.SpecificCoT.SendDeleteVideoStream import SendDeleteVideoStream
from FreeTAKServer.controllers.configuration.LoggingConstants import LoggingConstants
from FreeTAKServer.controllers.CreateLoggerController import CreateLoggerController
from FreeTAKServer.model.RestMessages.RestEnumerations import RestEnumerations
from FreeTAKServer.model.FTSModel.Event import Event as event
import json as jsonmodule
from FreeTAKServer.controllers.serializers.xml_serializer import XmlSerializer
from FreeTAKServer.controllers.configuration.RestAPIVariables import RestAPIVariables
from defusedxml import ElementTree as etree
from FreeTAKServer.controllers.DatabaseControllers.DatabaseController import DatabaseController
loggingConstants = LoggingConstants()
logger = CreateLoggerController("SendDeleteVideoStreamController").getLogger()


class SendDeleteVideoStreamController:
    def __init__(self, json):
        tempObject = event.DeleteVideo()
        object = SendDeleteVideoStream()
        object.setModelObject(tempObject)
        object.modelObject = self._serializeJsonToModel(
            object.modelObject, json)
        DatabaseController().create_CoT(object.modelObject)
        object.setXmlString(
            etree.tostring(XmlSerializer().from_fts_object_to_format(
                object.modelObject)))
        self.setCoTObject(object)

    def _serializeJsonToModel(self, object, json):
        try:
            json.getuid()
            object.setuid(json.getuid())
Exemple #13
0
from FreeTAKServer.model.SpecificCoT.SendInvalidCoT import SendInvalidCoT
from FreeTAKServer.controllers.configuration.LoggingConstants import LoggingConstants
from FreeTAKServer.controllers.CreateLoggerController import CreateLoggerController

loggingConstants = LoggingConstants()
logger = CreateLoggerController("SendInvalidCoTController").getLogger()


class SendInvalidCoTController:
    def __init__(self, RawCOT):
        try:
            self.SendInvalidCoT = SendInvalidCoT()
            self.SendInvalidCoT.clientInformation = RawCOT.clientInformation
        except Exception as e:
            logger.error("there has been an exception in the creation"
                         " of the send Invalid CoT object " + str(e))
            return -1
    def getObject(self):
        return self.SendInvalidCoT
from defusedxml import ElementTree as etree
from FreeTAKServer.model.SpecificCoT.SendOther import SendOther
from FreeTAKServer.controllers.SpecificCoTControllers.SendCoTAbstractController import SendCoTAbstractController
from FreeTAKServer.controllers.configuration.LoggingConstants import LoggingConstants
from FreeTAKServer.controllers.CreateLoggerController import CreateLoggerController

loggingConstants = LoggingConstants()
logger = CreateLoggerController("SendOtherController").getLogger()


class SendOtherController(SendCoTAbstractController):
    def __init__(self, RawCoT=None):
        if type(RawCoT != bytes):
            pass
        else:
            RawCoT.xmlString.encode()
        try:
            tempObject = super().Event.Other()
            self.object = SendOther()
            if RawCoT is not None:
                xml = RawCoT.xmlString
                RawCoT.xmlString = etree.tostring(self.filter_CoT(xml))
                self.fill_object(self.object, tempObject, RawCoT)
                try:
                    object = self.getObject()

                except Exception as e:
                    logger.error(
                        "there has been an exception getting object " + str(e))
                self.Object.setXmlString(xml)
            else:
#######################################################
#
# sendClientData.py
# Python implementation of the Class sendClientData
# Generated by Enterprise Architect
# Created on:      19-May-2020 7:37:17 PM
# Original author: Natha Paquette
#
#######################################################

from FreeTAKServer.controllers.configuration.LoggingConstants import LoggingConstants
from FreeTAKServer.controllers.CreateLoggerController import CreateLoggerController

logger = CreateLoggerController("SendClientData").getLogger()

loggingConstants = LoggingConstants()


class SendClientData:
    def __init__(self):
        pass

    def SendDataInQueue(self, dataQueue, clientQueue):
        logger.info(loggingConstants.SENDCLIENTDATASENDDATAINQUEUEINFO)
        while True:
            tempQueue = clientQueue
            tempArray = []
            if dataQueue.empty() == False:
                while tempQueue.empty() == False:
                    tempArray.append(tempQueue.get())
                data = dataQueue.get()
Exemple #16
0
from FreeTAKServer.controllers.configuration.LoggingConstants import LoggingConstants
from FreeTAKServer.controllers.CreateLoggerController import CreateLoggerController
loggingConstants = LoggingConstants()
logger = CreateLoggerController("SendDataController").getLogger()
import copy
#TODO: the part handling new connection from seperate process needs to be cleaned up


class SendDataController:
    def __init__(self):
        pass

    def sendDataInQueue(self,
                        sender,
                        processedCoT,
                        clientInformationQueue,
                        shareDataPipe=None):
        try:
            pass
            # print('sending data to fts client' + str(processedCoT.xmlString))
        except Exception as e:
            print(e)
        try:
            if processedCoT.type == 'GeoChat':
                self.returnData = self.geochat_sending(clientInformationQueue,
                                                       processedCoT, sender,
                                                       shareDataPipe)
                return self.returnData
            elif sender == processedCoT:
                for client in clientInformationQueue:
                    try:
Exemple #17
0
from FreeTAKServer.model.SpecificCoT.SendSimpleCoT import SendSimpleCoT
from FreeTAKServer.controllers.configuration.LoggingConstants import LoggingConstants
from FreeTAKServer.controllers.CreateLoggerController import CreateLoggerController
from FreeTAKServer.model.RestMessages.RestEnumerations import RestEnumerations
from FreeTAKServer.model.FTSModel.Event import Event as event
import json as jsonmodule
from FreeTAKServer.controllers.XMLCoTController import XMLCoTController
from FreeTAKServer.controllers.serializers.xml_serializer import XmlSerializer
from FreeTAKServer.controllers.configuration.RestAPIVariables import RestAPIVariables
from geopy import Nominatim
from defusedxml import ElementTree as etree
from FreeTAKServer.controllers.DatabaseControllers.DatabaseController import DatabaseController
loggingConstants = LoggingConstants()
logger = CreateLoggerController("SendSimpleCoTController").getLogger()

class SendSimpleCoTController:
    def __init__(self, json):
        tempObject = event.SimpleCoT()
        object = SendSimpleCoT()
        object.setModelObject(tempObject)
        object.modelObject = self._serializeJsonToModel(object.modelObject, json)
        DatabaseController().create_CoT(object.modelObject)
        object.setXmlString(etree.tostring(XmlSerializer().from_fts_object_to_format(object.modelObject)))
        self.setCoTObject(object)

    def _serializeJsonToModel(self, object, json):
        try:
            if json.getuid():
                object.setuid(json.getuid())
            object.sethow(json.gethow())
            COTTYPE = json.getgeoObject()
from FreeTAKServer.model.SpecificCoT.SendPrecense import SendPresence
from FreeTAKServer.controllers.configuration.LoggingConstants import LoggingConstants
from FreeTAKServer.controllers.CreateLoggerController import CreateLoggerController
from FreeTAKServer.model.RestMessages.RestEnumerations import RestEnumerations
from FreeTAKServer.model.FTSModel.Event import Event as event
import json as jsonmodule
from FreeTAKServer.controllers.XMLCoTController import XMLCoTController
from FreeTAKServer.controllers.configuration.RestAPIVariables import RestAPIVariables

loggingConstants = LoggingConstants()
logger = CreateLoggerController("SendPresenceController").getLogger()


class SendPresenceController:
    def __init__(self, json):
        tempObject = event.Presence()
        object = SendPresence()
        object.setModelObject(tempObject)
        object.modelObject = self._serializeJsonToModel(object.modelObject, json)
        object.setXmlString(XMLCoTController().serialize_model_to_CoT(object.modelObject))
        self.setCoTObject(object)

    def _serializeJsonToModel(self, object, json):
        try:
            object.sethow(json.gethow())
            object.type = RestAPIVariables.defaultPresenceType
            point = object.point
            point.setlon(json.getlongitude())
            point.setlat(json.getlatitude())
            object.detail.contact.setcallsign(json.getname())
            object.detail._group.setname(json.getteam())
Exemple #19
0
#######################################################
#
# ClientReceptionHandler.py
# Python implementation of the Class ClientReceptionHandler
# Generated by Enterprise Architect
# Created on:      19-May-2020 7:17:21 PM
# Original author: Natha Paquette
#
#######################################################
import time
import socket
from FreeTAKServer.controllers.CreateLoggerController import CreateLoggerController
from defusedxml import ElementTree as etree

logger = CreateLoggerController("ClientReceptionHandler").getLogger()
from FreeTAKServer.controllers.configuration.ClientReceptionLoggingConstants import ClientReceptionLoggingConstants

loggingConstants = ClientReceptionLoggingConstants()


class ClientReceptionHandler:
    def __init__(self):
        self.dataPipe = []
        self.socketCount = 0

    def startup(self, clientInformationArray):
        try:
            self.clientInformationArray = clientInformationArray
            '''logger.propagate = False
            logger.info(loggingConstants.CLIENTRECEPTIONHANDLERSTART)
            logger.propagate = True'''
Exemple #20
0
from FreeTAKServer.controllers.services.RestAPI import RestAPI
from FreeTAKServer.model.ServiceObjects.FTS import FTS as FTSObj
from FreeTAKServer.model.SimpleClient import SimpleClient
import time
from FreeTAKServer.controllers.AddDataToCoTList import AddDataToCoTList
from FreeTAKServer.model.FilterGroup import FilterGroup
from FreeTAKServer.controllers.services.SSLCoTServiceController import SSLCoTServiceController
from FreeTAKServer.controllers.services.TCPCoTServiceController import TCPCoTServiceController
from FreeTAKServer.controllers.services.federation.FederationClientService import FederationClientServiceController
from FreeTAKServer.controllers.services.federation.federation import FederationServerService
from FreeTAKServer.controllers.DatabaseControllers.DatabaseController import DatabaseController
from FreeTAKServer.controllers.certificate_generation import AtakOfTheCerts
from multiprocessing import Queue
from FreeTAKServer.controllers.configuration.MainConfig import MainConfig
loggingConstants = LoggingConstants()
logger = CreateLoggerController("FTS").getLogger()


# noinspection PyUnresolvedReferences
class FTS:
    def __init__(self):
        self.CoTService = None
        self.TCPDataPackageService = None
        self.UserCommand = None
        self.killSwitch = False
        self.ReceiveConnectionsReset = None
        self.CoTPoisonPill = None
        self.ClientDataPipe = None
        self.SSLClientDataPipe = None
        self.clientArray = []
        self.socketCount = 0
from FreeTAKServer.model.SpecificCoT.SendExcheckUpdate import SendExcheckUpdate
from .SendCoTAbstractController import SendCoTAbstractController
from FreeTAKServer.controllers.configuration.LoggingConstants import LoggingConstants
from FreeTAKServer.controllers.CreateLoggerController import CreateLoggerController

loggingConstants = LoggingConstants()
logger = CreateLoggerController("SendExcheckUpdateController").getLogger()


class SendExcheckUpdateController(SendCoTAbstractController):
    def __init__(self, RawCoT):
        try:
            tempObject = super().Event.ExcheckUpdate()
            object = SendExcheckUpdate()
            self.fill_object(object, tempObject, RawCoT, addToDB=False)
        except Exception as e:
            logger.error(
                "there has been an exception in the creation of the send Emergency object "
                + str(e))
            return -1