コード例 #1
0
        public static ProjectScanStatuses EditRemark(long resultId, long pathId, string remark)
        {
            LoginData     loginData     = LoginHelper.LoadSaved();
            OidcLoginData oidcLoginData = OidcLoginData.GetOidcLoginDataInstance();
            LoginResult   loginResult   = new LoginResult();
            bool          cancelPressed = false;

            if (oidcLoginData.AccessToken == null)
            {
                //Execute login
                loginResult = LoginHelper.DoLoginWithoutForm(out cancelPressed, false);
                if (!loginResult.IsSuccesfull)
                {
                    loginResult = LoginHelper.DoLogin(out cancelPressed);
                }

                if (loginResult.IsSuccesfull)
                {
                    return(EditRemark(loginResult, resultId, pathId, remark));
                }
                else if (!cancelPressed)
                {
                    TopMostMessageBox.Show("Unable to connect to server or user creadentials are invalid. Please verify data", "Log in problem");
                    return(ProjectScanStatuses.Error);
                }
            }
            else
            {
                loginResult.AuthenticationData = loginData;
                loginResult.IsSuccesfull       = true;
            }

            return(ProjectScanStatuses.CanceledByUser);
        }
コード例 #2
0
        public static LoginResult LoginToServer()
        {
            LoginData     loginData     = LoginHelper.LoadSaved();
            OidcLoginData oidcLoginData = OidcLoginData.GetOidcLoginDataInstance();
            LoginResult   loginResult   = new LoginResult();
            bool          cancelPressed = false;

            if (oidcLoginData.AccessToken == null)
            {
                try
                {
                    loginResult = LoginHelper.DoLoginWithoutForm(out cancelPressed, false);
                    if (!loginResult.IsSuccesfull)
                    {
                        loginResult = LoginHelper.DoLogin(out cancelPressed);
                    }
                }
                catch (Exception e)
                {
                    Logger.Create().Error(e.ToString());
                    MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK);
                    return(null);
                }
            }
            else
            {
                loginResult.AuthenticationData = loginData;
                loginResult.IsSuccesfull       = true;
            }

            if (cancelPressed)
            {
                return(null);
            }
            if (!loginResult.IsSuccesfull)
            {
                if (!OIDCLoginHelper.errorWasShown)
                {
                    OIDCLoginHelper.errorWasShown = false;
                    showErrorMessage("Unable to connect to the server. Please verify data");
                    return(null);
                }
                return(LoginToServer());
            }
            return(loginResult);
        }
コード例 #3
0
        static ProjectScanStatuses LoginAndBindSelectedProject(Entities.Project project)
        {
            OidcLoginData oidcLoginData = OidcLoginData.GetOidcLoginDataInstance();
            LoginData     loginData     = LoginHelper.LoadSaved();
            LoginResult   loginResult   = new LoginResult();
            bool          cancelPressed = false;

            if (oidcLoginData.AccessToken == null)
            {
                //Execute login
                loginResult = LoginHelper.DoLoginWithoutForm(out cancelPressed, false);
                if (!loginResult.IsSuccesfull)
                {
                    loginResult = LoginHelper.DoLogin(out cancelPressed);
                }
            }
            else
            {
                loginResult.AuthenticationData = loginData;
                loginResult.IsSuccesfull       = true;
            }

            if (loginResult.IsSuccesfull)
            {
                _canceled = false;
                BindSelectedProject(loginResult, project);
                if (!_canceled)
                {
                    return(ProjectScanStatuses.Success);
                }
                else
                {
                    return(ProjectScanStatuses.CanceledByUser);
                }
            }
            else if (!cancelPressed)
            {
                TopMostMessageBox.Show("Unable to connect to server.", "Log in problem");
                return(ProjectScanStatuses.Error);
            }

            return(ProjectScanStatuses.CanceledByUser);
        }
コード例 #4
0
        private static LoginResult getLoginResult()
        {
            LoginData     loginData     = LoginHelper.LoadSaved();
            LoginResult   loginResult   = new LoginResult();
            OidcLoginData oidcLoginData = OidcLoginData.GetOidcLoginDataInstance();
            bool          cancelPressed;

            if (oidcLoginData.AccessToken == null)
            {
                loginResult = LoginHelper.DoLoginWithoutForm(out cancelPressed, false);
                if (!loginResult.IsSuccesfull)
                {
                    loginResult = LoginHelper.DoLogin(out cancelPressed);
                }
            }
            else
            {
                loginResult.AuthenticationData = loginData;
                loginResult.IsSuccesfull       = true;
            }

            return(loginResult);
        }
コード例 #5
0
        /// <summary>
        /// Execute scan
        /// </summary>
        /// <param name="project">Upload project folder</param>
        /// <param name="isIncremental"></param>
        /// <param name="scanData"></param>
        /// <param name="scanId"></param>
        /// <returns></returns>
        public ProjectScanStatuses DoScan(Project project, bool isIncremental, ref CxWSQueryVulnerabilityData[] scanData, ref long scanId)
        {
            if (_scan != null && _scan.InProcess)
            {
                return(ProjectScanStatuses.CanceledByUser);
            }
            LoginResult loginResult = new LoginResult();

            try
            {
                //Release old view data

                CommonActionsInstance.getInstance().ClearScanProgressView();

                LoginData     logindata     = LoginHelper.LoadSaved();
                OidcLoginData oidcLoginData = OidcLoginData.GetOidcLoginDataInstance();
                //Execute login
                if (oidcLoginData.AccessToken == null)
                {
                    loginResult = Login();
                    if (loginResult == null || loginResult.AuthenticationData == null)
                    {
                        LoginHelper.ShowLoginErrorMessage(loginResult);
                        return(ProjectScanStatuses.Error);
                    }
                }
                else
                {
                    loginResult.AuthenticationData = logindata;
                    loginResult.IsSuccesfull       = true;
                }

                if (_cancelPressed)
                {
                    return(ProjectScanStatuses.CanceledByUser);
                }

                if (loginResult.IsSuccesfull)
                {
                    _scan = new Scan(loginResult, onScanInBackground, onCancel, onDetails)
                    {
                        InProcess     = true,
                        DockView      = CommonActionsInstance.getInstance().ScanProgressView,
                        ScanProject   = project,
                        IsIncremental = isIncremental
                    };

                    //Execute setting upload project properties
                    _uploadSettings = GetUploadSettings(project, loginResult);

                    if (_uploadSettings == null || _cancelPressed)
                    {
                        return(ProjectScanStatuses.CanceledByUser);
                    }

                    if (_uploadSettings.IsUploading)
                    {
                        _scan.UploadSettings = _uploadSettings;

                        return(ExecuteScan(project, ref scanData, ref scanId));
                    }
                }
                else if (!_cancelPressed)
                {
                    TopMostMessageBox.Show("Unable to connect to server or user creadentials are invalid. Please verify data", "Log in problem");
                    return(ProjectScanStatuses.Error);
                }
            }
            finally
            {
                if (_scan != null)
                {
                    _scan.InProcess = false;
                }
            }

            return(ProjectScanStatuses.CanceledByUser);
        }