private void btnSubmitGroup1_Click(object sender, RoutedEventArgs e) { try { string newUsername = ValidateUser.ValidateUsername(tbUsername.Text, _selectedUser.username.Trim()); Authentification.ChangeUsername(_userId, tbUsername.Text); Authentification.ChangeUserRole(_userId, cbRole.Text); DialogHelper.ShowInfo("Požadované změny byly úspěšně provedeny."); InitializeInterface(); } catch (InvalidUsernameException ex) { DialogHelper.ShowWarning(ex.Message); } catch (UsernameAlreadyExistsException ex) { DialogHelper.ShowWarning(ex.Message); } catch { DialogHelper.ShowError("Kvůli neočekávané chybě operace selhala."); } }
private void btnSubmitGroup2_Click(object sender, RoutedEventArgs e) { try { string newPswd = ValidateUser.ValidatePassword(pbNewPswd.Password); string newPswdAgain = pbNewPswdAgain.Password; if (newPswd == newPswdAgain) { Authentification.ChangePassword(_userId, newPswd); pbNewPswd.Password = string.Empty; pbNewPswdAgain.Password = string.Empty; DialogHelper.ShowInfo("Heslo bylo úspěšně změněno."); InitializeInterface(); } else { pbNewPswdAgain.Password = string.Empty; throw new PasswordsDoNotMatchException(); } } catch (InvalidAuthPasswordException ex) { pbNewPswd.Password = string.Empty; pbNewPswd.Focus(); DialogHelper.ShowWarning(ex.Message); } catch (PasswordsDoNotMatchException ex) { DialogHelper.ShowWarning(ex.Message); } catch { DialogHelper.ShowError("Heslo nemohlo být změněno."); } }
private void btnSubmit_Click(object sender, RoutedEventArgs e) { // Uložení hesla try { string pswd = ValidateAmininistrator.ValidateAdminPassword(pbAdminPswd.Password); if (pswd == pbAdminPswdAgain.Password) { DatabaseSetup.RecreateAppData(); Authentification.CreateAdministratorPassword(pbAdminPswd.Password); } else { DialogHelper.ShowWarning("Hesla se neshodují."); pbAdminPswdAgain.Password = string.Empty; pbAdminPswdAgain.Focus(); return; } } catch (InvalidAdminPasswordException ex) { DialogHelper.ShowWarning(ex.Message); pbAdminPswd.Password = string.Empty; pbAdminPswd.Focus(); return; } catch (AdministratorSetupFailedException ex) { DialogHelper.ShowError(ex.Message); return; } catch { return; } Success = true; this.Close(); }
public void CheckMasterPasswordTest() { SecureString wrongPassword = new SecureString(); wrongPassword.AppendChar('c'); SecureString passwd = new SecureString(); foreach (char c in masterPassword.ToCharArray()) { passwd.AppendChar(c); } Authentification.NewMasterPassword(passwd, triggerCompleteEvent: true); PasswordObject oldAppPassword = new PasswordObject(); oldAppPassword.Password = Authentification.AppPassword.Password.Copy(); oldAppPassword.Salt = new byte[Authentification.AppPassword.Salt.Length]; Authentification.AppPassword.Salt.CopyTo(oldAppPassword.Salt, 0); Assert.IsFalse(Authentification.CheckMasterPassword(wrongPassword)); Assert.IsTrue(Authentification.CheckMasterPassword(passwd)); PasswordObject newAppPassword = new PasswordObject(); newAppPassword.Password = Authentification.AppPassword.Password.Copy(); newAppPassword.Salt = new byte[Authentification.AppPassword.Salt.Length]; Authentification.AppPassword.Salt.CopyTo(newAppPassword.Salt, 0); Assert.IsTrue(CheckAppPassword(oldAppPassword, newAppPassword)); Assert.IsTrue(Authentification.CheckMasterPassword(passwd, shortCheck: true)); Assert.IsTrue(CheckAppPassword(newAppPassword, Authentification.AppPassword)); }
// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { BaseDeDonnées.ConfigureService(services, Configuration); ServicesDeDonnées.ConfigureServices(services); Authentification.ConfigureServices(services, Configuration); services.AddCors(options => { options.AddPolicy("AutoriseLocalhost", builder => builder .WithOrigins("https://localhost:4200", "https://localhost:44391") .AllowAnyHeader() .AllowAnyMethod() .AllowCredentials() .WithExposedHeaders(JwtFabrique.NomJwtRéponse.ToLower()) .Build() ); }); services.AddMvc(options => options.EnableEndpointRouting = false); services.AddDataProtection(); }
public void LancementAuth(string login, string mdp) { Authentification auth = new Authentification(login, mdp); th = new Thread(new ParameterizedThreadStart(RunAuth)); th.Start(auth); }
private void SignInButton_Click(object sender, EventArgs e) { try { IAuthentificationManager am = new Authentification(); am.load("users.bin"); am.authentify(loginText.Text, passwordText.Text); Console.WriteLine(loginText.Text + " has signed in !"); ChatWindow chatWindow = new ChatWindow(loginText.Text, clientGT); this.Dispose(); this.chatWindow = chatWindow; chatWindow.ShowDialog(); } catch (UserUnknownException ex) { errorsLabel.Text = ex.login + " is unknown"; } catch (WrongPasswordException ex) { errorsLabel.Text = "Invalid password "; } catch (IOException) { errorsLabel.Text = "Erreur dans la lecture ou l'ecriture du fichier"; } }
public void LoadAuthentificationTab() { Authentification.GetAuthentificationTab(); SelectedTabIndex = 0; Authentification.AuthentificationComplete += LoadFrameWorkTabs; WindowDragAreaWidth = StaticResources.MainWindowWidth - StaticResources.TabTitleDefaultWidth - StaticResources.SystemButtonWidth * 2; }
public IList<Right> GetListRight(Authentification user) { String url = this.wsRestAuthentified.UrlRootWS + "/user/rights"; String xmlRight = this.wsRestAuthentified.CallUrl(url, "GET"); IList<Right> rights = Get(xmlRight); return rights; }
/// <summary> /// Omezí přístup dle role /// </summary> private void ApplyAuthentification() { if (Authentification.IsInRole(Authentification.AuthUser.Id, "skladník")) { // Zakázat tabManagement.Visibility = Visibility.Collapsed; tabCashRegister.Visibility = Visibility.Collapsed; //Defaultně otevřená záložka tabMenu.SelectedItem = tabStorage; } if (Authentification.IsInRole(Authentification.AuthUser.Id, "pokladní")) { // Zakázat tabManagement.Visibility = Visibility.Collapsed; tabStorage.Visibility = Visibility.Collapsed; //Defaultně otevřená záložka tabMenu.SelectedItem = tabCashRegister; } if (Authentification.IsInRole(Authentification.AuthUser.Id, "manažer")) { // Defaultně otevřená záložka tabMenu.SelectedItem = tabManagement; } }
private void Awake() { if (Instance == null) { Instance = this; } else { Destroy(gameObject); return; } if (platform == null) { PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().Build(); PlayGamesPlatform.InitializeInstance(config); PlayGamesPlatform.DebugLogEnabled = true; platform = PlayGamesPlatform.Activate(); } Social.Active.localUser.Authenticate(success => { if (success) { AfterAuth?.Invoke(); } }); }
// Přihlášení private void btnLogin_Click(object sender, RoutedEventArgs e) { DatabaseSetup.InitializeLinqToSql(); if (Properties.Settings.Default.IsFullDb == "1") { try { DatabaseSetup.SetupDatabase(); DialogHelper.ShowInfo("Databáze byla automaticky naplněna daty."); } catch { DialogHelper.ShowInfo("Zvolená databáze nemohla být naplněna daty, neboť již nějaké obsahuje."); } } try { Authentification.Authentificate(tbUsername.Text, tbPassword.Password); _isAuthentificated = true; this.Close(); } catch (InvalidUsernameOrPasswordException ex) { tbPassword.Password = string.Empty; DialogHelper.ShowWarning(ex.Message); } }
public void ValidateNewPasswordReEnterTest() { SecureString string1 = new SecureString(); foreach (char c in validMasterPassword) { string1.AppendChar(c); } Authentification.NewMasterPassword(string1, true); Assert.IsFalse(viewModel.OnSubmitPassword()); CheckUIErrors("Current password cannot be empty!", Visibility.Visible); viewModel.CheckPassword = new PasswordString(string1); Assert.IsFalse(viewModel.OnSubmitPassword()); CheckUIErrors("", Visibility.Hidden, "New password cannot be empty!", Visibility.Visible); viewModel.NewPassword = new PasswordString(string1); Assert.IsFalse(viewModel.OnSubmitPassword()); CheckUIErrors("", Visibility.Hidden, "Cannot use current password as a new one!", Visibility.Visible); SecureString string2 = new SecureString(); foreach (char c in newPassword) { string2.AppendChar(c); } viewModel.NewPassword = new PasswordString(string2); Assert.IsFalse(viewModel.OnSubmitPassword()); CheckUIErrors("", Visibility.Hidden, "", Visibility.Hidden, "Please re-enter new password", Visibility.Visible); SecureString string3 = new SecureString(); foreach (char c in wrongPassword1) { string3.AppendChar(c); } viewModel.NewPasswordReEnter = new PasswordString(string3); Assert.IsFalse(viewModel.OnSubmitPassword()); CheckUIErrors("", Visibility.Hidden, "Passwords don't match!", Visibility.Visible, "Passwords don't match!", Visibility.Visible); viewModel.CheckPassword = new PasswordString(string3); viewModel.NewPasswordReEnter = new PasswordString(string2); Assert.IsFalse(viewModel.OnSubmitPassword()); CheckUIErrors("Current password is incorrect!", Visibility.Visible); SecureString string4 = new SecureString(); foreach (char c in wrongPassword2) { string4.AppendChar(c); } viewModel.CheckPassword = new PasswordString(string4); Assert.IsFalse(viewModel.OnSubmitPassword()); CheckUIErrors("Current password is incorrect!", Visibility.Visible); viewModel.CheckPassword = new PasswordString(string1); Assert.IsTrue(viewModel.OnSubmitPassword()); CheckUIErrors(); }
private void déconnexionToolStripMenuItem_Click(object sender, EventArgs e) { this.Hide(); Authentification a = new Authentification(); a.Show(); }
public User Authentificate(Authentification auth) { User result = null; User user = FindUserByEmail(auth.Email); if (user != null) { HashPassword hashPassword = new HashPassword(); if (user.Password == hashPassword.HashedPass(auth.Password)) { var key = Encoding.ASCII.GetBytes(_appsettings.Secret); var jwtToken = new SecurityTokenDescriptor { Subject = new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.Name, user.Id.ToString()), new Claim(ClaimTypes.Role, user.Role) }), Expires = DateTime.UtcNow.AddDays(2), SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature) }; var tokenHandler = new JwtSecurityTokenHandler(); var token = tokenHandler.CreateToken(jwtToken); user.Token = tokenHandler.WriteToken(token); result = user; } } return(result); }
/// <summary> /// Sends the message. /// </summary> internal void Send() { if (this.UseRC4) { Authentification Auth = new Authentification(); Auth.ClientVersion = this.Version; Auth.Encode(); byte[] Encrypted = Auth.Writer.ToArray(); this.RC4.Encrypt(ref Encrypted); Auth.Writer.Clear(); Auth.Writer.AddRange(Encrypted); Auth.Header.Length = (uint)Encrypted.Length; int Sent = this.Socket.Send(Auth.ToBytes); Debug.WriteLine("-> We sent " + Auth.Header.Identifier + ". [" + this.Version[0] + "." + this.Version[1] + "." + this.Version[2] + "]"); } else { Pre_Authentification _PreAuth = new Pre_Authentification(); _PreAuth.Version = this.Version; _PreAuth.Encode(); int Sent = this.Socket.Send(_PreAuth.ToBytes); Debug.WriteLine("-> We sent " + _PreAuth.Header.Identifier + ". [" + this.Version[0] + "." + this.Version[1] + "." + this.Version[2] + "]"); } }
public void TestAuthentification() { Person currentPerson = new Person("toto", "1234"); Person testPerson = new Person("toto", "1234"); Assert.IsTrue(Authentification.AuthentifyTest(currentPerson, testPerson)); }
public GestionIPSAS(User user, Authentification authentification) { InitializeComponent(); this.user = user; this.authentification = authentification; userToolStrip.Text = user.FirstName + " " + user.LastName + " - " + user.Role; }
static void Main(string[] args) { AuthentificationManager am = new Authentification(); // persistance try { am.Load("users.txt"); } catch (IOException e) { Console.WriteLine(e); } /*AuthentificationServer authentificationServer = new AuthentificationServer(am); * * authentificationServer.StartServer(26763); * * authentificationServer.Run(); * TextChatRoom chatRoom = new TextChatRoom(); * ServerChatRoom server = new ServerChatRoom(chatRoom); * server.StartServer(26763); * * server.Run();*/ ServerTopicsManager stm = new ServerTopicsManager(am); stm.StartServer(26763); stm.Run(); }
private void Register(object o) { RegisterRequestModel.Email = RegisterRequestModel.Email?.Trim(); string password = (o as PasswordBox).Password; if (!ValidateInput(password)) { return; } //TODO : Use the RegisterRequest in form to take directly the password as input RegisterRequestModel.Password = password; IsLoading = true; var requestResponse = Authentification.SignUp(this.RegisterRequestModel); if (requestResponse.Success) { MainTransitions.TransitionPageControl.ShowPage(new Tutorial()); } else { MessageBox.Show(requestResponse.Response); } }
/// <summary> /// Adds the given user to the database /// </summary> /// <param name="user">ASC user</param> public DBUserAuthentification AddUser(ref DBUser user) { if (!CanChangeName(user?.Name) || user is null) { return(null); } user.ID = NextID(USERS); while (HasUser(user.ID)) { ++user.ID; } DBUserAuthentification auth = new DBUserAuthentification { ID = user.ID, Salt = Authentification.GenerateSaltString(), }; if (!ValidateUser(user)) { return(null); } var sql = GetScript(nameof(AddUser), user.ID, auth.Salt, user.Name, user.Status, user.IsAdmin ? 1 : 0, user.IsBlocked ? 1 : 0); ExecuteVoid(sql); user = GetUser(user.ID); // update user $"Added user {{{user.UUID}}}".Ok(); return(DecodeUAuth(auth)); }
public void ListenerClient(Object ob) { TcpClient tcp = ob as TcpClient; CommandType comand = new CommandType(); BinaryFormatter bf = new BinaryFormatter(); //отримання з клієнта Authentification au = bf.Deserialize(tcp.GetStream()) as Authentification; bool result = contract.Connect(au.Login); BinaryWriter bw = new BinaryWriter(tcp.GetStream()); //відсилається назад bw.Write(result); BinaryReader br = new BinaryReader(tcp.GetStream()); if (!result) { return; } bool bye_bye = true; while (bye_bye) { try { comand = (CommandType)br.ReadByte(); } catch (Exception e) { string s = e.Message; } switch (comand) { case CommandType.Connect: break; case CommandType.Disconect: tcp.Close(); break; case CommandType.GetMessages: DateTime dt = (DateTime)bf.Deserialize(tcp.GetStream()); var t = contract.GetMessages(dt); bf.Serialize(tcp.GetStream(), t); break; case CommandType.SendMessage: Message data = bf.Deserialize(tcp.GetStream()) as Message; //* contract.SendMessage(data); break; default: bye_bye = false; break; } } }
public void OnSubmitPassword() { ClearValidationErrors(); if (ValidateNewPassword() && ValidateNewPasswordReEnter()) { Authentification.NewMasterPassword(NewPassword.Password); } }
private void Application_Exit(object sender, ExitEventArgs e) { Authentification.SignOut(); WebSocket.Instance.Terminate(); MessagingService.Instance.Terminate(); GameService.Instance.Terminate(); }
public void Logout() { var authentificationWindow = new Authentification(); var activeWindow = Application.Current.Windows.OfType <Window>().SingleOrDefault(x => x.IsActive); authentificationWindow.Show(); activeWindow.Close(); }
public static Authentification GetAuthentification() { byte[] jsonBytes = Properties.Resources.LoginPassword; string jsonString = Encoding.UTF8.GetString(jsonBytes); Authentification authentification = JsonConvert.DeserializeObject <Authentification>(jsonString); return(authentification); }
public IList <Right> GetListRight(Authentification user) { String url = this.wsRestAuthentified.UrlRootWS + "/user/rights"; String xmlRight = this.wsRestAuthentified.CallUrl(url, "GET"); IList <Right> rights = Get(xmlRight); return(rights); }
private DtoAuthentification ToDto(Authentification auth) { return(new DtoAuthentification() { code = auth.Code, state = auth.State }); }
// GET: Utilisateurs public ActionResult Index() { if (Authentification.EstConnecte()) { return(View(db.Utilisateurs.ToList())); } return(View("Error")); }
/// <summary> /// Událost tlačítka pro odhlášení uživatele. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnLogout_Click(object sender, RoutedEventArgs e) { if (Authentification.Logout()) { EntryWindow entryW = new EntryWindow(); entryW.Show(); Window.GetWindow(this).Close(); } }
public DtoAuthentification BuildAuthentification(string code, string state) { Auth = new Authentification() { Code = code, State = state }; return(ToDto(Auth)); }
public FriendList(string _userId, string _access_token, Authentification _auth) { users = new List<User>(); gettedUsers = new List<User>(); selectedUser = null; userId = _userId; access_token = _access_token; auth = _auth; DownloadUsers(); //timer timer = new Timer(); timer.Interval = 10000; timer.Tick += timer_Tick; }
public static void SendPlayerToWorld(Network.WorldLink link, Authentification.Network.AuthentificationClient client, string ticket) { link.SendMessage(new Network.Packet.PlayerCommingMessage(client.Account, ticket)); System.Threading.Thread.Sleep(250); }