Exemplo n.º 1
0
 private X509Certificate2 GetCertificate()
 {
     var certificate = new ModSicService(server).GetCertificate();
     return new X509Certificate2(certificate);
 }
Exemplo n.º 2
0
        private X509Certificate2 GetCertificate()
        {
            var certificate = new ModSicService(server).GetCertificate();

            return(new X509Certificate2(certificate));
        }
Exemplo n.º 3
0
        private void Execute(Operation operation)
        {
            modSICService = new ModSicService(this.server);
            switch (operation)
            {
                case Operation.ValidateSchematronOnly:
                    if (!ValidateSchema())
                        return;
                    if (options.ValidateSchematron)
                    {
                        if (!ValidadeSchematron())
                            return;
                    }
                    break;

                case Operation.SendCollect:
                    {
                        var ovalDefinitions = GetFileContents("Oval Definitions", this.definitionsFilename);
                        var ovalVariables = GetOvalExternalVariablesFile();
                        Dictionary<string, string> targetParameters = null;
                        if (!String.IsNullOrEmpty(options.SSHPort))
                        {
                            targetParameters = new Dictionary<string, string>();
                            targetParameters.Add("sshPort", options.SSHPort);
                        }

                        if (ovalDefinitions != null)
                        {
                            view.ShowMessage("Requesting collect...");
                            var sendCollectResult = modSICService.SendCollect(target.Address, CreateCredentials(), ovalDefinitions, ovalVariables, targetParameters);

                            view.ShowMessage(String.Format(COLLECT_WAS_SENT, sendCollectResult.First().Value));
                        }
                        else
                        {
                            view.ShowMessage(WAS_NOT_POSSIBLE_TO_GET_OVAL_DEFINITIONS);
                        }

                        break;
                    }

                case Operation.SendCollectSync:
                    {
                        var ovalDefinitions = GetFileContents("Oval Definitions", this.definitionsFilename);
                        var ovalVariables = GetOvalExternalVariablesFile();
                        Dictionary<string, string> targetParameters = null;
                        if (!String.IsNullOrEmpty(options.SSHPort))
                        {
                            targetParameters = new Dictionary<string, string>();
                            targetParameters.Add("sshPort", options.SSHPort);
                        }

                        if (ovalDefinitions != null)
                        {
                            string collectRequestID;

                            view.ShowMessage("Requesting collect...");
                            var credentials = this.CreateCredentials();
                            var ovalResults = modSICService.SendCollectSynchronous(target.Address, credentials, ovalDefinitions, out collectRequestID, 10, ovalVariables, targetParameters);

                            SaveResults(ovalResults, collectRequestID);
                            view.ShowMessage("[Operation completed]");
                        }
                        else
                        {
                            view.ShowMessage(WAS_NOT_POSSIBLE_TO_GET_OVAL_DEFINITIONS);
                        }

                        break;
                    }

                case Operation.GetResults:
                    {
                        var collectRequestID = this.options.RequestId;
                        view.ShowMessage(String.Format("Trying to get Oval Results for '{0}'...", collectRequestID));
                        var ovalResults = modSICService.GetOvalResults(collectRequestID);
                        SaveResults(ovalResults, collectRequestID);
                        view.ShowMessage("[Operation completed]");

                        break;
                    }

                case Operation.CancelCollect:
                    {
                        var collectRequestID = this.options.CancelRequestId;
                        view.ShowMessage(String.Format("Trying to cancel '{0}'...", collectRequestID));
                        if (modSICService.CancelCollect(collectRequestID))
                        {
                            view.ShowMessage(CollectCanceledMessage);
                        }
                        else
                        {
                            view.ShowMessage("The collect request was not canceled by modSIC because weather it is no longer in execution or the collect request does not exist.");
                        }

                        break;
                    }

                case Operation.ListCollectsInExecution:
                case Operation.ListAllCollectsInExecution:
                    {
                        view.ShowMessage("Trying to get collections in execution...");
                        var collectsInExecutions = (operation == Operation.ListCollectsInExecution) ?
                            modSICService.GetCollectionsInExecution(options.VerboseOutput) :
                            modSICService.GetAllCollectionsInExecution(options.VerboseOutput);

                        view.ShowMessage(String.Format("modSIC server version is {0}, providing API {1}",
                                                        modSICService.ServerProgramVersion,
                                                        modSICService.ServerAPIVersion));

                        if ((collectsInExecutions != null) && (collectsInExecutions.Count() > 0))
                            view.ShowMessages(collectsInExecutions.Select(col => col.Key + " on " + col.Value).ToArray());
                        else
                            view.ShowMessage(NoCollectionIsBeingPerformedMessage);

                        break;
                    }
            }
        }
Exemplo n.º 4
0
        private void Execute(Operation operation)
        {
            modSICService = new ModSicService(this.server);
            switch (operation)
            {
            case Operation.ValidateSchematronOnly:
                if (!ValidateSchema())
                {
                    return;
                }
                if (options.ValidateSchematron)
                {
                    if (!ValidadeSchematron())
                    {
                        return;
                    }
                }
                break;

            case Operation.SendCollect:
            {
                var ovalDefinitions = GetFileContents("Oval Definitions", this.definitionsFilename);
                var ovalVariables   = GetOvalExternalVariablesFile();
                Dictionary <string, string> targetParameters = null;
                if (!String.IsNullOrEmpty(options.SSHPort))
                {
                    targetParameters = new Dictionary <string, string>();
                    targetParameters.Add("sshPort", options.SSHPort);
                }

                if (ovalDefinitions != null)
                {
                    view.ShowMessage("Requesting collect...");
                    var sendCollectResult = modSICService.SendCollect(target.Address, CreateCredentials(), ovalDefinitions, ovalVariables, targetParameters);

                    view.ShowMessage(String.Format(COLLECT_WAS_SENT, sendCollectResult.First().Value));
                }
                else
                {
                    view.ShowMessage(WAS_NOT_POSSIBLE_TO_GET_OVAL_DEFINITIONS);
                }

                break;
            }

            case Operation.SendCollectSync:
            {
                var ovalDefinitions = GetFileContents("Oval Definitions", this.definitionsFilename);
                var ovalVariables   = GetOvalExternalVariablesFile();
                Dictionary <string, string> targetParameters = null;
                if (!String.IsNullOrEmpty(options.SSHPort))
                {
                    targetParameters = new Dictionary <string, string>();
                    targetParameters.Add("sshPort", options.SSHPort);
                }

                if (ovalDefinitions != null)
                {
                    string collectRequestID;

                    view.ShowMessage("Requesting collect...");
                    var credentials = this.CreateCredentials();
                    var ovalResults = modSICService.SendCollectSynchronous(target.Address, credentials, ovalDefinitions, out collectRequestID, 10, ovalVariables, targetParameters);

                    SaveResults(ovalResults, collectRequestID);
                    view.ShowMessage("[Operation completed]");
                }
                else
                {
                    view.ShowMessage(WAS_NOT_POSSIBLE_TO_GET_OVAL_DEFINITIONS);
                }

                break;
            }

            case Operation.GetResults:
            {
                var collectRequestID = this.options.RequestId;
                view.ShowMessage(String.Format("Trying to get Oval Results for '{0}'...", collectRequestID));
                var ovalResults = modSICService.GetOvalResults(collectRequestID);
                SaveResults(ovalResults, collectRequestID);
                view.ShowMessage("[Operation completed]");

                break;
            }

            case Operation.CancelCollect:
            {
                var collectRequestID = this.options.CancelRequestId;
                view.ShowMessage(String.Format("Trying to cancel '{0}'...", collectRequestID));
                if (modSICService.CancelCollect(collectRequestID))
                {
                    view.ShowMessage(CollectCanceledMessage);
                }
                else
                {
                    view.ShowMessage("The collect request was not canceled by modSIC because weather it is no longer in execution or the collect request does not exist.");
                }

                break;
            }

            case Operation.ListCollectsInExecution:
            case Operation.ListAllCollectsInExecution:
            {
                view.ShowMessage("Trying to get collections in execution...");
                var collectsInExecutions = (operation == Operation.ListCollectsInExecution) ?
                                           modSICService.GetCollectionsInExecution(options.VerboseOutput) :
                                           modSICService.GetAllCollectionsInExecution(options.VerboseOutput);

                view.ShowMessage(String.Format("modSIC server version is {0}, providing API {1}",
                                               modSICService.ServerProgramVersion,
                                               modSICService.ServerAPIVersion));

                if ((collectsInExecutions != null) && (collectsInExecutions.Count() > 0))
                {
                    view.ShowMessages(collectsInExecutions.Select(col => col.Key + " on " + col.Value).ToArray());
                }
                else
                {
                    view.ShowMessage(NoCollectionIsBeingPerformedMessage);
                }

                break;
            }
            }
        }