public LoginResponseStateEnum Login(string username, string password) { if (!IsConnected) { throw new InvalidOperationException("Client was not connected."); } LoginResponseArgs response = mProxy.Login(new LoginRequestArgs(username, password)); LoginResponseStateEnum result = LoginResponseStateEnum.AccessDenied; if (response != null) { result = response.ResponseState; if (result == LoginResponseStateEnum.AccessGranted) { mProxy.IsAuthenticated = true; mServiceConfig = mProxy.ClientGetConfiguration(); mCursorWithIds.Clear(); foreach (CursorInfo info in mServiceConfig.Cursors) { mCursorWithIds[info.CursorId] = info.Cursor; } pbClient.Size = mServiceConfig.DesktopSize; DrawInitialBlackBackground(); } } return(result); }
private async Task LoginCommandHandler() { LoginResponseArgs args; if (string.IsNullOrEmpty(this.UserName) || string.IsNullOrEmpty(this.Password)) { args = new LoginResponseArgs(ResponseCode.Failure, "Invalid values."); } else { if (this.UserName == "*****@*****.**" && this.Password == "123") { args = new LoginResponseArgs(ResponseCode.Success, "Login Success"); } else { args = new LoginResponseArgs(ResponseCode.Failure, "Invalid Username and Password"); } } LoginEvent?.Invoke(this, args); }
/// <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); }