public static ISetupFlow Create(ILoggerFactory loggerFactory, SetupFlowType setupFlowType)
        {
            ISetupFlow result = null;

            switch (setupFlowType)
            {
            default:
            case SetupFlowType.RegisterWithVC:
                result = new RegisterWithVCSetupFlow(loggerFactory);
                break;

            case SetupFlowType.UnregisterFromVC:
                result = new UnregisterFromVCSetupFlow(loggerFactory);
                break;

            case SetupFlowType.UpdateTlsCertificate:
                result = new UpdateTlsCertificateSetupFlow(loggerFactory);
                break;

            case SetupFlowType.UpdateTrustedCACertificates:
                result = new UpdateTrustedCACertificatesSetupFlow(loggerFactory);
                break;

            case SetupFlowType.CleanupVCRegistration:
                result = new CleanupVCRegistrationSetupFlow(loggerFactory);
                break;
            }
            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Verifies user input settings are valid for the specified Setup Flow Type.
        /// If user input is not valid exception with invalid properties is thrown
        /// </summary>
        /// <param name="setupFlowType"></param>
        public void EnsureIsValid(SetupFlowType setupFlowType)
        {
            if (string.IsNullOrEmpty(Psc))
            {
                throw new InvalidUserInputException("VC IP/FQDN is not specified");
            }
            if (string.IsNullOrEmpty(User))
            {
                throw new InvalidUserInputException("VC Username is not specified");
            }
            if (Password == null)
            {
                throw new InvalidUserInputException("VC Password is not specified");
            }

            if (setupFlowType == SetupFlowType.UnregisterFromVC ||
                setupFlowType == SetupFlowType.UpdateTlsCertificate)
            {
                if (string.IsNullOrEmpty(StsSettingsPath))
                {
                    throw new InvalidUserInputException("StsSettings file path is not specified");
                }

                if (!File.Exists(StsSettingsPath))
                {
                    throw new InvalidUserInputException($"StsSettings file not found '{StsSettingsPath}'");
                }
            }

            if (setupFlowType == SetupFlowType.UpdateTlsCertificate)
            {
                if (string.IsNullOrEmpty(TlsCertificatePath))
                {
                    throw new InvalidUserInputException("TlsCertificatePath file path is not specified");
                }

                if (!File.Exists(TlsCertificatePath))
                {
                    throw new InvalidUserInputException($"StsSettings file not found '{TlsCertificatePath}'");
                }
            }
        }