|
@@ -495,7 +495,7 @@ class DSignatureDetailsViewController: NSViewController, NSTableViewDelegate, NS
|
|
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
|
|
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
|
|
|
|
|
|
if self.detailsTableView.isEqual(tableView) {
|
|
if self.detailsTableView.isEqual(tableView) {
|
|
- let dic = self.certDatas.object(at: row) as! NSDictionary
|
|
|
|
|
|
+ let dic = self.certDatas.object(at: row) as? NSDictionary ?? [:]
|
|
let cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(tableColumn?.identifier.rawValue ?? ""), owner: self) as! NSTableCellView
|
|
let cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(tableColumn?.identifier.rawValue ?? ""), owner: self) as! NSTableCellView
|
|
if ((tableColumn?.identifier.rawValue) == "name") {
|
|
if ((tableColumn?.identifier.rawValue) == "name") {
|
|
cell.textField?.stringValue = dic.allKeys.first as! String
|
|
cell.textField?.stringValue = dic.allKeys.first as! String
|
|
@@ -522,7 +522,11 @@ class DSignatureDetailsViewController: NSViewController, NSTableViewDelegate, NS
|
|
func tableViewSelectionDidChange(_ notification: Notification) {
|
|
func tableViewSelectionDidChange(_ notification: Notification) {
|
|
let tableView = notification.object
|
|
let tableView = notification.object
|
|
if self.detailsTableView.isEqual(tableView) {
|
|
if self.detailsTableView.isEqual(tableView) {
|
|
- let model = self.models.object(at: self.tableView.selectedRow) as! CDSPDFSigntureModel
|
|
|
|
|
|
+ let row = self.tableView.selectedRow
|
|
|
|
+ if row < 0 || row >= self.models.count {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ let model = self.models.object(at: row) as! CDSPDFSigntureModel
|
|
let cert = model.certificate!
|
|
let cert = model.certificate!
|
|
|
|
|
|
let dateFormatter = DateFormatter.init()
|
|
let dateFormatter = DateFormatter.init()
|
|
@@ -535,22 +539,22 @@ class DSignatureDetailsViewController: NSViewController, NSTableViewDelegate, NS
|
|
} else if selectedRow == 1 {
|
|
} else if selectedRow == 1 {
|
|
switch cert.signatureAlgorithmType {
|
|
switch cert.signatureAlgorithmType {
|
|
case .RSA_RSA:
|
|
case .RSA_RSA:
|
|
- self.detailsTextView.string = String(format: "%@(%@)","RSA_RSA",cert.signatureAlgorithmOID)
|
|
|
|
|
|
+ self.detailsTextView.string = String(format: "%@(%@)","RSA_RSA",cert.signatureAlgorithmOID ?? "")
|
|
break;
|
|
break;
|
|
case .MD2RSA:
|
|
case .MD2RSA:
|
|
- self.detailsTextView.string = String(format: "%@(%@)","MD2RSA",cert.signatureAlgorithmOID)
|
|
|
|
|
|
+ self.detailsTextView.string = String(format: "%@(%@)","MD2RSA",cert.signatureAlgorithmOID ?? "")
|
|
break;
|
|
break;
|
|
case .MD4RSA:
|
|
case .MD4RSA:
|
|
- self.detailsTextView.string = String(format: "%@(%@)", "MD4RSA",cert.signatureAlgorithmOID)
|
|
|
|
|
|
+ self.detailsTextView.string = String(format: "%@(%@)", "MD4RSA",cert.signatureAlgorithmOID ?? "")
|
|
break;
|
|
break;
|
|
case .SHA1RSA:
|
|
case .SHA1RSA:
|
|
- self.detailsTextView.string = String(format: "%@(%@)", "SHA1RSA",cert.signatureAlgorithmOID)
|
|
|
|
|
|
+ self.detailsTextView.string = String(format: "%@(%@)", "SHA1RSA",cert.signatureAlgorithmOID ?? "")
|
|
break;
|
|
break;
|
|
case .SHA256RSA:
|
|
case .SHA256RSA:
|
|
- self.detailsTextView.string = String(format: "%@(%@)", "SHA256RSA",cert.signatureAlgorithmOID)
|
|
|
|
|
|
+ self.detailsTextView.string = String(format: "%@(%@)", "SHA256RSA",cert.signatureAlgorithmOID ?? "")
|
|
break;
|
|
break;
|
|
case .SM3SM2:
|
|
case .SM3SM2:
|
|
- self.detailsTextView.string = String(format: "%@(%@)", "SM3SM2",cert.signatureAlgorithmOID)
|
|
|
|
|
|
+ self.detailsTextView.string = String(format: "%@(%@)", "SM3SM2",cert.signatureAlgorithmOID ?? "")
|
|
break;
|
|
break;
|
|
default: break
|
|
default: break
|
|
}
|
|
}
|
|
@@ -558,9 +562,9 @@ class DSignatureDetailsViewController: NSViewController, NSTableViewDelegate, NS
|
|
var string = ""
|
|
var string = ""
|
|
for key in cert.subjectDict.keys {
|
|
for key in cert.subjectDict.keys {
|
|
if (string.count == 0) {
|
|
if (string.count == 0) {
|
|
- string = String(format: "%@=%@",key as! String, cert.subjectDict[key] as! String)
|
|
|
|
|
|
+ string = String(format: "%@=%@",(key as? String) ?? "", (cert.subjectDict[key] as? String) ?? "")
|
|
} else {
|
|
} else {
|
|
- string = String(format: "%@\n%@=%@",string, (key as! String), cert.subjectDict[key] as! String)
|
|
|
|
|
|
+ string = String(format: "%@\n%@=%@",string, (key as? String) ?? "", (cert.subjectDict[key] as? String) ?? "")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
self.detailsTextView.string = string
|
|
self.detailsTextView.string = string
|
|
@@ -568,9 +572,9 @@ class DSignatureDetailsViewController: NSViewController, NSTableViewDelegate, NS
|
|
var string = ""
|
|
var string = ""
|
|
for key in cert.issuerDict.keys {
|
|
for key in cert.issuerDict.keys {
|
|
if (string.count == 0) {
|
|
if (string.count == 0) {
|
|
- string = String(format: "%@=%@",key as! String, cert.issuerDict[key] as! String)
|
|
|
|
|
|
+ string = String(format: "%@=%@",(key as? String) ?? "", (cert.issuerDict[key] as? String) ?? "")
|
|
} else {
|
|
} else {
|
|
- string = String(format: "%@\n%@=%@",string, (key as! String), cert.issuerDict[key] as! String)
|
|
|
|
|
|
+ string = String(format: "%@\n%@=%@",string, (key as? String) ?? "", (cert.issuerDict[key] as? String) ?? "")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
self.detailsTextView.string = string
|
|
self.detailsTextView.string = string
|
|
@@ -585,18 +589,18 @@ class DSignatureDetailsViewController: NSViewController, NSTableViewDelegate, NS
|
|
for infoDic in cert.authorityInfoAccess {
|
|
for infoDic in cert.authorityInfoAccess {
|
|
let dic: Dictionary = infoDic
|
|
let dic: Dictionary = infoDic
|
|
if content.count == 0 {
|
|
if content.count == 0 {
|
|
- content = String(format: "%@ = %@", dic["Method"] as! String, (dic["Method"] as! String))
|
|
|
|
|
|
+ content = String(format: "%@ = %@", (dic["Method"] as? String) ?? "", (dic["Method"] as? String) ?? "")
|
|
content = content + "\n"
|
|
content = content + "\n"
|
|
- let tString = String(format: "URL = %@", (dic["URI"] as! String))
|
|
|
|
|
|
+ let tString = String(format: "URL = %@", (dic["URI"] as? String) ?? "")
|
|
content = content + tString
|
|
content = content + tString
|
|
} else {
|
|
} else {
|
|
content = content + "\n"
|
|
content = content + "\n"
|
|
content = content + "\n"
|
|
content = content + "\n"
|
|
- var tString = String(format: "Method = %@", (dic["Method"] as! String))
|
|
|
|
|
|
+ var tString = String(format: "Method = %@", (dic["Method"] as? String) ?? "")
|
|
|
|
|
|
content = content + tString
|
|
content = content + tString
|
|
content = content + "\n"
|
|
content = content + "\n"
|
|
- tString = String(format: "URL = %@",(dic["URI"] as! String))
|
|
|
|
|
|
+ tString = String(format: "URL = %@",(dic["URI"] as? String) ?? "")
|
|
content = content + tString
|
|
content = content + tString
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -627,15 +631,15 @@ class DSignatureDetailsViewController: NSViewController, NSTableViewDelegate, NS
|
|
var usageString = ""
|
|
var usageString = ""
|
|
for us in att {
|
|
for us in att {
|
|
if usageString.count == 0 {
|
|
if usageString.count == 0 {
|
|
- usageString = NSLocalizedString(us as! String, comment: "")
|
|
|
|
|
|
+ usageString = NSLocalizedString((us as? String) ?? "", comment: "")
|
|
} else {
|
|
} else {
|
|
- usageString = String(format: "%@\n%@",usageString, NSLocalizedString(us as! String, comment: ""))
|
|
|
|
|
|
+ usageString = String(format: "%@\n%@",usageString, NSLocalizedString((us as? String) ?? "", comment: ""))
|
|
}
|
|
}
|
|
|
|
|
|
if usageString.count == 0 {
|
|
if usageString.count == 0 {
|
|
|
|
|
|
} else {
|
|
} else {
|
|
- usageString = String(format: "%@\n%@",usageString, NSLocalizedString(us as! String, comment: ""))
|
|
|
|
|
|
+ usageString = String(format: "%@\n%@",usageString, NSLocalizedString((us as? String) ?? "", comment: ""))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
self.detailsTextView.string = usageString
|
|
self.detailsTextView.string = usageString
|
|
@@ -655,17 +659,17 @@ class DSignatureDetailsViewController: NSViewController, NSTableViewDelegate, NS
|
|
}
|
|
}
|
|
self.detailsTextView.string = content
|
|
self.detailsTextView.string = content
|
|
} else if selectedRow == 13 {
|
|
} else if selectedRow == 13 {
|
|
- self.detailsTextView.string = cert.basicConstraints.replacingOccurrences(of: ",", with: "\n")
|
|
|
|
|
|
+ self.detailsTextView.string = cert.basicConstraints?.replacingOccurrences(of: ",", with: "\n") ?? ""
|
|
} else if selectedRow == 14 {
|
|
} else if selectedRow == 14 {
|
|
- self.detailsTextView.string = cert.publicKey.replacingOccurrences(of: ":", with: " ")
|
|
|
|
|
|
+ self.detailsTextView.string = cert.publicKey?.replacingOccurrences(of: ":", with: " ") ?? ""
|
|
} else if selectedRow == 15 {
|
|
} else if selectedRow == 15 {
|
|
- self.detailsTextView.string = cert.subjectKeyIdentifier.uppercased()
|
|
|
|
|
|
+ self.detailsTextView.string = cert.subjectKeyIdentifier?.uppercased() ?? ""
|
|
} else if selectedRow == 16 {
|
|
} else if selectedRow == 16 {
|
|
- self.detailsTextView.string = cert.x509Data.replacingOccurrences(of: ":", with: " ")
|
|
|
|
|
|
+ self.detailsTextView.string = cert.x509Data?.replacingOccurrences(of: ":", with: " ") ?? ""
|
|
} else if selectedRow == 17 {
|
|
} else if selectedRow == 17 {
|
|
- self.detailsTextView.string = cert.sha1Digest.replacingOccurrences(of: ":", with: " ")
|
|
|
|
|
|
+ self.detailsTextView.string = cert.sha1Digest?.replacingOccurrences(of: ":", with: " ") ?? ""
|
|
} else if selectedRow == 18 {
|
|
} else if selectedRow == 18 {
|
|
- self.detailsTextView.string = cert.md5Digest.replacingOccurrences(of: ":", with: " ")
|
|
|
|
|
|
+ self.detailsTextView.string = cert.md5Digest?.replacingOccurrences(of: ":", with: " ") ?? ""
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
self.detailsTextView.string = ""
|
|
self.detailsTextView.string = ""
|