Exemplo n.º 1
0
        public static void InitApp(String applicationId, String apiKey)
        {
            if (String.IsNullOrEmpty(applicationId))
            {
                throw new ArgumentNullException(ExceptionMessage.NULL_APPLICATION_ID);
            }

            if (String.IsNullOrEmpty(apiKey))
            {
                throw new ArgumentNullException(ExceptionMessage.NULL_SECRET_KEY);
            }

            Log.addLogger(Log.DEFAULTLOGGER, new ConsoleLogger());
            Log.startLogging(BACKENDLESSLOG);
#if WITHRT
            Quobject.EngineIoClientDotNet.Modules.LogManager.Enabled = !DeviceCheck.IsMobile;
#endif
            AppId  = applicationId;
            APIKey = apiKey;

            Persistence   = new PersistenceService();
            Data          = Persistence;
            Geo           = new GeoService();
            Messaging     = new MessagingService();
            Files         = new FileService();
            UserService   = new UserService();
            Events        = Events.GetInstance();
            Cache         = Cache.GetInstance();
            Counters      = CounterService.GetInstance();
            Logging       = new LoggingService();
            CustomService = new CustomService();

      #if WITHRT
            RT = new RTServiceImpl();
      #endif

            MessageWriter.DefaultWriter = new UnderflowWriter();
            MessageWriter.AddAdditionalTypeWriter(typeof(BackendlessUser), new BackendlessUserWriter());
            MessageWriter.AddAdditionalTypeWriter(typeof(Geometry), new BackendlessGeometryWriter());
            MessageWriter.AddAdditionalTypeWriter(typeof(Point), new BackendlessGeometryWriter());
            MessageWriter.AddAdditionalTypeWriter(typeof(LineString), new BackendlessGeometryWriter());
            MessageWriter.AddAdditionalTypeWriter(typeof(Polygon), new BackendlessGeometryWriter());
            ORBConfig.GetInstance().getObjectFactories().AddArgumentObjectFactory(typeof(BackendlessUser).FullName, new BackendlessUserFactory());
            ORBConfig.GetInstance().getObjectFactories().AddArgumentObjectFactory(typeof(GeometryDTO).FullName, new BackendlessGeometryFactory());
            ORBConfig.GetInstance().getObjectFactories().AddArgumentObjectFactory(typeof(Geometry).FullName, new BackendlessGeometryFactory());
            ORBConfig.GetInstance().getObjectFactories().AddArgumentObjectFactory(typeof(Point).FullName, new BackendlessGeometryFactory());
            ORBConfig.GetInstance().getObjectFactories().AddArgumentObjectFactory(typeof(LineString).FullName, new BackendlessGeometryFactory());
            ORBConfig.GetInstance().getObjectFactories().AddArgumentObjectFactory(typeof(Polygon).FullName, new BackendlessGeometryFactory());

            HeadersManager.CleanHeaders();
            LoginStorage loginStorage = new LoginStorage();

            if (loginStorage.HasData)
            {
                HeadersManager.GetInstance().AddHeader(HeadersEnum.USER_TOKEN_KEY, loginStorage.UserToken);
            }
        }
Exemplo n.º 2
0
 public LoginService(IServerConfiguration configuration)
 {
     _configuration = configuration;
     _loginStorage = new LoginStorage(_configuration);
     _store =
         NotificationManager<LoginService>.Instance.RegisterDuplexService<UserIdentity, ILoginNotifier>(
             NotifierBehaviour.OneInstance);
     _loginStorage.OnAddItem += new EventHandler<KeyCollection<UserIdentity>.KeyEventArgs>(_loginStorage_OnAddItem);
     _loginStorage.OnRemoveItem += new EventHandler<KeyCollection<UserIdentity>.KeyEventArgs>(_loginStorage_OnRemoveItem);
 }
Exemplo n.º 3
0
        public void LoginStorage()
        {
            LoginStorage storage = new LoginStorage();
            int          res     = storage.WhoLogins("Admin", "Admin");

            Assert.AreEqual(0, res);
            res = storage.WhoLogins("jk", "jk");
            Assert.AreEqual(1, res);
            res = storage.WhoLogins("belfer1", "belfer1");
            Assert.AreEqual(2, res);
        }
        public bool Verify(BigInteger username, BigInteger password)
        {
            string       fromFile      = System.IO.File.ReadAllText($"../../res/log.txt");
            string       jsonDecrypted = StringCipher.Decrypt(BigInteger.Parse(fromFile), "ACHTENNEN");
            LoginStorage loginStorage  = JsonConvert.DeserializeObject <LoginStorage>(jsonDecrypted);

            if (loginStorage.Storage.ContainsKey(StringCipher.Decrypt(username, "ACHTENNEN")) && loginStorage.Storage[(StringCipher.Decrypt(username, "ACHTENNEN"))] == StringCipher.Decrypt(password, "ACHTENNEN"))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// The constructor for the server
        /// </summary>
        /// <param name="port">insert the port number here what you want to use</param>
        public Server(int port)
        {
            bool ipIsOk = IPAddress.TryParse(GetLocalIPAddress(), out host);

            if (!ipIsOk)
            {
                Console.WriteLine("IP Adress could not be Parsed");
                Environment.Exit(1);
            }
            this.listener    = new TcpListener(host, port);
            this.ClientList  = new Dictionary <string, HandleClient>();
            this.PatientList = new List <Patient>();
            this.Util        = new ServerUtil();
            this.Util.GenerateJson();
            this.Util.GenTrainingSesJson(this.Util.PatientsInfo);
            Storage = new LoginStorage();
            FillPatientList();
        }
Exemplo n.º 6
0
        public static void InitApp(string applicationId, string apiKey)
        {
            if (string.IsNullOrEmpty(applicationId))
            {
                throw new ArgumentNullException(ExceptionMessage.NULL_APPLICATION_ID);
            }

            if (string.IsNullOrEmpty(apiKey))
            {
                throw new ArgumentNullException(ExceptionMessage.NULL_SECRET_KEY);
            }

            AppId  = applicationId;
            APIKey = apiKey;

            Persistence   = new PersistenceService();
            Data          = Persistence;
            Geo           = new GeoService();
            Messaging     = new MessagingService();
            Files         = new FileService();
            UserService   = new UserService();
            Events        = Events.GetInstance();
            Cache         = Cache.GetInstance();
            Counters      = CounterService.GetInstance();
            Logging       = new LoggingService();
            CustomService = new CustomService();

            MessageWriter.DefaultWriter = new UnderflowWriter();
            MessageWriter.AddAdditionalTypeWriter(typeof(BackendlessUser), new BackendlessUserWriter());
            ORBConfig.GetInstance().getObjectFactories().AddArgumentObjectFactory(typeof(BackendlessUser).FullName, new BackendlessUserFactory());

            HeadersManager.CleanHeaders();
            LoginStorage loginStorage = new LoginStorage();

            if (loginStorage.HasData)
            {
                HeadersManager.GetInstance().AddHeader(HeadersEnum.USER_TOKEN_KEY, loginStorage.UserToken);
            }
        }