E5Network/E5SslCertificatesDialog.py

changeset 3020
542e97d4ecb3
parent 2990
583beaf0b4b8
child 3022
57179e4cdadd
equal deleted inserted replaced
3019:7912530a33e2 3020:542e97d4ecb3
145 def on_serversDeleteButton_clicked(self): 145 def on_serversDeleteButton_clicked(self):
146 """ 146 """
147 Private slot to delete the selected server certificate. 147 Private slot to delete the selected server certificate.
148 """ 148 """
149 itm = self.serversCertificatesTree.currentItem() 149 itm = self.serversCertificatesTree.currentItem()
150 res = E5MessageBox.yesNo(self, 150 res = E5MessageBox.yesNo(
151 self,
151 self.trUtf8("Delete Server Certificate"), 152 self.trUtf8("Delete Server Certificate"),
152 self.trUtf8("""<p>Shall the server certificate really be""" 153 self.trUtf8("""<p>Shall the server certificate really be"""
153 """ deleted?</p><p>{0}</p>""" 154 """ deleted?</p><p>{0}</p>"""
154 """<p>If the server certificate is deleted, the""" 155 """<p>If the server certificate is deleted, the"""
155 """ normal security checks will be reinstantiated""" 156 """ normal security checks will be reinstantiated"""
211 commonStr = ", ".join( 212 commonStr = ", ".join(
212 cert.subjectInfo(QSslCertificate.CommonName)) 213 cert.subjectInfo(QSslCertificate.CommonName))
213 else: 214 else:
214 commonStr = cert.subjectInfo( 215 commonStr = cert.subjectInfo(
215 QSslCertificate.CommonName) 216 QSslCertificate.CommonName)
216 E5MessageBox.warning(self, 217 E5MessageBox.warning(
218 self,
217 self.trUtf8("Import Certificate"), 219 self.trUtf8("Import Certificate"),
218 self.trUtf8( 220 self.trUtf8(
219 """<p>The certificate <b>{0}</b> already exists.""" 221 """<p>The certificate <b>{0}</b> already exists."""
220 """ Skipping.</p>""") 222 """ Skipping.</p>""")
221 .format(Utilities.decodeString(commonStr))) 223 .format(Utilities.decodeString(commonStr)))
349 def on_caDeleteButton_clicked(self): 351 def on_caDeleteButton_clicked(self):
350 """ 352 """
351 Private slot to delete the selected CA certificate. 353 Private slot to delete the selected CA certificate.
352 """ 354 """
353 itm = self.caCertificatesTree.currentItem() 355 itm = self.caCertificatesTree.currentItem()
354 res = E5MessageBox.yesNo(self, 356 res = E5MessageBox.yesNo(
357 self,
355 self.trUtf8("Delete CA Certificate"), 358 self.trUtf8("Delete CA Certificate"),
356 self.trUtf8( 359 self.trUtf8(
357 """<p>Shall the CA certificate really be deleted?</p>""" 360 """<p>Shall the CA certificate really be deleted?</p>"""
358 """<p>{0}</p>""" 361 """<p>{0}</p>"""
359 """<p>If the CA certificate is deleted, the browser""" 362 """<p>If the CA certificate is deleted, the browser"""
397 commonStr = ", ".join( 400 commonStr = ", ".join(
398 cert.subjectInfo(QSslCertificate.CommonName)) 401 cert.subjectInfo(QSslCertificate.CommonName))
399 else: 402 else:
400 commonStr = cert.subjectInfo( 403 commonStr = cert.subjectInfo(
401 QSslCertificate.CommonName) 404 QSslCertificate.CommonName)
402 E5MessageBox.warning(self, 405 E5MessageBox.warning(
406 self,
403 self.trUtf8("Import Certificate"), 407 self.trUtf8("Import Certificate"),
404 self.trUtf8( 408 self.trUtf8(
405 """<p>The certificate <b>{0}</b> already exists.""" 409 """<p>The certificate <b>{0}</b> already exists."""
406 """ Skipping.</p>""") 410 """ Skipping.</p>""")
407 .format(Utilities.decodeString(commonStr))) 411 .format(Utilities.decodeString(commonStr)))
451 if not ext or ext not in ["pem", "der"]: 455 if not ext or ext not in ["pem", "der"]:
452 ex = selectedFilter.split("(*")[1].split(")")[0] 456 ex = selectedFilter.split("(*")[1].split(")")[0]
453 if ex: 457 if ex:
454 fname += ex 458 fname += ex
455 if QFileInfo(fname).exists(): 459 if QFileInfo(fname).exists():
456 res = E5MessageBox.yesNo(self, 460 res = E5MessageBox.yesNo(
461 self,
457 self.trUtf8("Export Certificate"), 462 self.trUtf8("Export Certificate"),
458 self.trUtf8("<p>The file <b>{0}</b> already exists." 463 self.trUtf8("<p>The file <b>{0}</b> already exists."
459 " Overwrite it?</p>").format(fname), 464 " Overwrite it?</p>").format(fname),
460 icon=E5MessageBox.Warning) 465 icon=E5MessageBox.Warning)
461 if not res: 466 if not res:
462 return 467 return
463 468
464 f = QFile(fname) 469 f = QFile(fname)
465 if not f.open(QIODevice.WriteOnly): 470 if not f.open(QIODevice.WriteOnly):
466 E5MessageBox.critical(self, 471 E5MessageBox.critical(
472 self,
467 self.trUtf8("Export Certificate"), 473 self.trUtf8("Export Certificate"),
468 self.trUtf8( 474 self.trUtf8(
469 """<p>The certificate could not be written""" 475 """<p>The certificate could not be written"""
470 """ to file <b>{0}</b></p><p>Error: {1}</p>""") 476 """ to file <b>{0}</b></p><p>Error: {1}</p>""")
471 .format(fname, f.errorString())) 477 .format(fname, f.errorString()))
492 "All Files (*)")) 498 "All Files (*)"))
493 499
494 if fname: 500 if fname:
495 f = QFile(fname) 501 f = QFile(fname)
496 if not f.open(QIODevice.ReadOnly): 502 if not f.open(QIODevice.ReadOnly):
497 E5MessageBox.critical(self, 503 E5MessageBox.critical(
504 self,
498 self.trUtf8("Export Certificate"), 505 self.trUtf8("Export Certificate"),
499 self.trUtf8( 506 self.trUtf8(
500 """<p>The certificate could not be read from file""" 507 """<p>The certificate could not be read from file"""
501 """ <b>{0}</b></p><p>Error: {1}</p>""") 508 """ <b>{0}</b></p><p>Error: {1}</p>""")
502 .format(fname, f.errorString())) 509 .format(fname, f.errorString()))

eric ide

mercurial