/// <summary> /// Signs a number of <see cref="Feed"/>s with a single <see cref="OpenPgpSecretKey"/>. /// </summary> /// <param name="secretKey">The private key to use for signing the files.</param> /// <param name="passphrase">The passphrase to use to unlock the key.</param> /// <exception cref="IOException">The feed file could not be read or written.</exception> /// <exception cref="UnauthorizedAccessException">Read or write access to the feed file is not permitted.</exception> private void SignFiles(OpenPgpSecretKey?secretKey, string passphrase) { var task = ForEachTask.Create(Resources.SigningFeeds, _files, file => { SignedFeed signedFeed; try { signedFeed = SignedFeed.Load(file.FullName); } #region Error handling catch (Exception ex) when(ex is UnauthorizedAccessException or InvalidDataException) { // Wrap exception since only certain exception types are allowed throw new IOException(ex.Message, ex); } #endregion signedFeed.SecretKey = secretKey; try { signedFeed.Save(file.FullName, passphrase); } #region Error handling catch (Exception ex) when(ex is UnauthorizedAccessException or KeyNotFoundException or WrongPassphraseException) { // Wrap exception since only certain exception types are allowed throw new IOException(ex.Message, ex); } #endregion });
/// <summary> /// Saves feed to an XML file, adds the default stylesheet and signs it with <see cref="Publish.SignedFeed.SecretKey"/> (if specified). /// </summary> /// <remarks>Writing and signing the feed file are performed as an atomic operation (i.e. if signing fails an existing file remains unchanged).</remarks> /// <param name="path">The file to save to.</param> /// <exception cref="IOException">A problem occurred while writing the file.</exception> /// <exception cref="UnauthorizedAccessException">Write access to the file is not permitted.</exception> /// <exception cref="KeyNotFoundException">The specified <see cref="Publish.SignedFeed.SecretKey"/> could not be found on the system.</exception> /// <exception cref="WrongPassphraseException"><see cref="Passphrase"/> was incorrect.</exception> public override void Save(string path) { SignedFeed.Save(path, Passphrase); Path = path; ClearUndo(); }
(string.IsNullOrEmpty(Path) && Target?.Elements.Count != 0); // Generated programmatically /// <summary> /// Starts with an existing feed. /// </summary> /// <param name="signedFeed">The feed to be edited.</param> public FeedEditing(SignedFeed signedFeed) : base(signedFeed.Feed) { SignedFeed = signedFeed ?? throw new ArgumentNullException(nameof(signedFeed)); // Keep Target and SignedFeed in sync even if Target is replaced with a new object TargetUpdated += () => SignedFeed = new SignedFeed(Target !, SignedFeed.SecretKey); }
private NewFeedWizard(IOpenPgp openPgp) { InitializeComponent(); // Pages var downloadPage = new DownloadPage(_feedBuilder, _installerCapture); var archiveExtractPage = new ArchiveExtractPage(_feedBuilder); var entryPointPage = new EntryPointPage(_feedBuilder); var installerCaptureStartPage = new InstallerCaptureStartPage(_installerCapture, _feedBuilder); var installerCaptureDiffPage = new InstallerCaptureDiffPage(_installerCapture, _feedBuilder); var installerCollectFilesPage = new InstallerCollectFilesPage(_installerCapture); var installerAltDownloadPage = new DownloadPage(_feedBuilder, _installerCapture); var installerExtractPage = new ArchiveExtractPage(_feedBuilder, _installerCapture); var installerEntryPointPage = new EntryPointPage(_feedBuilder); var detailsPage = new DetailsPage(_feedBuilder); var iconPage = new IconPage(_feedBuilder); var securityPage = new SecurityPage(_feedBuilder, openPgp); var donePage = new DonePage(); // Flows downloadPage.AsArchive += () => PushPage(archiveExtractPage); downloadPage.AsSingleFile += () => { _feedBuilder.GenerateCommands(); PushPage(detailsPage); }; downloadPage.AsInstaller += () => PushPage(installerCaptureStartPage); archiveExtractPage.Next += () => PushPage(entryPointPage); entryPointPage.Next += () => { _feedBuilder.GenerateCommands(); PushPage(detailsPage); }; installerCaptureStartPage.Next += () => PushPage(installerCaptureDiffPage); installerCaptureStartPage.Skip += () => PushPage(archiveExtractPage); installerCaptureDiffPage.AsArchive += () => PushPage(installerExtractPage); installerCaptureDiffPage.AltSource += () => PushPage(installerCollectFilesPage); installerCollectFilesPage.Next += () => PushPage(installerEntryPointPage); installerCollectFilesPage.ExistingArchive += () => PushPage(installerAltDownloadPage); installerAltDownloadPage.AsArchive += () => PushPage(installerExtractPage); installerExtractPage.Next += () => PushPage(installerEntryPointPage); installerEntryPointPage.Next += () => { _installerCapture.CaptureSession.Finish(); PushPage(detailsPage); }; detailsPage.Next += () => PushPage(iconPage); iconPage.Next += () => PushPage(securityPage); securityPage.Next += () => PushPage(donePage); donePage.Finish += () => { _signedFeed = _feedBuilder.Build(); Close(); }; // Start PushPage(downloadPage); }
/// <summary> /// Signs a number of <see cref="Feed"/>s with a single <see cref="OpenPgpSecretKey"/>. /// </summary> /// <param name="secretKey">The private key to use for signing the files.</param> /// <param name="passphrase">The passphrase to use to unlock the key.</param> /// <exception cref="IOException">The feed file could not be read or written.</exception> /// <exception cref="UnauthorizedAccessException">Read or write access to the feed file is not permitted.</exception> private void SignFiles(OpenPgpSecretKey secretKey, string passphrase) { var task = ForEachTask.Create("Signing feeds", _files, file => { SignedFeed signedFeed; try { signedFeed = SignedFeed.Load(file.FullName); } #region Error handling catch (UnauthorizedAccessException ex) { // Wrap exception since only certain exception types are allowed throw new IOException(ex.Message, ex); } catch (InvalidDataException ex) { // Wrap exception since only certain exception types are allowed throw new IOException(ex.Message + (ex.InnerException == null ? "" : Environment.NewLine + ex.InnerException.Message), ex); } #endregion signedFeed.SecretKey = secretKey; try { signedFeed.Save(file.FullName, passphrase); } #region Error handling catch (UnauthorizedAccessException ex) { // Wrap exception since only certain exception types are allowed throw new IOException(ex.Message, ex); } catch (KeyNotFoundException ex) { // Wrap exception since only certain exception types are allowed throw new IOException(ex.Message, ex); } catch (WrongPassphraseException ex) { // Wrap exception since only certain exception types are allowed throw new IOException(ex.Message, ex); } #endregion }); using (var handler = new DialogTaskHandler(this)) handler.RunTask(task); Msg.Inform(this, "Successfully signed files.", MsgSeverity.Info); }
private void donePage_Commit(object sender, WizardPageConfirmEventArgs e) { _signedFeed = _feedBuilder.Build(); }
private void donePage_Commit(object sender, WizardPageConfirmEventArgs e) { _signedFeed = _feedBuilder.Build(); }