Exemplo n.º 1
0
        /// <summary>
        ///     Contacts the login api server and gets a login response
        /// </summary>
        /// <param name="account">The account credentials</param>
        /// <param name="config">The login configuration</param>
        /// <returns>An instance of <typeparam name="T"></typeparam> with deserialized values if successful, otherwise a default instance.</returns>
        internal static async Task <T> GetLoginAPIResponse <T>(IAccount account, LoginConfig config)
        {
            try
            {
                HttpResponseMessage message;
                if (config.ShouldPost)
                {
                    // Post to server
                    message = await Client.PostAsync(config.LoginAPI, config.PostData);
                }
                else
                {
                    // Send a get request
                    message = await Client.GetAsync(config.LoginAPI);
                }

                // Get response
                var responseString = await message.Content.ReadAsStringAsync();


                return(JsonConvert.DeserializeObject <T>(responseString));
            }
            catch
            {
                return(default(T));
            }
        }
Exemplo n.º 2
0
        public override void Login(LoginConfig config)
        {
            var prompt = new CustomMessageBox {
                Caption            = config.Title,
                Message            = config.Message,
                LeftButtonContent  = config.OkText,
                RightButtonContent = config.CancelText
            };

            var txtUser = new PhoneTextBox {
                Hint = config.LoginPlaceholder,
                Text = config.LoginValue ?? String.Empty
            };
            var txtPass = new PasswordBox();
            var stack   = new StackPanel();

            stack.Children.Add(txtUser);
            stack.Children.Add(txtPass);
            prompt.Content = stack;

            prompt.Dismissed += (sender, args) => config.OnResult(new LoginResult(
                                                                      txtUser.Text,
                                                                      txtPass.Password,
                                                                      args.Result == CustomMessageBoxResult.LeftButton
                                                                      ));
            this.Dispatch(prompt.Show);
        }
Exemplo n.º 3
0
 static Configs()
 {
     directory    = GetDirectoryConfig();
     ClientConfig = LoadingClientConfig(directory);
     PatchConfig  = LoadingPatchConfig(directory);
     LoginConfig  = LoadingLoginConfig(directory);
 }
        public override void Login(LoginConfig config)
        {
            var context = Utils.GetActivityContext();
            var txtUser = new EditText(context) {
                Hint = config.LoginPlaceholder,
                Text = config.LoginValue ?? String.Empty
            };
            var txtPass = new EditText(context) {
                Hint = config.PasswordPlaceholder,
                TransformationMethod = PasswordTransformationMethod.Instance
            };
            var layout = new LinearLayout(context) {
                Orientation = Orientation.Vertical
            };
            layout.AddView(txtUser, ViewGroup.LayoutParams.MatchParent);
            layout.AddView(txtPass, ViewGroup.LayoutParams.MatchParent);

            Utils.RequestMainThread(() =>
                new AlertDialog
                    .Builder(Utils.GetActivityContext())
                    .SetTitle(config.Title)
                    .SetMessage(config.Message)
                    .SetView(layout)
                    .SetPositiveButton(config.OkText, (o, e) =>
                        config.OnResult(new LoginResult(txtUser.Text, txtPass.Text, true))
                    )
                    .SetNegativeButton(config.CancelText, (o, e) =>
                        config.OnResult(new LoginResult(txtUser.Text, txtPass.Text, false))
                    )
                    .Show()
            );
        }
Exemplo n.º 5
0
 public Login(LoginConfig config)
 {
     Config = config;
     this.BindingContext = config;
     InitializeComponent();
     this.LockModal();
 }
Exemplo n.º 6
0
        public async Task ShowLoginInterface(LoginConfig loginConfig)
        {
            Console.WriteLine("Please log in with you Vman credentials to continue:");

            bool success;

            do
            {
                if (loginConfig.Email == null)
                {
                    Console.Write("Email: ");
                    loginConfig.Email = Console.ReadLine();
                }

                if (loginConfig.Password == null)
                {
                    Console.Write("Password: "******"Wrong email or password. Try again:");
                    loginConfig = new LoginConfig();
                }
            } while (success != true);

            Console.Clear();
        }
 public SettingViewModel(LoginConfig config)
 {
     PathDofus   = config.PathDofus;
     AccountName = config.Username;
     Password    = config.Password;
     CanHide     = false;
 }
        public override void Login(LoginConfig config) {
            var prompt = new CustomMessageBox {
                Caption = config.Title,
                Message = config.Message,
                LeftButtonContent = config.OkText,
                RightButtonContent = config.CancelText
            };

            var txtUser = new PhoneTextBox {
                Hint = config.LoginPlaceholder,
                Text = config.LoginValue ?? String.Empty
            };
            var txtPass = new PasswordBox();
            var stack = new StackPanel();
            stack.Children.Add(txtUser);
            stack.Children.Add(txtPass);
            prompt.Content = stack;

            prompt.Dismissed += (sender, args) => config.OnResult(new LoginResult(
                txtUser.Text, 
                txtPass.Password, 
                args.Result == CustomMessageBoxResult.LeftButton
            ));
            this.Dispatch(prompt.Show);
        }
Exemplo n.º 9
0
        public SessionServices(IOptions <LoginConfig> settings, IHttpContextAccessor httpContextAccessor)
        {
            _config = settings.Value;
            var client   = new MongoClient(_config.Uri);
            var database = client.GetDatabase(_config.Database);

            credentials = database.GetCollection <Credentials>(_config.Collection);
        }
Exemplo n.º 10
0
        public HomeServices(IOptions <LoginConfig> settings)
        {
            _config = settings.Value;
            var client   = new MongoClient(_config.Uri);
            var database = client.GetDatabase(_config.Database);

            credentials = database.GetCollection <Credentials>(_config.Collection);
        }
Exemplo n.º 11
0
        public void StudentsTest(LoginConfig login)
        {
            var account = new VulcanAccount(login);

            account.InitializeStudents();

            Assert.True(account.Students.Count > 0);
        }
Exemplo n.º 12
0
        private void Login()
        {
            var Config = new LoginConfig();

            Config.Title    = "ログイン";
            Config.OnAction = (result) => { ResultText = "Login: "******"キャンセル"); };

            _dialogs.Login(Config);
        }
Exemplo n.º 13
0
        private void 更改配置ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LoginConfig a = new LoginConfig();

            if (a.ShowDialog() == DialogResult.OK)
            {
                MessageBox.Show("更改配置成功,请重新登陆系统");
                Application.Exit();
            }
        }
        /// <summary>
        /// Save config in file .json
        /// </summary>
        /// <param name="window"></param>
        private void SaveConfig(object window)
        {
            LoginConfig config = new LoginConfig(AccountName, Password, PathDofus);

            config.UpdateData();

            if (window is Window)
            {
                (window as Window).Close();
            }
        }
Exemplo n.º 15
0
        public static bool Export(BaseView _view)
        {
            SaveFileDialog _sf = new SaveFileDialog();

            _sf.Filter      = "Excle文件|*.xls|HTML文件|*.mht|文本文件|*.TXT";
            _sf.FilterIndex = 1;
            string _fname = "";

            while (_fname == "")
            {
                if (_sf.ShowDialog() == DialogResult.OK)
                {
                    _fname = _sf.FileName;
                    if (_fname != "")
                    {
                        switch (_sf.FilterIndex)
                        {
                        case 1:
                            _view.ExportToXls(_fname, true);
                            break;

                        case 2:
                            _view.ExportToMht(_fname, "UTF-8", "", true);
                            break;

                        case 3:
                            _view.ExportToText(_fname, "\t");
                            break;

                        case 4:
                            _view.ExportToPdf(_fname);
                            break;
                        }
                        IAuthorize ics_Auth        = LoginConfig.GetAuthorizeInterface();
                        int        _exportRowCount = _view.RowCount;
                        ics_Auth.WriteExportLog(_exportRowCount, (_view.Tag != null) ? _view.Tag.ToString() : "");
                        if (XtraMessageBox.Show("导出文件已成功,是否立即打开?", "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            System.Diagnostics.Process.Start(_fname);
                        }
                        return(true);
                    }
                    else
                    {
                        XtraMessageBox.Show("请输入导出文件名!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    return(false);
                }
            }
            return(false);
        }
Exemplo n.º 16
0
        public void Login(string nickname, string serverIP)
        {
            Instance.nickname = nickname;
            Endpoint.openEngine();
            EndpointConfig config = Endpoint.createEndpointConfigBuilder(
                serverIP, 30000, LoginConfig.plainLogin(nickname, "123456", "test"))
                                    .staticViewClasses(ViewManager.createInstance(providerId))
                                    .build();

            Endpoint.start(config, new MyListener());
        }
Exemplo n.º 17
0
        public void TimetableTest(LoginConfig login)
        {
            var account = new VulcanAccount(login);

            account.InitializeStudents();

            var timetable = account.Students[0].GetTimetable(account, DateTime.Today);

            Assert.NotNull(timetable);
            Assert.NotEmpty(timetable.Days);
            Assert.NotEmpty(timetable.Days[0].Lessons);
        }
        public PersonServices(IOptions <MongoDbConfigs> options, IOptions <LoginConfig> loginoptions)
        {
            Personconfig = options.Value;
            var client   = new MongoClient(Personconfig.Uri);
            var database = client.GetDatabase(Personconfig.Database);

            _person     = database.GetCollection <Person>(Personconfig.Collection);
            loginconfig = loginoptions.Value;
            var Loginclient   = new MongoClient(loginconfig.Uri);
            var Logindatabase = client.GetDatabase(loginconfig.Database);

            _cred = database.GetCollection <Credentials>(loginconfig.Collection);
        }
Exemplo n.º 19
0
        public async Task <LoginResult> LoginAsync(LoginConfig config)
        {
            if (string.IsNullOrEmpty(config.TitleBackground))
            {
                config.TitleBackground = Color.Accent.ToHex();
            }
            Login login = new Login(config);
            await login.ShowDialog();

            LoginResult result = new LoginResult(login.Ok, config.User, config.Password);

            config.OnAction?.Invoke(result);
            return(result);
        }
Exemplo n.º 20
0
        public void LoginTest(LoginConfig login)
        {
            var account = new VulcanAccount(login);

            account.LoginService.Login(login.Email, login.Password, out var certificate, out var sendCertificate);

            Assert.NotNull(certificate);
            Assert.True(certificate.IsValid());

            Assert.NotNull(sendCertificate);
            Assert.True(sendCertificate.IsValid());

            _output.WriteLine($"Successfuly logged with {login.Email}, {sendCertificate.StudentSchools.Count} students, {certificate.Wresult.Symbols.Count} symbols");
        }
Exemplo n.º 21
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddTransient <FuncionarioRepositorio>();

            var loginConfig = new LoginConfig();

            services.AddSingleton(loginConfig);

            var tokenConfigurations = new TokenConfigurations();

            new ConfigureFromConfigurationOptions <TokenConfigurations>(
                Configuration.GetSection("TokenConfigurations"))
            .Configure(tokenConfigurations);
            services.AddSingleton(tokenConfigurations);


            services.AddAuthentication(authOptions =>
            {
                authOptions.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                authOptions.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
            }).AddJwtBearer(bearerOptions =>
            {
                var paramsValidation = bearerOptions.TokenValidationParameters;
                paramsValidation.IssuerSigningKey = loginConfig.Key;
                paramsValidation.ValidAudience    = tokenConfigurations.Audience;
                paramsValidation.ValidIssuer      = tokenConfigurations.Issuer;

                // Valida a assinatura de um token recebido
                paramsValidation.ValidateIssuerSigningKey = true;

                // Verifica se um token recebido ainda é válido
                paramsValidation.ValidateLifetime = true;

                // Tempo de tolerância para a expiração de um token (utilizado
                // caso haja problemas de sincronismo de horário entre diferentes
                // computadores envolvidos no processo de comunicação)
                paramsValidation.ClockSkew = TimeSpan.Zero;
            });

            // Ativa o uso do token como forma de autorizar o acesso
            // a recursos deste projeto
            services.AddAuthorization(auth =>
            {
                auth.AddPolicy("Bearer", new AuthorizationPolicyBuilder()
                               .AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme)
                               .RequireAuthenticatedUser().Build());
            });

            services.AddMvc();
        }
Exemplo n.º 22
0
        public WindowsMain(ClientEnvironmentType environment)
        {
            _environment = environment;

            //ProtobufMappingSetup.Setup();

            ClientLogger.init(); // Initializes logger
            ClientLogger.Log(Log_Type.INFO, "Game Initialized");
            _graphics             = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            _LoginConfig = new LoginConfig();

            this.Exiting += Main_Exiting;
        }
Exemplo n.º 23
0
        public void LuckyNumberTest(LoginConfig login)
        {
            var account = new VulcanAccount(login);

            account.InitializeStudents();

            foreach (var school in account.Students.Select(x => x.School).DistinctBy(x => x.SchoolId))
            {
                var luckyNumber = school.GetLuckyNumber(account);
                if (login.IsTestLog)
                {
                    Assert.Equal(DateTime.Now.Hour <= 7 ? -1 : DateTime.Today.Day, luckyNumber);
                }
                _output.WriteLine($"{school.SchoolSymbol} have lucky {luckyNumber} today");
            }
        }
Exemplo n.º 24
0
        public BotnetMain(ClientEnvironmentType environment) : base(environment)
        {
            _LoginConfig = new LoginConfig {
                LoginIP = "73.136.102.14"
            };

            _loadGraphics = false;

            _updateTimer           = new Timer(16.66666f);
            _updateTimer.AutoReset = false;

            _updateTimer.Elapsed += _updateTimer_Elapsed;

            Initialize();
            LoadContent();
        }
        // ACR User Dialogs v6.5.1 で Login dialog でバックスペースが効かない場合がある workaround
        // LoginDialogFragment の OnKeyPress の処理がコメント化されているため
        // https://github.com/aritchie/userdialogs/issues/400 対応されたら不要
        public override IDisposable Login(LoginConfig config)
        {
            var activity = TopActivityFunc();

            if (activity is AppCompatActivity compatActivity)
            {
                return(ShowDialog <CustomLoginAppCompatDialogFragment, LoginConfig>(compatActivity, config));
            }

            if (activity is FragmentActivity fragmentActivity)
            {
                return(ShowDialog <CustomLoginDialogFragment, LoginConfig>(fragmentActivity, config));
            }

            return(Show(activity, () => new CustomLoginBuilder().Build(activity, config)));
        }
        public override void Login(LoginConfig config) {
            this.Dispatch(() => {
                var dlg = new UIAlertView { AlertViewStyle = UIAlertViewStyle.LoginAndPasswordInput };
                var txtUser = dlg.GetTextField(0);
                var txtPass = dlg.GetTextField(1);

                txtUser.Placeholder = config.LoginPlaceholder;
                txtUser.Text = config.LoginValue ?? String.Empty;
                txtPass.Placeholder = config.PasswordPlaceholder;
                txtPass.SecureTextEntry = true;

                dlg.Clicked += (s, e) => {
                    var ok = (dlg.CancelButtonIndex != e.ButtonIndex);
                    config.OnResult(new LoginResult(txtUser.Text, txtPass.Text, ok));
                };
                dlg.Show();
            });
        }
Exemplo n.º 27
0
 public override void Login(LoginConfig config) {
     UITextField txtUser = null;
     UITextField txtPass = null;
     var dlg = UIAlertController.Create(config.Title ?? String.Empty, config.Message, UIAlertControllerStyle.Alert);
     dlg.AddAction(UIAlertAction.Create(config.OkText, UIAlertActionStyle.Default, x => config.OnResult(new LoginResult(txtUser.Text, txtPass.Text, true))));
     dlg.AddAction(UIAlertAction.Create(config.CancelText, UIAlertActionStyle.Default, x => config.OnResult(new LoginResult(txtUser.Text, txtPass.Text, false))));
     dlg.AddTextField(x => {
         txtUser = x;
         x.Placeholder = config.LoginPlaceholder;
         x.Text = config.LoginValue ?? String.Empty;
     });
     dlg.AddTextField(x => {
         txtPass = x;
         x.Placeholder = config.PasswordPlaceholder;
         x.SecureTextEntry = true;
     });
     this.Present(dlg);
 }
Exemplo n.º 28
0
        public override void Login(LoginConfig config)
        {
            var context = Utils.GetActivityContext();
            var txtUser = new EditText(context)
            {
                Hint      = config.LoginPlaceholder,
                Text      = config.LoginValue ?? String.Empty,
                InputType = InputTypes.TextVariationVisiblePassword
            };

            txtUser.SetMaxLines(1);

            var txtPass = new EditText(context)
            {
                Hint = config.PasswordPlaceholder ?? "*",
                TransformationMethod = PasswordTransformationMethod.Instance,
                InputType            = InputTypes.ClassText | InputTypes.TextVariationPassword
            };

            txtPass.SetMaxLines(1);

            var layout = new LinearLayout(context)
            {
                Orientation = Orientation.Vertical
            };

            layout.AddView(txtUser, ViewGroup.LayoutParams.MatchParent);
            layout.AddView(txtPass, ViewGroup.LayoutParams.MatchParent);

            Utils.RequestMainThread(() =>
                                    new AlertDialog
                                    .Builder(Utils.GetActivityContext())
                                    .SetTitle(config.Title)
                                    .SetMessage(config.Message)
                                    .SetView(layout)
                                    .SetPositiveButton(config.OkText, (o, e) =>
                                                       config.OnResult(new LoginResult(txtUser.Text, txtPass.Text, true))
                                                       )
                                    .SetNegativeButton(config.CancelText, (o, e) =>
                                                       config.OnResult(new LoginResult(txtUser.Text, txtPass.Text, false))
                                                       )
                                    .Show()
                                    );
        }
Exemplo n.º 29
0
        public override void Login(LoginConfig config)
        {
            UITextField txtUser = null;
            UITextField txtPass = null;

            Device.BeginInvokeOnMainThread(() => {
                if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
                {
                    var dlg = UIAlertController.Create(config.Title ?? String.Empty, config.Message, UIAlertControllerStyle.Alert);
                    dlg.AddAction(UIAlertAction.Create(config.OkText, UIAlertActionStyle.Default, x => config.OnResult(new LoginResult(txtUser.Text, txtPass.Text, true))));
                    dlg.AddAction(UIAlertAction.Create(config.CancelText, UIAlertActionStyle.Default, x => config.OnResult(new LoginResult(txtUser.Text, txtPass.Text, true))));

                    dlg.AddTextField(x => {
                        txtUser       = x;
                        x.Placeholder = config.LoginPlaceholder;
                        x.Text        = config.LoginValue ?? String.Empty;
                    });
                    dlg.AddTextField(x => {
                        txtPass           = x;
                        x.Placeholder     = config.PasswordPlaceholder;
                        x.SecureTextEntry = true;
                    });
                    Present(dlg);
                }
                else
                {
                    var dlg = new UIAlertView {
                        AlertViewStyle = UIAlertViewStyle.LoginAndPasswordInput
                    };
                    txtUser = dlg.GetTextField((nint)0);
                    txtPass = dlg.GetTextField((nint)1);

                    txtUser.Placeholder = config.LoginPlaceholder;
                    txtUser.Text        = config.LoginValue ?? String.Empty;
                    txtPass.Placeholder = config.PasswordPlaceholder;

                    dlg.Clicked += (s, e) => {
                        var ok = ((int)dlg.CancelButtonIndex != (int)e.ButtonIndex);
                        config.OnResult(new LoginResult(txtUser.Text, txtPass.Text, ok));
                    };
                    dlg.Show();
                }
            });
        }
Exemplo n.º 30
0
        public override void Login(LoginConfig config)
        {
            UITextField txtUser = null;
            UITextField txtPass = null;
            var         dlg     = UIAlertController.Create(config.Title ?? String.Empty, config.Message, UIAlertControllerStyle.Alert);

            dlg.AddAction(UIAlertAction.Create(config.OkText, UIAlertActionStyle.Default, x => config.OnResult(new LoginResult(txtUser.Text, txtPass.Text, true))));
            dlg.AddAction(UIAlertAction.Create(config.CancelText, UIAlertActionStyle.Default, x => config.OnResult(new LoginResult(txtUser.Text, txtPass.Text, false))));
            dlg.AddTextField(x => {
                txtUser       = x;
                x.Placeholder = config.LoginPlaceholder;
                x.Text        = config.LoginValue ?? String.Empty;
            });
            dlg.AddTextField(x => {
                txtPass           = x;
                x.Placeholder     = config.PasswordPlaceholder;
                x.SecureTextEntry = true;
            });
            this.Present(dlg);
        }
Exemplo n.º 31
0
        public void LoginConfigTest()
        {
            string domain = Guid.NewGuid().ToString();
            string authenticationGroupTag = Guid.NewGuid().ToString();
            string userTag      = Guid.NewGuid().ToString();
            var    loginSession = new LoginSession()
            {
                LoginSessionId = Guid.NewGuid().ToString()
            };

            LoginConfig.SaveLoginConfig(domain, authenticationGroupTag, userTag, loginSession);
            var loginConfig = LoginConfig.GetLoginConfig(domain, authenticationGroupTag);

            Assert.AreEqual(userTag, loginConfig.UserTag);
            Assert.AreEqual(loginSession.LoginSessionId, loginConfig.LoginSession.LoginSessionId);
            LoginConfig.SaveLoginConfig(domain, authenticationGroupTag, string.Empty, null);
            loginConfig = LoginConfig.GetLoginConfig(domain, authenticationGroupTag);
            Assert.AreEqual(string.Empty, loginConfig.UserTag);
            Assert.AreEqual(null, loginConfig.LoginSession);
        }
        public override void Login(LoginConfig config)
        {
            this.Dispatch(() => {
                var dlg = new UIAlertView {
                    AlertViewStyle = UIAlertViewStyle.LoginAndPasswordInput
                };
                var txtUser = dlg.GetTextField(0);
                var txtPass = dlg.GetTextField(1);

                txtUser.Placeholder     = config.LoginPlaceholder;
                txtUser.Text            = config.LoginValue ?? String.Empty;
                txtPass.Placeholder     = config.PasswordPlaceholder;
                txtPass.SecureTextEntry = true;

                dlg.Clicked += (s, e) => {
                    var ok = (dlg.CancelButtonIndex != e.ButtonIndex);
                    config.OnResult(new LoginResult(txtUser.Text, txtPass.Text, ok));
                };
                dlg.Show();
            });
        }
Exemplo n.º 33
0
        public LoginStateManager(
            LoginConfig loginConfig,
            ClientManager clientManager,
            GlobalGameUISingleton globalGameUiSingleton,
            MessageService_ToServer messageService,
            LidgrenNetworkingService networkingService)
            : base(null, null, networkingService, messageService, GameStateType.Login)
        {
            _clientManager = clientManager;

            // Todo: Unfuck this
            WebView = new PortWebView(globalGameUiSingleton, null);

            _loginConfig = loginConfig;

            //_gameStateManager = gameStateManager;

            networkingService.RegisterMessageHandler(this, _loginStateManager_MessageReceived);

            this._asynchronousUpdateList.Add(this);
        }
Exemplo n.º 34
0
 protected override bool HandleRecentInfo()
 {
     if (RecentInfo.Length == 0)
     {
         UserConfig            = new LoginConfig();
         UserConfig.reply_code = (int)ReplyCodeMeaning.NoNetWork;
         UserConfig.reply_msg  = "没有校园网";
         Debug.WriteLine(UserConfig.reply_msg);
         UserConfig.userinfo = null;
         return(false);
     }
     else
     {
         //如果有返回信息
         var serializer = new DataContractJsonSerializer(typeof(LoginConfig));
         var mStream    = new MemoryStream(Encoding.UTF8.GetBytes(RecentInfo));
         UserConfig = (LoginConfig)serializer.ReadObject(mStream);
         Debug.WriteLine(UserConfig.reply_msg);
         return(UserConfig.reply_code == (int)ReplyCodeMeaning.LogInSucceed || UserConfig.reply_code == (int)ReplyCodeMeaning.AlreadyLoggedIn);
     }
 }