Exemple #1
0
    public override Response Execute()
    {
        var db         = MasterContainer.GetService <IBroadcastDatabase>();
        var collisions = db.GetInterval(Broadcast.StartTime, Broadcast.EndTime);

        PlanBroadcastResult result;

        if (collisions.Length > 0)
        {
            var authorizator = MasterContainer.GetService <IAuthorizator>();
            // If there is a collission, admin can override it
            if (authorizator.HasPermission(User, Permission.AdminBroadcasts))
            {
                result = PlanBroadcastResult.CanUploadIfAdmin;
            }
            else
            {
                result = PlanBroadcastResult.CannotUpload;
            }
        }
        else
        {
            result = PlanBroadcastResult.CanUpload;
        }

        return(new PlanBroadcastResponse(result, collisions));
    }
Exemple #2
0
 public BroadcastForm()
 {
     InitializeComponent();
     client      = MasterContainer.GetService <RequestSender>();
     currentUser = MasterContainer.GetService <User>();
     recForm     = new RecordForm();
 }
Exemple #3
0
        public MainWindow()
        {
            var masterContainer = new MasterContainer();

            _facade = masterContainer.Facade;
            InitializeComponent();
        }
Exemple #4
0
    public override Response Execute()
    {
        var db         = MasterContainer.GetService <IBroadcastDatabase>();
        var broadcasts = db.GetInterval(IntervalStart, IntervalEnd);

        return(new SelectBroadcastResponse(broadcasts));
    }
Exemple #5
0
    public override Response Execute()
    {
        var db      = MasterContainer.GetService <IBroadcastDatabase>();
        var altered = db.Edit(BroadcastId, NewStartTime, NewLabel);

        return(new AlterBroadcastResponse(altered ? AlterBroadcastResult.Success : AlterBroadcastResult.NotFound));
    }
Exemple #6
0
        private static RequestSender InitTcpSender(Settings settings)
        {
            string    ip = settings.SERVER_IP;
            TcpSender tcpClient;

            try
            {
                tcpClient = new TcpSender(ip, settings.CONTROL_TCP_PORT,
                                          settings.RESPOND_TIMEOUT);
            }
            catch
            {
                MessageBox.Show("Nepodařilo se zinicializovat síťovou komunikaci, program bude ukončen.", "Chyba", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }
            var sender = new RequestSender(tcpClient);

            sender.NetProblem           += ProgramError;
            sender.UnrecognizedResponse += ProgramError;
            sender.CryptoError          += ProgramError;
            sender.Unauthorized         += ProgramError;
            sender.AccessDenied         += ProgramError;
            sender.CannotExecute        += ProgramError;
            sender.InvalidResponse      += ProgramError;

            MasterContainer.AddService(sender);

            return(sender);
        }
Exemple #7
0
        private static Playback InitPlayback(Settings settings)
        {
            Playback playback;

            try
            {
                playback = new Playback((int)settings.PLAYBACK_DEV_OUT);
                if (playback.OutDevNumber < 0 || playback.OutDevNumber > playback.OutputsCount)
                {
                    ProgramOutput.Error("Cannot initialize playback, invalid output device index. Index must be between 0 and {1}.", playback.OutputsCount);
                    return(null);
                }
            }
            catch (Exception ex)
            {
                ProgramOutput.Error("Cannot initialize playback audio output, error: {0}", ex.Message);
                return(null);
            }

            MasterContainer.AddService <Playback>(playback);

            ProgramOutput.Info("Playback initialized, output set to: device index = {0} - ({1}).", playback.OutDevNumber, playback.OutName);

            return(playback);
        }
Exemple #8
0
        public LoginForm()
        {
            InitializeComponent();

            netSender = MasterContainer.GetService <RequestSender>();
            crypter   = MasterContainer.GetService <EncryptionProvider>();
        }
Exemple #9
0
    public override Response Execute()
    {
        var crypter       = MasterContainer.GetService <RsaCrpyter>();
        var clientCripter = crypter.StripPrivateKey();

        return(new HelloResponse(clientCripter.GetPublicXmlConfig()));
    }
Exemple #10
0
        private static SessionManager InitSessionManager()
        {
            var manager = new SessionManager();

            MasterContainer.AddService <SessionManager>(manager);

            return(manager);
        }
Exemple #11
0
    public override Response Execute()
    {
        var    authenticator = MasterContainer.GetService <IAuthenticator>();
        string password      = Session.Crpter.DecryptString(User.PasswordEnc);
        var    result        = authenticator.Authenticate(User, password);

        return(new AuthenticateResponse(result));
    }
Exemple #12
0
    public void SendGoodbye()
    {
        var user        = MasterContainer.GetService <User>();
        var goodbye     = new GoodbyeRequest(user);
        var requestData = EncryptRequest(goodbye, SessionCrypter);

        client.Send(requestData);
    }
Exemple #13
0
        private static TcpServer InitTcpServer(Settings settings)
        {
            var server = new TcpServer((int)settings.CONTROL_TCP_PORT);

            MasterContainer.AddService <TcpServer>(server);
            ProgramOutput.Info("TCP socket initialized, ready on port {0}.", server.Port);

            return(server);
        }
Exemple #14
0
 private static void stopMaster()
 {
     if (Master.engine != null)
     {
         Master.engine.StopEngine();
         Master.Dispose();
         MasterContainer.Reset();
         clientListen.stop();
     }
 }
Exemple #15
0
    public override Response Execute()
    {
        var server  = MasterContainer.GetService <TcpServer>();
        var manager = MasterContainer.GetService <SessionManager>();

        server.DisconnectClient(Session.Host);
        manager.RemoveSession(Session);

        return(new SuccessResponse());
    }
Exemple #16
0
        static void Main()
        {
            using (Mutex mutex = new Mutex(false, "Global\\" + appGuid))
            {
                Application.EnableVisualStyles();

                if (!mutex.WaitOne(0, false))
                {
                    MessageBox.Show("Program již na tomto počítači běží!", "Upozornění", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                var settings = Settings.Default;
                var sender   = InitTcpSender(settings);
                if (sender == null)
                {
                    return;
                }

#if DEBUG
                // System.Threading.Thread.Sleep(3000);
#endif
                // Get server public key to encrypt exchange request by RSA
                sender.AsymetricCrypter = GetServerKey(settings, sender);
                if (sender.AsymetricCrypter == null)
                {
                    return;
                }
                // Do symetric AES key exchange with server for the rest of the session
                bool keyExchanged = ExchangeKey(sender);
                if (!keyExchanged)
                {
                    return;
                }

                var login = new LoginForm();
                login.ShowDialog();

                if (login.Result == AuthenticationResult.Granted)
                {
                    MasterContainer.AddService(login.User);
                    Application.Run(new MainForm());
                }

                try
                {
                    sender.SendGoodbye();
                }
                catch { }
                //}
            }
        }
Exemple #17
0
        private static RsaCrpyter InitCrypter(Settings settings)
        {
            RsaCrpyter crypter = null;
            string     keyFile = settings.KEYS_FILE;

            if (File.Exists(keyFile))
            {
                string xml = null;
                try
                {
                    ProgramOutput.Info("Loading RSA key pair from file {0}...", keyFile);
                    xml = File.ReadAllText(keyFile);
                }
                catch
                {
                    ProgramOutput.Error("Error accessing RSA key file {0}. Please check permissions to this file.", keyFile);
                    Console.ReadKey(true);
                    return(null);
                }
                try
                {
                    crypter = new RsaCrpyter(xml);
                }
                catch
                {
                    ProgramOutput.Error("Error parsing RSA key file {0}. Maybe the file is corrupted or invalid format. Please delete the file to generate new RSA key pair.", keyFile);
                    Console.ReadKey(true);
                    return(null);
                }
            }
            else
            {
                ProgramOutput.Info("Generating new RSA key pair into file {0}...", keyFile);
                crypter = new RsaCrpyter();
                string xml = crypter.GetFullXmlConfig();
                try
                {
                    File.WriteAllText(keyFile, xml);
                }
                catch
                {
                    ProgramOutput.Error("Error accessing RSA key file {0}. Please check permissions to this file.", keyFile);
                    Console.ReadKey(true);
                    return(null);
                }
            }
            MasterContainer.AddService <RsaCrpyter>(crypter);
            ProgramOutput.Info("RSA crypto module successfuly initialized.");

            return(crypter);
        }
Exemple #18
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            this.sender = MasterContainer.GetService <RequestSender>();


            //var start = timeLine1.StartTime.AddMinutes(2);
            //var end = timeLine1.StartTime.AddMinutes(8);

            //var tasks = new TimeLineTask[] {
            //    new TimeLineTask(start, end, "V. Klínská"),
            //    new TimeLineTask(start.AddMinutes(3), end.AddMinutes(1), "M. Kaufmann") };

            //timeLine1.SetTasks(tasks);
        }
Exemple #19
0
        private static IBroadcastDatabase InitDatabase(Settings settings)
        {
            string connString = string.Format(settings.SQLITE_CONN_STRING, settings.DB_FILE);
            var    db         = new SQLiteConnection(connString);
            var    database   = new SQLiteDatabase(db, (int)settings.SCHEDULER_PADDING_START, (int)settings.SCHEDULER_PADDING_END);

            database.Open();
            //database.Add(new BroadcastInfo("Kaufmann", DateTime.Now.AddMinutes(3), new TimeSpan(0, 3, 0), BroadcastType.Reservation));
            //database.Add(new BroadcastInfo("Nosková", DateTime.Now.AddMinutes(7), new TimeSpan(0, 5, 0), BroadcastType.Reservation));
            MasterContainer.AddService <IBroadcastDatabase>(database);
            ProgramOutput.Info("Database connection to {0} is up.", settings.DB_FILE);

            return(database);
        }
Exemple #20
0
    public override Response Execute()
    {
        try
        {
            var reciever = MasterContainer.GetService <LiveBroadcastReciever>();
            reciever.Abort();
            MasterContainer.RemoveService <LiveBroadcastReciever>();

            return(new StopLiveBroadcastResponse(StopLiveBroadcastResults.Stopped));
        }
        catch
        {
            return(new StopLiveBroadcastResponse(StopLiveBroadcastResults.NoBroadcast));
        }
    }
Exemple #21
0
    public override Response Execute()
    {
        var authorizator = MasterContainer.GetService <IAuthorizator>();
        var granted      = new List <Permission>();

        foreach (Permission requested in RequestedPermissons)
        {
            if (authorizator.HasPermission(User, requested))
            {
                granted.Add(requested);
            }
        }

        return(new ListPermissionsResponse(granted.ToArray()));
    }
Exemple #22
0
        private void OnStop()
        {
            if (rcRecorder.Recording)
            {
                rcRecorder.Stop();
                streamer.StopStreaming();

                var client      = MasterContainer.GetService <RequestSender>();
                var currentUser = MasterContainer.GetService <User>();
                var request     = new StopLiveBroadcastRequest(currentUser);
                client.SendAndRecieve <StopLiveBroadcastResponse>(request);
            }
            rcRecorder.FrontColor = Color.Lime;
            btnRecord.Enabled     = true;
        }
Exemple #23
0
    public override Response Execute()
    {
        var db      = MasterContainer.GetService <IBroadcastDatabase>();
        var removed = db.Remove(Broadcast.Id);

        if (removed)
        {
            var store = MasterContainer.GetService <FileStore>();
            if (Broadcast.Filename != null)
            {
                store.Delete(Broadcast.Filename);
            }
        }

        return(new AlterBroadcastResponse(removed? AlterBroadcastResult.Success : AlterBroadcastResult.NotFound));
    }
Exemple #24
0
        private static IAuthorizator InitAuthorizator(Settings settings)
        {
            // Init LDAP authorizator
            var authorizator = InitLdap(settings, delegate(LdapCredentials creds)
            {
#if DEBUG
                var auth = new DummyAuthorizator();
#else
                var auth = new LdapAuthorizator(creds);
                auth.Connect();
#endif

                return(auth);
            });

            var authorizatorCache = new AuthorizatorCache(authorizator, (int)settings.SECURITY_CACHE_EXPIRATION);

            MasterContainer.AddService <IAuthorizator>(authorizatorCache);

            // Load LDAP permission binding from def file
            var permissionCfgFile = Properties.Settings.Default.LDAP_PERMISSION_DEF_FILE;

            string[] permissionCfg;
            try
            {
                permissionCfg = File.ReadAllLines(permissionCfgFile);
            }
            catch (Exception ex)
            {
                ProgramOutput.Error("Cannot process LDAP permission binding file {0}, because of following reason:\r\n{1}", permissionCfgFile, ex.Message);
                return(null);
            }
            try
            {
                PermissionAttributeEditor.AddAttribFromConfig(permissionCfg, LdapAuthorizator.LDAP_GROUP_ATTRIBUTE,
                                                              (groupName) => groupName.ToString());
            }
            catch
            {
                ProgramOutput.Error("Cannot process LDAP permission binding file {0}. Invalid syntax.");
                return(null);
            }
            ProgramOutput.Error("Authorizator initialized, LDAP connection to {0} up.", authorizator.ConnectedServer);

            return(authorizatorCache);
        }
Exemple #25
0
    //public IAudioCodec Codec { get; private set; }



    public override Response Execute()
    {
        var playback = MasterContainer.GetService <Playback>();
        var reciever = new LiveBroadcastReciever(RemoteIP, Port, new PcmCodec(), playback);

        MasterContainer.AddService(reciever);
        try
        {
            reciever.RecieveLiveBroadcast();
            return(new LiveBroadcastResponse(LiveBroadcastResults.Recieving));
        }
        catch (Exception ex)
        {
            reciever.Abort();
            return(new LiveBroadcastResponse(LiveBroadcastResults.Failed, ex.Message));
        }
    }
Exemple #26
0
        private static BroadcastScheduler InitScheduler(Settings settins, IBroadcastDatabase db, FileStore store, Playback playback)
        {
            BroadcastScheduler scheduler;

            try
            {
                scheduler = new BroadcastScheduler(db, store, playback, (int)settins.SCHEDULER_CHECK_INTERVAL);
            }
            catch
            {
                ProgramOutput.Error("Cannot initialize scheduler. Please check the scheduler parameters in config file.");
                return(null);
            }
            MasterContainer.AddService <BroadcastScheduler>(scheduler);

            return(scheduler);
        }
Exemple #27
0
        private static IAuthenticator InitAuthenticator(Settings settings)
        {
            var authenticator = InitLdap(settings, delegate(LdapCredentials creds)
            {
#if DEBUG
                var auth = new DummyAuthenticator();
#else
                var auth = new LdapAuthenticator(creds);
                auth.Connect();
#endif

                return(auth);
            });
            var authenticatorCache = new AuthenticatorCache(authenticator, (int)settings.SECURITY_CACHE_EXPIRATION);

            MasterContainer.AddService <IAuthenticator>(authenticatorCache);
            ProgramOutput.Info("Authenticator initialized, LDAP connection to {0} up.", authenticator.ConnectedServer);

            return(authenticatorCache);
        }
    public override Response Execute()
    {
        var db         = MasterContainer.GetService <IBroadcastDatabase>();
        var collisions = db.GetInterval(Broadcast.StartTime, Broadcast.EndTime);

        UploadBroadcastResult result;

        if (collisions.Length > 0)
        {
            var authorizator = MasterContainer.GetService <IAuthorizator>();
            if (authorizator.HasPermission(User, Permission.AdminBroadcasts))
            {
                foreach (var collision in collisions)
                {
                    db.Remove(collision.Id);
                }
                result = UploadBroadcastResult.Success;
            }
            else
            {
                result = UploadBroadcastResult.CollissionBlocked;
            }
        }
        else
        {
            result = UploadBroadcastResult.Success;
        }

        if (result == UploadBroadcastResult.Success)
        {
            var          store    = MasterContainer.GetService <FileStore>();
            string       fullPath = store.GenerateFullFilename(Broadcast);
            FileReciever reciever = new FileReciever(Session.Host, Port, BufferSize, fullPath);
            reciever.Start();

            Broadcast.Filename = store.GetFilename(Broadcast);
            db.Add(Broadcast);
        }

        return(new UploadBroadcastResponse(result));
    }
        public override void Run()
        {
            MasterContainer.IsStuck = false;
            if (!ObjectManager.isGhost)
            {
                Calls.DoString("RepopMe();");
            }
            else
            {
                if (ObjectManager.CorpseLocation.differenceToPlayer() > 3)
                {
                    WaitAfterRelease.Reset();
                    while (!WaitAfterRelease.IsReady())
                    {
                        Thread.CurrentThread.Join(100);
                    }
                    Ingame.Tele(ObjectManager.CorpseLocation, 60, false);
                }
                else
                {
                    RezzTimer.Reset();
                    while (!RezzTimer.IsReady())
                    {
                        Thread.CurrentThread.Join(100);
                    }

                    while (ObjectManager.isGhost && ObjectManager.playerPtr != 0)
                    {
                        Calls.DoString("RetrieveCorpse();");
                        RezzTimer2.Reset();
                        while (!RezzTimer2.IsReady())
                        {
                            Thread.CurrentThread.Join(100);
                        }
                    }
                    MasterContainer.Reset();
                }
            }
        }
Exemple #30
0
        private static bool ExchangeKey(RequestSender sender)
        {
            var sessionCrypter = new AesCrypter();

            sender.SessionCrypter = sessionCrypter;
            MasterContainer.AddService <EncryptionProvider>(sessionCrypter);
            var keyExchange         = new KeyExchangeRequest(sessionCrypter.Key);
            var keyExchangeResponse = sender.SendAndRecieve <Response>(keyExchange);

            if (keyExchangeResponse == null)
            {
                MessageBox.Show("Server neodpověděl na požadavek pro výměnu symetrického klíče. Zkontrolujte síťové připojení.", "Chyba", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            if (!keyExchangeResponse.Success)
            {
                MessageBox.Show("Nepodařilo se provést výměnu šifrovacího klíče se serverm. Spojení není bezpečné. Program bude ukončen.", "Chyba", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return(false);
            }

            return(true);
        }
 internal static HandleRef getCPtr(MasterContainer obj) {
   return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
 }
 public static extern void MasterContainer_director_connect(HandleRef jarg1, MasterContainer.SwigDelegateMasterContainer_0 delegate0, MasterContainer.SwigDelegateMasterContainer_1 delegate1, MasterContainer.SwigDelegateMasterContainer_2 delegate2, MasterContainer.SwigDelegateMasterContainer_3 delegate3, MasterContainer.SwigDelegateMasterContainer_4 delegate4, MasterContainer.SwigDelegateMasterContainer_5 delegate5, MasterContainer.SwigDelegateMasterContainer_6 delegate6, MasterContainer.SwigDelegateMasterContainer_7 delegate7, MasterContainer.SwigDelegateMasterContainer_8 delegate8, MasterContainer.SwigDelegateMasterContainer_9 delegate9, MasterContainer.SwigDelegateMasterContainer_10 delegate10, MasterContainer.SwigDelegateMasterContainer_11 delegate11, MasterContainer.SwigDelegateMasterContainer_12 delegate12, MasterContainer.SwigDelegateMasterContainer_13 delegate13, MasterContainer.SwigDelegateMasterContainer_14 delegate14, MasterContainer.SwigDelegateMasterContainer_15 delegate15, MasterContainer.SwigDelegateMasterContainer_16 delegate16, MasterContainer.SwigDelegateMasterContainer_17 delegate17);