private void AuthenticationAdminForm_Shown(object sender, EventArgs e) { cbAuthenticationModes.Items.Add(new ComboBoxItem <AuthenticationModeEnum>(AuthenticationModeEnum.Off)); cbAuthenticationModes.Items.Add(new ComboBoxItem <AuthenticationModeEnum>(AuthenticationModeEnum.OnlyPassword)); cbAuthenticationModes.Items.Add(new ComboBoxItem <AuthenticationModeEnum>(AuthenticationModeEnum.UsernameAndPassword)); switch (Settings.AuthenticationMode) { case AuthenticationModeEnum.OnlyPassword: cbAuthenticationModes.SelectedItem = cbAuthenticationModes.Items[1]; gbPassword.Enabled = true; pUsers.Enabled = false; break; case AuthenticationModeEnum.UsernameAndPassword: cbAuthenticationModes.SelectedItem = cbAuthenticationModes.Items[2]; gbPassword.Enabled = false; pUsers.Enabled = true; break; case AuthenticationModeEnum.Off: cbAuthenticationModes.SelectedItem = cbAuthenticationModes.Items[0]; gbPassword.Enabled = false; pUsers.Enabled = false; break; } foreach (string username in AuthenticationHandlerModule.GetUsers()) { ListViewItem item = new ListViewItem(username); lvUsers.Items.Add(item); } }
private void btRemoveUser_Click(object sender, EventArgs e) { if (MessageBox.Show(this, Resources.MsgBox_AreYouSure, Resources.MsgBox_Title_Save, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { AuthenticationHandlerModule.RemoveUser(lvUsers.SelectedItems[0].Text); lvUsers.SelectedItems[0].Remove(); } }
private void btOk_Click(object sender, EventArgs e) { if (tbUsername.Enabled) { if (tbUsername.Text.Length == 0) { MessageBox.Show(this, Resources.MsgBox_UserMandatory, Resources.MsgBox_Title_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (AuthenticationHandlerModule.GetUsers().Contains <string>(tbUsername.Text)) { MessageBox.Show(this, Resources.MsgBox_UserNameExist, Resources.MsgBox_Title_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } AuthenticationHandlerModule.SetPassword(tbUsername.Text, tbUserPassword.Text); lvUsers.Items.Add(new ListViewItem(tbUsername.Text)); } else { AuthenticationHandlerModule.SetPassword(tbUsername.Text, tbUserPassword.Text); } btCancel_Click(sender, e); }
/// <summary> /// Login into the remote service /// </summary> /// <param name="request">The request.</param> /// <returns></returns> public override LoginResponseArgs Login(Forge.RemoteDesktop.Contracts.LoginRequestArgs request) { if (request == null) { ThrowHelper.ThrowArgumentNullException("request"); } LoginResponseArgs response = null; lock (mBlackList) { if (mBlackList.ContainsKey(this.RemoteHost)) { DateTime blacklistedTime = mBlackList[this.RemoteHost]; if (blacklistedTime.AddMinutes(Settings.BlackListTimeout) < DateTime.Now) { mBlackList.Remove(this.RemoteHost); } else { if (LOGGER.IsInfoEnabled) { LOGGER.Info(string.Format("REMOTE_DESKTOP_SERVICE_CONTRACT, client blacklisted. SessionId: {0}", this.SessionId)); } this.mChannel.Disconnect(mSessionId); return(null); } } } if (RemoteDesktopServiceManager.Instance.ManagerState == Management.ManagerStateEnum.Started) { if (AuthenticationHandlerModule.CheckAuthenticationInfo(request.UserName, request.Password)) { // sikeres az auth this.IsAuthenticated = true; mLoginFailedCounter = 0; if (RemoteDesktopServiceManager.Instance.AcceptUser(this)) { if (LOGGER.IsDebugEnabled) { LOGGER.Debug(string.Format("REMOTE_DESKTOP_SERVICE_CONTRACT, login succeeded. SessionId: {0}", this.SessionId)); } response = new LoginResponseArgs(LoginResponseStateEnum.AccessGranted); } else { if (LOGGER.IsDebugEnabled) { LOGGER.Debug(string.Format("REMOTE_DESKTOP_SERVICE_CONTRACT, login succeeded, but service did not accept new client to serve. Service inactive. SessionId: {0}", this.SessionId)); } response = new LoginResponseArgs(LoginResponseStateEnum.ServiceBusy); } } else { if (LOGGER.IsDebugEnabled) { LOGGER.Debug(string.Format("REMOTE_DESKTOP_SERVICE_CONTRACT, authentication failed. SessionId: {0}", this.SessionId)); } response = new LoginResponseArgs(LoginResponseStateEnum.AccessDenied); mLoginFailedCounter++; } } else { if (LOGGER.IsDebugEnabled) { LOGGER.Debug(string.Format("REMOTE_DESKTOP_SERVICE_CONTRACT, login failed. Service inactive. SessionId: {0}", this.SessionId)); } response = new LoginResponseArgs(LoginResponseStateEnum.ServiceInactive); mLoginFailedCounter++; } if (Settings.MaximumFailedLoginAttempt < mLoginFailedCounter) { mBlackList[this.RemoteHost] = DateTime.Now; if (LOGGER.IsInfoEnabled) { LOGGER.Info(string.Format("REMOTE_DESKTOP_SERVICE_CONTRACT, client blacklisted. SessionId: {0}", this.SessionId)); } this.mChannel.Disconnect(mSessionId); } return(response); }
private void btSaveGlobalPassword_Click(object sender, EventArgs e) { AuthenticationHandlerModule.SetPassword(tbPassword.Text); tbPassword.Text = string.Empty; MessageBox.Show(this, Resources.MsgBox_PasswordSaved, Resources.MsgBox_Title_Save, MessageBoxButtons.OK, MessageBoxIcon.Information); }