1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- //
- // CDSignatureCertificateStateViewController.swift
- // PDF Reader Pro Edition
- //
- // Created by Niehaoyu on 2023/10/20.
- //
- import Cocoa
- class CDSignatureCertificateStateViewController: NSViewController {
- @IBOutlet weak var titleLabel: NSTextField!
- @IBOutlet weak var imageView: NSImageView!
- @IBOutlet weak var subTitleLabel: NSTextField!
- @IBOutlet weak var subDes1Label: NSTextField!
- @IBOutlet weak var subDes2Label: NSTextField!
- @IBOutlet weak var propertiesBtn: NSButton!
- @IBOutlet weak var closeBtn: NSButton!
-
- var signature: CPDFSignature!
- var pdfListView: CPDFDigtalView!
-
- var actionBlock: ((_ stateVC: CDSignatureCertificateStateViewController, _ actionType: DSignatureActionType)->Void)?
-
- override func viewDidAppear() {
- super.viewDidAppear()
-
- self.reloadData()
- }
-
- override func viewDidLoad() {
- super.viewDidLoad()
- // Do view setup here.
-
- self.titleLabel.stringValue = NSLocalizedString("Signature Validation Status", comment: "")
-
- self.reloadData()
- }
-
- func reloadData () {
- let signer = self.signature.signers.first
- let isSignVerified = signer?.isSignVerified
- let isCertTrusted = signer?.isCertTrusted
- if isSignVerified == true && isCertTrusted == true {
- self.imageView.image = NSImage(named: "ImageNameSigntureLargeVerifySuccess")
-
- let cer = signer?.certificates.first
- let CNStr = cer?.subjectDict["CN"] as! String
- self.subTitleLabel.stringValue = String(format: NSLocalizedString("Signature is VALID, signed by %@.", comment: ""), CNStr)
- self.subDes1Label.stringValue = String(format: "- %@",NSLocalizedString("The document has not been modified since this signature was applied.", comment: ""))
- self.subDes2Label.stringValue = String(format: "- %@",NSLocalizedString("The signer's identity is valid.", comment: ""))
-
- } else if isSignVerified == true && isCertTrusted == false {
- self.imageView.image = NSImage(named: "ImageNameSigntureLargeTrustedFailure")
-
- self.subTitleLabel.stringValue = NSLocalizedString("Signature is invalid", comment: "")
- self.subDes1Label.stringValue = String(format: "- %@",NSLocalizedString("The document has not been modified since this signature was applied.", comment: ""))
- self.subDes2Label.stringValue = String(format: "- %@",NSLocalizedString("The signer's identity is unknown because it has not been included in your list of trusted certificates and none of its parent certificates are trusted certificates.", comment: ""))
-
- } else if isSignVerified == false && isCertTrusted == false {
- self.imageView.image = NSImage(named: "ImageNameSigntureLargeVerifyFailure")
-
- self.subTitleLabel.stringValue = NSLocalizedString("Signature is invalid", comment: "")
- self.subDes1Label.stringValue = String(format: "- %@",NSLocalizedString("The document has not been modified since this signature was applied.", comment: ""))
- self.subDes2Label.stringValue = String(format: "- %@",NSLocalizedString("The signer's identity is invalid.", comment: ""))
- } else {
- self.imageView.image = NSImage(named: "ImageNameSigntureLargeVerifyFailure")
-
- self.subTitleLabel.stringValue = NSLocalizedString("Signature is invalid", comment: "")
- self.subDes1Label.stringValue = String(format: "- %@",NSLocalizedString("The revision of the document that was covered by this signature has not been altered; however, there have been subsequent changes to the document.", comment: ""))
- self.subDes2Label.stringValue = String(format: "- %@",NSLocalizedString("Click Signature Properties, then it will show what is covered by this signature.", comment: ""))
- }
-
- self.propertiesBtn.title = NSLocalizedString("Signature Properties...", comment: "")
- self.closeBtn.title = NSLocalizedString("Close", comment: "")
-
- self.subTitleLabel.textColor = NSColor.labelColor
- self.titleLabel.textColor = NSColor.labelColor
- self.subDes1Label.textColor = NSColor.labelColor
- self.subDes2Label.textColor = NSColor.labelColor
- }
-
- //MARK: IBAction
- @IBAction func buttonItemClick_Properties(_ sender: NSButton) {
- guard let callBack = self.actionBlock else {
- return
- }
- callBack(self, .confirm)
- }
-
- @IBAction func buttonItemClick_Close(_ sender: Any) {
- guard let callBack = self.actionBlock else {
- return
- }
- callBack(self, .cancel)
- }
-
- }
|