Sun, 30 Sep 2012 17:04:23 +0200
Made the second set of Qt5 compatibility changes.
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
1509
c0b5e693b0eb
Updated copyright for 2012.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1427
diff
changeset
|
3 | # Copyright (c) 2010 - 2012 Detlev Offenbach <detlev@die-offenbachs.de> |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing a widget to show SSL certificate infos. |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
2078
9f4a45741622
Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
10 | from PyQt4.QtCore import QCryptographicHash, QDateTime, Qt, qVersion |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
11 | from PyQt4.QtGui import QWidget |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
12 | from PyQt4.QtNetwork import QSslCertificate |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
13 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
14 | from .Ui_SslInfoWidget import Ui_SslInfoWidget |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
15 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
16 | import Utilities |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | class SslInfoWidget(QWidget, Ui_SslInfoWidget): |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | Class implementing a widget to show SSL certificate infos. |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | def __init__(self, parent=None): |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | Constructor |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | @param parent reference to the parent widget (QWidget) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | super().__init__(parent) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
30 | self.setupUi(self) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | def showCertificate(self, certificate): |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | Public method to show the SSL certificate information. |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | @param certificate reference to the SSL certificate (QSslCertificate) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
37 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | self.blacklistedLabel.setVisible(False) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | self.blacklistedLabel.setStyleSheet( |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
40 | "QLabel { color : white; background-color : red; }") |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
41 | self.expiredLabel.setVisible(False) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
42 | self.expiredLabel.setStyleSheet( |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
43 | "QLabel { color : white; background-color : red; }") |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | |
2078
9f4a45741622
Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
45 | if qVersion() >= "5.0.0": |
9f4a45741622
Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
46 | self.subjectCommonNameLabel.setText(self.__certificateString( |
9f4a45741622
Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
47 | ", ".join(certificate.subjectInfo(QSslCertificate.CommonName)))) |
9f4a45741622
Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
48 | self.subjectOrganizationLabel.setText(self.__certificateString( |
9f4a45741622
Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
49 | ", ".join(certificate.subjectInfo(QSslCertificate.Organization)))) |
9f4a45741622
Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
50 | self.subjectOrganizationalUnitLabel.setText(self.__certificateString( |
9f4a45741622
Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
51 | ", ".join( |
9f4a45741622
Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
52 | certificate.subjectInfo(QSslCertificate.OrganizationalUnitName)))) |
9f4a45741622
Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
53 | self.issuerCommonNameLabel.setText(self.__certificateString( |
9f4a45741622
Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
54 | ", ".join(certificate.issuerInfo(QSslCertificate.CommonName)))) |
9f4a45741622
Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
55 | self.issuerOrganizationLabel.setText(self.__certificateString( |
9f4a45741622
Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
56 | ", ".join(certificate.issuerInfo(QSslCertificate.Organization)))) |
9f4a45741622
Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
57 | self.issuerOrganizationalUnitLabel.setText(self.__certificateString( |
9f4a45741622
Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
58 | ", ".join(certificate.issuerInfo(QSslCertificate.OrganizationalUnitName)))) |
9f4a45741622
Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
59 | else: |
9f4a45741622
Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
60 | self.subjectCommonNameLabel.setText(self.__certificateString( |
9f4a45741622
Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
61 | certificate.subjectInfo(QSslCertificate.CommonName))) |
9f4a45741622
Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
62 | self.subjectOrganizationLabel.setText(self.__certificateString( |
9f4a45741622
Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
63 | certificate.subjectInfo(QSslCertificate.Organization))) |
9f4a45741622
Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
64 | self.subjectOrganizationalUnitLabel.setText(self.__certificateString( |
9f4a45741622
Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
65 | certificate.subjectInfo(QSslCertificate.OrganizationalUnitName))) |
9f4a45741622
Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
66 | self.issuerCommonNameLabel.setText(self.__certificateString( |
9f4a45741622
Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
67 | certificate.issuerInfo(QSslCertificate.CommonName))) |
9f4a45741622
Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
68 | self.issuerOrganizationLabel.setText(self.__certificateString( |
9f4a45741622
Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
69 | certificate.issuerInfo(QSslCertificate.Organization))) |
9f4a45741622
Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
70 | self.issuerOrganizationalUnitLabel.setText(self.__certificateString( |
9f4a45741622
Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
71 | certificate.issuerInfo(QSslCertificate.OrganizationalUnitName))) |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
72 | self.serialNumberLabel.setText(self.__serialNumber(certificate)) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
73 | self.effectiveLabel.setText(Qt.escape( |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
74 | certificate.effectiveDate().toString("yyyy-MM-dd"))) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
75 | self.expiresLabel.setText(Qt.escape( |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
76 | certificate.expiryDate().toString("yyyy-MM-dd"))) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
77 | self.sha1Label.setText(self.__formatHexString( |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
78 | str(certificate.digest(QCryptographicHash.Sha1).toHex(), encoding="ascii"))) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
79 | self.md5Label.setText(self.__formatHexString( |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
80 | str(certificate.digest(QCryptographicHash.Md5).toHex(), encoding="ascii"))) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
81 | |
2078
9f4a45741622
Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
82 | if (qVersion() >= "5.0.0" and certificate.isBlacklisted()) or \ |
9f4a45741622
Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
83 | (qVersion() < "5.0.0" and not certificate.isValid()): |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
84 | # something is wrong; indicate it to the user |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
85 | if self.__hasExpired(certificate.effectiveDate(), certificate.expiryDate()): |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
86 | self.expiredLabel.setVisible(True) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
87 | else: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
88 | self.blacklistedLabel.setVisible(True) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
89 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
90 | def __certificateString(self, txt): |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
91 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
92 | Private method to prepare some text for display. |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
93 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
94 | @param txt text to be displayed (string) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
95 | @return prepared text (string) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
96 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
97 | if txt is None or txt == "": |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
98 | return self.trUtf8("<not part of the certificate>") |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
99 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
100 | return Qt.escape(Utilities.decodeString(txt)) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
101 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
102 | def __serialNumber(self, cert): |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
103 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
104 | Private slot to format the certificate serial number. |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
105 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
106 | @param cert reference to the SSL certificate (QSslCertificate) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
107 | @return formated serial number (string) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
108 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
109 | serial = cert.serialNumber() |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
110 | if serial == "": |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
111 | return self.trUtf8("<not part of the certificate>") |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
112 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
113 | if ':' in serial: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
114 | return str(serial, encoding="ascii").upper() |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
115 | else: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
116 | hexString = hex(int(serial))[2:] |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
117 | return self.__formatHexString(hexString) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
118 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
119 | def __formatHexString(self, hexString): |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
120 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
121 | Private method to format a hex string for display. |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
122 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
123 | @param hexString hex string to be formatted (string) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
124 | @return formatted string (string) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
125 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
126 | hexString = hexString.upper() |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
127 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
128 | if len(hexString) % 2 == 1: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
129 | hexString = '0' + hexString |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
130 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
131 | hexList = [] |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
132 | while hexString: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
133 | hexList.append(hexString[:2]) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
134 | hexString = hexString[2:] |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
135 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
136 | return Qt.escape(':'.join(hexList)) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
137 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
138 | def __hasExpired(self, effectiveDate, expiryDate): |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
139 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
140 | Private method to check for a certificate expiration. |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
141 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
142 | @param effectiveDate date the certificate becomes effective (QDateTime) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
143 | @param expiryDate date the certificate expires (QDateTime) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
144 | @return flag indicating the expiration status (boolean) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
145 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
146 | now = QDateTime.currentDateTime() |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
147 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
148 | return now < effectiveDate or now >= expiryDate |