/// <summary> /// Dokonuje próby logowania, jeżeli zapisane jest poprzednie logowanie /// </summary> public async Task LoginOnStartup() { SettingsManager settingsManager = new SettingsManager(); string defaultProvider = settingsManager.LoadProvider(); if (!string.IsNullOrEmpty(defaultProvider)) { if (Enum.TryParse(typeof(AuthenticationProvider), defaultProvider, out object provider)) { IsAuthenticationButtonsEnabled = false; AuthenticationProvider authProvider = (AuthenticationProvider)provider; AuthenticationProcessor authentication = new AuthenticationProcessor(); UserPublic userAccount = await authentication.AuthenticateAsync(authProvider, mCancellationToken.Token).ConfigureAwait(false); if (this.ValidateAccount(userAccount, authProvider)) { await LoginUserPTM().ConfigureAwait(false); await this.OpenMainWindowAsync().ConfigureAwait(false); return; } IsAuthenticationButtonsEnabled = true; } } else { settingsManager.DeleteProvider(); } // Jeśli nie udało się zweryfikować usera, to pokazujemy okno mContext.WindowManager.ActivateWindow(Identity); }
public StatusCode Connect() { SystemProcessor = new SystemProcessor(this); KexProcessor = new KeyExchangeProcessor(this); var ident = new IdentificationProcessor(this); Socket = new SshSocket(this); var code = Socket.Connect(Hostname, Port); if (code == StatusCode.OK) { ident.Wait(); if (ident.StatusCode != StatusCode.OK) { return(ident.StatusCode); } KexProcessor.Wait(); if (KexProcessor.StatusCode != StatusCode.OK) { return(KexProcessor.StatusCode); } var auth = new AuthenticationProcessor(this); auth.Wait(); IsAuthenticated = auth.StatusCode == StatusCode.OK; return(auth.StatusCode); } return(code); }
/// <summary> /// Dokonuje logowania przy użyciu Microsoft (Oauth 2) /// </summary> public async Task AuthenticateWithMicrosoftAsync() { try { IsAuthenticationButtonsEnabled = false; AuthenticationProcessor authentication = new AuthenticationProcessor(); UserPublic userAccount = await authentication.AuthenticateAsync(AuthenticationProvider.Microsoft, mCancellationToken.Token).ConfigureAwait(false); if (this.ValidateAccount(userAccount, AuthenticationProvider.Microsoft)) { await LoginUserPTM().ConfigureAwait(false); await this.OpenMainWindowAsync().ConfigureAwait(false); } } catch (OperationCanceledException) { // do nothing } catch (Exception ex) { mContext.DialogBuilder.ErrorDialog((Application.Current.TryFindResource("IDS_LoginWindow_AuthenticationError") as string), ex); } finally { IsAuthenticationButtonsEnabled = true; } }
public List<Message> RequestMessages(Guid token, int lastMessageId) { lock (threadLock) { AuthenticationProcessor auth = new AuthenticationProcessor(); if (auth.ValidateNameByToken(token) != null) { var newMesseges = ServerContext.ChatSession.Where(m => m.Id > lastMessageId).ToList<Message>(); return newMesseges; } else return null; } }
public List <Message> RequestMessages(Guid token, int lastMessageId) { lock (threadLock) { AuthenticationProcessor auth = new AuthenticationProcessor(); if (auth.ValidateNameByToken(token) != null) { var newMesseges = ServerContext.ChatSession.Where(m => m.Id > lastMessageId).ToList <Message>(); return(newMesseges); } else { return(null); } } }
public async Task AuthenticateAsync_OnGoogleRefreshToken_SuccessfulAuthentication() { // ARRANGE AuthenticationProcessor processor = new AuthenticationProcessor(); CredentialsManager manager = new CredentialsManager(AuthenticationProvider.Google); manager.SaveToken("*TOKEN*"); // ACT UserPublic account = await processor.AuthenticateAsync(AuthenticationProvider.Google, CancellationToken.None); // ASSERT account.Should().NotBeNull(); manager.DeleteToken(); }
public bool PutMessage(Guid token, string message) { lock (threadLock) { AuthenticationProcessor auth = new AuthenticationProcessor(); var name = auth.ValidateNameByToken(token); if (name != null) { Message newMessage = new Message(); newMessage.Id = ServerContext.ChatSession.Count + 1; newMessage.Name = name; newMessage.Time = DateTime.Now; newMessage.Content = message; ServerContext.ChatSession.Add(newMessage); return(true); } return(false); } }
public bool PutMessage(Guid token, string message) { lock (threadLock) { AuthenticationProcessor auth = new AuthenticationProcessor(); var name = auth.ValidateNameByToken(token); if (name != null) { Message newMessage = new Message(); newMessage.Id = ServerContext.ChatSession.Count + 1; newMessage.Name = name; newMessage.Time = DateTime.Now; newMessage.Content = message; ServerContext.ChatSession.Add(newMessage); return true; } return false; } }
public AuthController(IOptions <AppSettings> appSettings, AuthenticationProcessor authenticationProcessor) { _appSettings = appSettings.Value; _authenticationProcessor = authenticationProcessor; }