Exemple #1
0
        public PackageSigningViewModel(
            ISelfElevationProxyProvider <ISigningManager> signingManagerFactory,
            IInteractionService interactionService,
            IConfigurationService configurationService,
            ITimeStampFeed timeStampFeed) : base("Package signing", interactionService)
        {
            this.signingManagerFactory = signingManagerFactory;
            this.interactionService    = interactionService;
            this.configurationService  = configurationService;

            this.Files               = new ValidatedChangeableCollection <string>(this.ValidateFiles);
            this.IncreaseVersion     = new ChangeableProperty <IncreaseVersionMethod>();
            this.CertificateSelector = new CertificateSelectorViewModel(
                interactionService,
                signingManagerFactory,
                configurationService?.GetCurrentConfiguration()?.Signing,
                timeStampFeed);
            this.OverrideSubject = new ChangeableProperty <bool>(true);

            this.TabPackages    = new ChangeableContainer(this.Files);
            this.TabAdjustments = new ChangeableContainer(this.IncreaseVersion);
            this.TabCertificate = new ChangeableContainer(this.CertificateSelector);

            this.AddChildren(this.TabPackages, this.TabCertificate, this.TabAdjustments, this.OverrideSubject);
            this.Files.CollectionChanged += (_, _) =>
            {
                this.OnPropertyChanged(nameof(IsOnePackage));
            };

            this.RegisterForCommandLineGeneration(
                this.TabCertificate,
                this.TabPackages,
                this.TabAdjustments,
                this.OverrideSubject);
        }
        public PackViewModel(
            ISelfElevationProxyProvider <ISigningManager> signingManagerFactory,
            IAppxManifestCreator manifestCreator,
            IConfigurationService configurationService,
            IInteractionService interactionService,
            ITimeStampFeed timeStampFeed) : base("Pack MSIX package", interactionService)
        {
            this.signingManagerFactory = signingManagerFactory;
            this.manifestCreator       = manifestCreator;
            var signConfig    = configurationService.GetCurrentConfiguration().Signing ?? new SigningConfiguration();
            var signByDefault = configurationService.GetCurrentConfiguration().Packer?.SignByDefault == true;

            this.InputPath = new ChangeableFolderProperty("Source directory", interactionService, ChangeableFolderProperty.ValidatePath);

            this.OutputPath = new ChangeableFileProperty("Target package path", interactionService, ChangeableFileProperty.ValidatePath)
            {
                OpenForSaving = true,
                Filter        = new DialogFilterBuilder("*" + FileConstants.MsixExtension, "*" + FileConstants.AppxExtension).BuildFilter()
            };

            this.Sign            = new ChangeableProperty <bool>(signByDefault);
            this.Compress        = new ChangeableProperty <bool>(true);
            this.Validate        = new ChangeableProperty <bool>(true);
            this.RemoveDirectory = new ChangeableProperty <bool>();
            this.OverrideSubject = new ChangeableProperty <bool>(true);

            this.SelectedCertificate = new CertificateSelectorViewModel(interactionService, signingManagerFactory, signConfig, timeStampFeed)
            {
                IsValidated = false
            };

            this.InputPath.ValueChanged += this.InputPathOnValueChanged;
            this.Sign.ValueChanged      += this.SignOnValueChanged;

            this.TabSource  = new ChangeableContainer(this.InputPath, this.OutputPath, this.Sign, this.Compress, this.Validate, this.RemoveDirectory);
            this.TabSigning = new ChangeableContainer(this.SelectedCertificate, this.OverrideSubject);

            this.AddChildren(this.TabSource, this.TabSigning);
        }
        public ModificationPackageViewModel(
            IModificationPackageBuilder contentBuilder,
            ISelfElevationProxyProvider <ISigningManager> signingManagerFactory,
            IConfigurationService configurationService,
            IInteractionService interactionService,
            ITimeStampFeed timeStampFeed) : base("Create modification package", interactionService)
        {
            this.contentBuilder        = contentBuilder;
            this.signingManagerFactory = signingManagerFactory;
            this.configurationService  = configurationService;
            this.interactionService    = interactionService;
            this.timeStampFeed         = timeStampFeed;

            this.InitializeTabProperties();
            this.InitializeTabParentPackage();
            this.InitializeTabContent();
            this.InitializeTabCertificate();

            this.AddChildren(
                this.TabProperties,
                this.TabParentPackage,
                this.TabContent,
                this.TabCertificate);
        }
 public SigningManager(ITimeStampFeed timeStampFeed)
 {
     this.timeStampFeed = timeStampFeed;
 }
Exemple #5
0
        public CertificateSelectorViewModel(
            IInteractionService interactionService,
            ISelfElevationProxyProvider <ISigningManager> signingManagerFactory,
            SigningConfiguration configuration,
            ITimeStampFeed timeStampFeed,
            bool allowNoSelection = false)
        {
            this.allowNoSelection      = allowNoSelection;
            this.interactionService    = interactionService;
            this.signingManagerFactory = signingManagerFactory;
            this.timeStampFeed         = timeStampFeed;
            var signConfig = configuration ?? new SigningConfiguration();


            if (string.IsNullOrEmpty(signConfig.TimeStampServer))
            {
                this.TimeStampSelectionMode = new ChangeableProperty <TimeStampSelectionMode>();
            }
            else if (string.Equals("auto", signConfig.TimeStampServer, StringComparison.OrdinalIgnoreCase))
            {
                this.TimeStampSelectionMode = new ChangeableProperty <TimeStampSelectionMode>(ViewModel.TimeStampSelectionMode.Auto);
            }
            else
            {
                this.TimeStampSelectionMode = new ChangeableProperty <TimeStampSelectionMode>(ViewModel.TimeStampSelectionMode.Url);
            }

            this.TimeStamp = new ValidatedChangeableProperty <string>(
                "Time stamp URL",
                signConfig.TimeStampServer == "auto" ? null : signConfig.TimeStampServer,
                this.ValidateTimestamp);

            this.TimeStampSelectionMode.Changed += (_, _) =>
            {
                this.TimeStamp.Validate();
            };

            var newStore = signConfig.Source;

            if (newStore == CertificateSource.Unknown && !allowNoSelection)
            {
                newStore = CertificateSource.Personal;
            }

            this.Store = new ChangeableProperty <CertificateSource>(newStore);
            this.Store.ValueChanged += this.StoreOnValueChanged;
            this.PfxPath             = new ChangeableFileProperty("Path to PFX file", interactionService, signConfig.PfxPath?.Resolved, this.ValidatePfxPath)
            {
                Filter = new DialogFilterBuilder("*.pfx").BuildFilter()
            };

            SecureString initialSecurePassword = null;

            if (this.Store.CurrentValue == CertificateSource.Pfx)
            {
                var initialPassword = signConfig.EncodedPassword;

                if (!string.IsNullOrEmpty(initialPassword))
                {
                    var crypto = new Crypto();
                    try
                    {
                        initialSecurePassword = crypto.Unprotect(initialPassword);
                    }
                    catch (Exception)
                    {
                        Logger.Warn("The encrypted password from settings could not be decrypted.");
                    }
                }
            }

            this.Password = new ChangeableProperty <SecureString>(initialSecurePassword);

            if (configuration?.DeviceGuard?.EncodedAccessToken != null)
            {
                this.DeviceGuard = new ValidatedChangeableProperty <DeviceGuardConfiguration>("Device Guard", configuration.DeviceGuard, false, this.ValidateDeviceGuard);
            }
            else
            {
                this.DeviceGuard = new ValidatedChangeableProperty <DeviceGuardConfiguration>("Device Guard", null, false, this.ValidateDeviceGuard);
            }

            this.SelectedPersonalCertificate = new ValidatedChangeableProperty <CertificateViewModel>("Selected certificate", false, this.ValidateSelectedCertificate);
            this.PersonalCertificates        = new AsyncProperty <ObservableCollection <CertificateViewModel> >(this.LoadPersonalCertificates(signConfig.Thumbprint, !signConfig.ShowAllCertificates));
            this.ShowAllCertificates         = new ChangeableProperty <bool>(signConfig.ShowAllCertificates);
            this.AddChildren(this.SelectedPersonalCertificate, this.PfxPath, this.TimeStamp, this.TimeStampSelectionMode, this.Password, this.DeviceGuard, this.Store, this.ShowAllCertificates);

            this.ShowAllCertificates.ValueChanged += async(_, args) =>
            {
                await this.PersonalCertificates.Load(this.LoadPersonalCertificates(this.SelectedPersonalCertificate.CurrentValue?.Model.Thumbprint, !(bool)args.NewValue)).ConfigureAwait(false);

                this.OnPropertyChanged(nameof(this.SelectedPersonalCertificate));
            };
        }
Exemple #6
0
        public SettingsViewModel(
            IEventAggregator eventAggregator,
            IConfigurationService configurationService,
            IInteractionService interactionService,
            ISelfElevationProxyProvider <ISigningManager> signingManagerFactory,
            ITimeStampFeed timeStampFeed)
        {
            this.eventAggregator      = eventAggregator;
            this.configurationService = configurationService;

            var config = configurationService.GetCurrentConfiguration() ?? new Configuration();

            this.TabOther.AddChildren
            (
                this.CertificateOutputPath             = new ChangeableFolderProperty("Certificate output path", interactionService, config.Signing?.DefaultOutFolder?.Resolved),
                this.PackerSignByDefault               = new ChangeableProperty <bool>(config.Packer?.SignByDefault == true),
                this.DefaultRemoteLocationPackages     = new ValidatedChangeableProperty <string>("Remote .msix URL", config.AppInstaller?.DefaultRemoteLocationPackages, this.ValidateUri),
                this.DefaultRemoteLocationAppInstaller = new ValidatedChangeableProperty <string>("Remote .appinstaller URL", config.AppInstaller?.DefaultRemoteLocationAppInstaller, this.ValidateUri)
            );

            this.TabEditors.AddChildren
            (
                this.ManifestEditorType     = new ChangeableProperty <EditorType>(config.Editing.ManifestEditorType),
                this.ManifestEditorPath     = new ChangeableFileProperty("Manifest editor path", interactionService, config.Editing.ManifestEditor.Resolved, this.ValidateManifestEditorPath),
                this.MsixEditorType         = new ChangeableProperty <EditorType>(config.Editing.MsixEditorType),
                this.MsixEditorPath         = new ChangeableFileProperty("MSIX editor path", interactionService, config.Editing.MsixEditor.Resolved, this.ValidateMsixEditorPath),
                this.AppinstallerEditorType = new ChangeableProperty <EditorType>(config.Editing.AppInstallerEditorType),
                this.AppinstallerEditorPath = new ChangeableFileProperty("App installer editor path", interactionService, config.Editing.AppInstallerEditor.Resolved, this.ValidateAppInstallerEditorPath),
                this.PsfEditorType          = new ChangeableProperty <EditorType>(config.Editing.PsfEditorType),
                this.PsfEditorPath          = new ChangeableFileProperty("PSF editor path", interactionService, config.Editing.PsfEditor.Resolved, this.ValidatePsfEditorPath),
                this.PowerShellEditorType   = new ChangeableProperty <EditorType>(config.Editing.PowerShellEditorType),
                this.PowerShellEditorPath   = new ChangeableFileProperty("PowerShell editor path", interactionService, config.Editing.PowerShellEditor.Resolved, this.ValidatePowerShellEditorPath)
            );

            this.TabSigning.AddChildren
            (
                this.CertificateSelector = new CertificateSelectorViewModel(
                    interactionService,
                    signingManagerFactory,
                    config.Signing,
                    timeStampFeed,
                    true)
            );

            var uiLevel = (int)(config.UiConfiguration?.UxTier ?? UxTierLevel.Auto);

            if (uiLevel < -1 || uiLevel > 2)
            {
                uiLevel = -1;
            }

            this.AllSettings.AddChildren(
                this.TabSigning,
                this.ConfirmDeletion  = new ChangeableProperty <bool>(config.UiConfiguration?.ConfirmDeletion != false),
                this.DefaultScreen    = new ChangeableProperty <DefaultScreen>(config.UiConfiguration == null ? Infrastructure.Configuration.DefaultScreen.Packages : config.UiConfiguration.DefaultScreen),
                this.ShowReleaseNotes = new ChangeableProperty <bool>(config.Update?.HideNewVersionInfo != true),
                this.UxLevel          = new ChangeableProperty <int>(uiLevel),
                this.VerboseLogging   = new ChangeableProperty <bool>(config.VerboseLogging),
                this.TabEditors,
                this.Tools = new ToolsConfigurationViewModel(interactionService, config),
                this.TabOther
                );

            this.CertificateOutputPath.Validators = new[] { ChangeableFolderProperty.ValidatePath };

            this.AppinstallerEditorType.ValueChanged += this.TypeOfPathChanged;
            this.ManifestEditorType.ValueChanged     += this.TypeOfPathChanged;
            this.PsfEditorType.ValueChanged          += this.TypeOfPathChanged;
            this.MsixEditorType.ValueChanged         += this.TypeOfPathChanged;
            this.PowerShellEditorType.ValueChanged   += this.TypeOfPathChanged;
        }
 public CachedTimeStampFeed(ITimeStampFeed decoratedFeed) : this(decoratedFeed, TimeSpan.FromHours(24))
 {
 }
 public CachedTimeStampFeed(ITimeStampFeed decoratedFeed, TimeSpan invalidateAfter)
 {
     this.decoratedFeed   = decoratedFeed;
     this.invalidateAfter = invalidateAfter;
 }