Browse Source

安全 - 部分bug

liuaoran 1 year ago
parent
commit
bd80c35fe3

+ 2 - 11
PDF Office/ViewModels/Dialog/ToolsDialogs/SaftyDialogs/CheckPasswordDialogViewModel.cs

@@ -120,21 +120,12 @@ namespace PDF_Office.ViewModels.Dialog.ToolsDialogs.SaftyDialogs
             }
             else
             {
-                if (tempDocument.UnlockWithPassword(Password))
-                {
-                    if (SecurityHelper.CheckHaveAllPermissions(tempDocument))
-                    {
+                if (tempDocument.CheckOwnerPassword(Password))
+                {  
                         var dialogResult = new DialogResult(ButtonResult.OK);
                         dialogResult.Parameters.Add(ParameterNames.Password, Password);
                         dialogResult.Parameters.Add(ParameterNames.PasswordResult, true);
                         RequestClose.Invoke(dialogResult);
-                    }
-                    else
-                    {
-                        IsRightValue = "false";
-                        tempDocument.Release();
-                        tempDocument = CPDFDocument.InitWithFilePath(document.FilePath);
-                    }
                 }
                 else
                 {

+ 1 - 5
PDF Office/ViewModels/TipContent/FileRestrictedTipViewModel.cs

@@ -42,15 +42,11 @@ namespace PDF_Office.ViewModels.TipContent
                 if (result.Password != null)
                 {
                     string filePath = PDFViewer.Document.FilePath;
-                    PDFViewer.CloseDocument();
-                    PDFViewer.InitDocument(filePath);
-                    PDFViewer.Document.UnlockWithPassword(result.Password);
-                    PDFViewer.Load();
+                    PDFViewer.Document.CheckOwnerPassword(result.Password);
                 }
                 ///TODO:
                 ///此处填入需要执行的代码
             this.eventAggregator.GetEvent<ShowTipEvent>().Publish(new ShowTipEventArgs() { enumTipKind = EnumTipKind.StatusNone, Unicode = unicode });
-
             }
         }
 

+ 10 - 11
PDF Office/ViewModels/Tools/ToolsBarContentViewModel.cs

@@ -203,16 +203,18 @@ namespace PDF_Office.ViewModels.Tools
         private void OpenSetPasswordDialog()
         { 
             VerifyPasswordResult result = SecurityHelper.VerifyPasswordByPasswordKind(PDFViewer.Document, EnumPasswordKind.StatusPermissionsPassword, dialogs);
-
             if (result.IsDiscryptied)
             { 
-                if ((result.Password != null || !viewContentViewModel.SecurityInfo.IsPasswordChanged)&&!string.IsNullOrEmpty(PDFViewer.Document.FilePath))
+                if (result.Password != null&&!string.IsNullOrEmpty(PDFViewer.Document.FilePath))
                 {
-                    string filePath = PDFViewer.Document.FilePath;
-                    PDFViewer.CloseDocument();
-                    PDFViewer.InitDocument(filePath);
-                    PDFViewer.Load();
-                    PDFViewer.Document.UnlockWithPassword(result.Password);
+                    //string filePath = PDFViewer.Document.FilePath;
+                    //PDFViewer.CloseDocument();
+                    //PDFViewer.InitDocument(filePath);
+                    //if (PDFViewer.Document != null)
+                    //{
+                    //    PDFViewer.Load();
+                    //}
+                    PDFViewer.Document.CheckOwnerPassword(result.Password);
                 }
 
                 DialogParameters value = new DialogParameters();
@@ -250,10 +252,7 @@ namespace PDF_Office.ViewModels.Tools
                 {
                     if (result.Password != null)
                     {
-                        string filePath = PDFViewer.Document.FilePath;
-                        PDFViewer.Document.Release();
-                        PDFViewer.InitDocument(filePath);
-                        PDFViewer.Document.UnlockWithPassword(result.Password);
+                        PDFViewer.Document.CheckOwnerPassword(result.Password);
                     }
                     DialogParameters value = new DialogParameters();
                     value.Add(ParameterNames.PDFDocument, PDFViewer.Document);