コード例 #1
0
        public bool checkUser()
        {
            if (currentUser.isEnterIntoSystem())
            {
                return(true);
            }
            else
            {
                FromDataSetToString newConverter = new FromDataSetToString();
                if (newConverter.convert(configProxyForLoadDataFromBDAndExecute(
                                             queryConfigurator.getSult(
                                                 currentUser.getLogin()))) == null)
                {
                    return(false);
                }

                string currentPassword = hashWorker.getHash(currentUser.getPassword(),
                                                            getSultForCurrentUser());


                if (converter.convert(configProxyForLoadDataFromBDAndExecute(
                                          queryConfigurator.checkUser(
                                              currentUser.getLogin(), currentPassword))) == 1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
コード例 #2
0
        public void addNewUser(SecurityUserInterface user)
        {
            string sult = hashWorker.getSult(user);


            if (currentUser.isAdmin())
            {
                //Проверка, есть ли уже такой пользователь
                FromDataSetToString newConverter = new FromDataSetToString();
                if (newConverter.convert(configProxyForLoadDataFromBDAndExecute(
                                             queryConfigurator.getSult(
                                                 currentUser.getLogin()))) == null)
                {
                    configProxyForLoadDataFromBDAndExecute(queryConfigurator.addNewUser(
                                                               user.getLogin(), hashWorker.getHash(user.getPassword(), sult),
                                                               sult, user.isAdmin()));
                    InformationPopupWindow       view   = new InformationPopupWindow();
                    InformationPopupWindowConfig config = new InformationPopupWindowConfig(
                        "Пользователь: " + user.getLogin() + " успешно добавлен!");
                    view.setConfig(config);
                    view.show();
                }
                else
                {
                    InformationPopupWindow       view   = new InformationPopupWindow();
                    InformationPopupWindowConfig config = new InformationPopupWindowConfig(
                        "Логин: " + user.getLogin() + " был ранее добавлен в систему, " +
                        "пожалуйста, придумайте другой");
                    view.setConfig(config);
                    view.show();
                }
            }
            else
            {
                throw new InsufficientPermissionsException("This user does not"
                                                           + "have sufficient rights to perform the specified operation");
            }
        }
コード例 #3
0
        private string getSultForCurrentUser()
        {
            FromDataSetToString newConverter = new FromDataSetToString();
            string currentSult = newConverter.convert(configProxyForLoadDataFromBDAndExecute(
                                                          queryConfigurator.getSult(
                                                              currentUser.getLogin())));

            //MS Sql Server дописывает пробелы в конец, их нужно убрать
            bool goNext = false;

            while (goNext == false)
            {
                if (currentSult.ElementAt(currentSult.Length - 1).Equals(' '))
                {
                    currentSult = currentSult.Remove(currentSult.Length - 1);
                }
                else
                {
                    goNext = true;
                }
            }

            return(currentSult);
        }