Example #1
0
        public static bool LoadTokenList()
        {
            RegistryKey _lmSoftware   = null;
            RegistryKey _koDevelopers = null;
            RegistryKey _appSession   = null;

            try
            {
                string           user = Environment.UserDomainName + "\\" + Environment.UserName;
                RegistrySecurity rs   = new RegistrySecurity();

                rs.AddAccessRule(new RegistryAccessRule(user,
                                                        RegistryRights.WriteKey | RegistryRights.ReadKey | RegistryRights.Delete,
                                                        InheritanceFlags.None,
                                                        PropagationFlags.None,
                                                        AccessControlType.Allow));
                _lmSoftware   = Registry.CurrentUser.OpenSubKey("SOFTWARE", true);
                _koDevelopers = _lmSoftware.CreateSubKey("KODevelopers", RegistryKeyPermissionCheck.ReadWriteSubTree, rs);
                _appSession   = _koDevelopers.CreateSubKey($"Session_{application_name}{application_version}", RegistryKeyPermissionCheck.ReadWriteSubTree, rs);

                foreach (string svName in _appSession.GetValueNames())
                {
                    TokenList.Add(svName, _appSession.GetValue(svName) as string);
                }

                return(true);
            }
            catch (Exception ex)
            {
                StaticReference.ShowError(null, ex.Message);
                return(false);
            }
        }
        public static bool Save()
        {
            RegistryKey _lmSoftware   = null;
            RegistryKey _koDevelopers = null;
            RegistryKey _pentagram    = null;
            RegistryKey _tbl          = null;

            try
            {
                string           user = Environment.UserDomainName + "\\" + Environment.UserName;
                RegistrySecurity rs   = new RegistrySecurity();

                rs.AddAccessRule(new RegistryAccessRule(user,
                                                        RegistryRights.WriteKey | RegistryRights.ReadKey | RegistryRights.Delete,
                                                        InheritanceFlags.None,
                                                        PropagationFlags.None,
                                                        AccessControlType.Allow));
                _lmSoftware = Registry.CurrentUser.OpenSubKey("SOFTWARE", true);

                _koDevelopers = _lmSoftware.CreateSubKey("KODevelopers", RegistryKeyPermissionCheck.ReadWriteSubTree, rs);
                _pentagram    = _koDevelopers.CreateSubKey("PENTAGRAM", RegistryKeyPermissionCheck.ReadWriteSubTree, rs);
                _tbl          = _pentagram.CreateSubKey("TBLEditor", RegistryKeyPermissionCheck.ReadWriteSubTree, rs);


                _tbl.SetValue("Username", Username);
                _tbl.SetValue("Password", Password);
                _tbl.SetValue("KeepLoggedIn", KeepLoggedIn);
                _tbl.SetValue("RememberMe", RememberMe);
                _tbl.SetValue("SkinName", SkinName);
                _tbl.SetValue("Language", Language);
                return(true);
            }
            catch (Exception e)
            {
                StaticReference.ShowError(null, e.Message);
                return(false);
            }
        }
Example #3
0
        protected override void OnCreateMainForm()
        {
            base.OnCreateMainForm();
            RegistrySettings.Load();
            UserLookAndFeel.Default.SkinName = RegistrySettings.SkinName;
            SupportedLanguage current = SupportedLanguage.Türkçe; // default

            if (Enum.TryParse(RegistrySettings.Language, out current))
            {
            }
            LanguageManager.ChangeLanguage(current, null);

            /*  MainForm = new mainFrm();
             * return;*/
            if (RegistrySettings.KeepLoggedIn)
            {
                var loginResult = KODevLoginManager.Login(StaticReference.Decrypt(RegistrySettings.Username, RegistrySettings._key, RegistrySettings._keySize), StaticReference.Decrypt(RegistrySettings.Password, RegistrySettings._key, RegistrySettings._keySize));

                switch (loginResult.Result.Substring(0, 29))
                {
                //LOGINSTATUS_KEY_3 (TOKEN METHODU İÇİN)  Token mevcut, fakat süresi dolmuş. Yeniden ID şifre ile token almak gerekli.
                case "LS003F5esRwzAPt33psnJdEt7eJkT":
                //LOGINSTATUS_KEY_4 (TOKEN METHODU İÇİN) Token mevcut, geçerli fakat kullanıcının gönderdiği değer yanlış!
                case "LS004GUcuNEM67D2P5PbUXqTLPHTt":
                //LOGINSTATUS_KEY_5 (PAROLA METHODU İÇİN) Hesap şuan kullanımda (token başkasında.)
                case "LS004rPrCHnnYLHUREjrh2fUggjQJ":
                //LOGINSTATUS_KEY_1 (PAROLA METHODU İÇİN) ID veya Parola yanlış.
                case "LS001Gs84DmanHUWmrWwLgDKysrFk":
                    StaticReference.ShowError((XtraForm)MainForm, loginResult.Message);
                    // failure, redirect to login page
                    using (frmLogin login = new frmLogin())
                    {
                        login.ShowDialog();
                    }
                    break;

                //LOGINSTATUS_KEY_2 (TOKEN METHODU İÇİN)  Token mevcut, geçerli ve doğru.
                case "LS002RvkzvsDWeLdGDGCKHDKx8SuP":
                //LOGINSTATUS_KEY_T (PAROLA METHODU İÇİN) ID ve Parola doğru, token değeri JSON içerisinde token kısmına eklenir.
                case "LS00TF5esRwzAPt33psnJdEt7eJkT":
                    RegistrySettings.LoggedIn = true;
                    break;

                //LOGINSTATUS_KEY_E
                case "LS00Ef9TV4vPbmGh9tytn7HdTMZp2":
                    StaticReference.ShowError((XtraForm)MainForm, loginResult.Message);
                    break;
                }
            }
            else
            {
                using (frmLogin login = new frmLogin())
                {
                    login.ShowDialog();
                }
            }
            if (RegistrySettings.LoggedIn)
            {
                MainForm = new mainFrm();
            }
            else
            {
                Environment.Exit(0);
            }
        }