69 { |
69 { |
70 return mFingerprint; |
70 return mFingerprint; |
71 } |
71 } |
72 |
72 |
73 // ---------------------------------------------------------------------------- |
73 // ---------------------------------------------------------------------------- |
|
74 // UntrustedCertificateInfoBase::serialNumber() |
|
75 // ---------------------------------------------------------------------------- |
|
76 // |
|
77 const QByteArray UntrustedCertificateInfoBase::serialNumber() const |
|
78 { |
|
79 return mSerialNumber; |
|
80 } |
|
81 |
|
82 // ---------------------------------------------------------------------------- |
|
83 // UntrustedCertificateInfoBase::validFrom() |
|
84 // ---------------------------------------------------------------------------- |
|
85 // |
|
86 const QDateTime UntrustedCertificateInfoBase::validFrom() const |
|
87 { |
|
88 return mValidFrom; |
|
89 } |
|
90 |
|
91 // ---------------------------------------------------------------------------- |
|
92 // UntrustedCertificateInfoBase::validTo() |
|
93 // ---------------------------------------------------------------------------- |
|
94 // |
|
95 const QDateTime UntrustedCertificateInfoBase::validTo() const |
|
96 { |
|
97 return mValidTo; |
|
98 } |
|
99 |
|
100 // ---------------------------------------------------------------------------- |
|
101 // UntrustedCertificateInfoBase::format() |
|
102 // ---------------------------------------------------------------------------- |
|
103 // |
|
104 const QString UntrustedCertificateInfoBase::format() const |
|
105 { |
|
106 QString format; |
|
107 switch (mFormat) { |
|
108 case X509Certificate: |
|
109 //: Type name for X509 certificates displayed in certificate details. |
|
110 // TODO: localised UI string |
|
111 format = tr("X.509"); |
|
112 break; |
|
113 default: |
|
114 //: Type name for unknown certificates displayed in certificate details. |
|
115 // TODO: localised UI string |
|
116 format = tr("Unknown"); |
|
117 break; |
|
118 } |
|
119 return format; |
|
120 } |
|
121 |
|
122 // ---------------------------------------------------------------------------- |
|
123 // UntrustedCertificateInfoBase::digestAlgorithm() |
|
124 // ---------------------------------------------------------------------------- |
|
125 // |
|
126 const QString UntrustedCertificateInfoBase::digestAlgorithm() const |
|
127 { |
|
128 return algorithmName(mDigestAlgorithm); |
|
129 } |
|
130 |
|
131 // ---------------------------------------------------------------------------- |
|
132 // UntrustedCertificateInfoBase::AsymmetricAlgorithm() |
|
133 // ---------------------------------------------------------------------------- |
|
134 // |
|
135 const QString UntrustedCertificateInfoBase::asymmetricAlgorithm() const |
|
136 { |
|
137 return algorithmName(mAsymmetricAlgorithm); |
|
138 } |
|
139 |
|
140 // ---------------------------------------------------------------------------- |
|
141 // UntrustedCertificateInfoBase::AsymmetricAlgorithm() |
|
142 // ---------------------------------------------------------------------------- |
|
143 // |
|
144 const QString UntrustedCertificateInfoBase::combinedAlgorithmName() const |
|
145 { |
|
146 if (mDigestAlgorithm != Unknown && mAsymmetricAlgorithm != Unknown) { |
|
147 //: Format to combine digest and asymmetric algorithm names. |
|
148 //: %1 is digest (signing) and %2 is asymmetric (public-key) algorithm. |
|
149 // TODO: localised UI string needed |
|
150 return tr("%1%2").arg(digestAlgorithm()).arg(asymmetricAlgorithm()); |
|
151 } |
|
152 //: Algorithm name for unknown algorithm. |
|
153 // TODO: localised UI string needed |
|
154 return tr("Unknown"); |
|
155 } |
|
156 |
|
157 // ---------------------------------------------------------------------------- |
74 // UntrustedCertificateInfoBase::formattedFingerprint() |
158 // UntrustedCertificateInfoBase::formattedFingerprint() |
75 // ---------------------------------------------------------------------------- |
159 // ---------------------------------------------------------------------------- |
76 // |
160 // |
77 const QString UntrustedCertificateInfoBase::formattedFingerprint() const |
161 const QString UntrustedCertificateInfoBase::formattedFingerprint( |
|
162 const QByteArray &byteArray) const |
78 { |
163 { |
79 QString formatted; |
164 QString formatted; |
80 QByteArray fp = fingerprint(); |
|
81 |
165 |
82 QString number; |
166 QString number; |
83 int blockIndex = 0; |
167 int blockIndex = 0; |
84 int count = fp.count(); |
168 int count = byteArray.count(); |
85 for (int index = 0; index < count; ++index) { |
169 for (int index = 0; index < count; ++index) { |
86 if (blockIndex == KCharsPerBlock) { |
170 if (blockIndex == KCharsPerBlock) { |
87 formatted.append(KBlockSeparator); |
171 formatted.append(KBlockSeparator); |
88 blockIndex = 0; |
172 blockIndex = 0; |
89 } |
173 } |
90 number.sprintf(KHexNumberFormatTwoDigitsWithLeadingZeroes, |
174 number.sprintf(KHexNumberFormatTwoDigitsWithLeadingZeroes, |
91 static_cast<unsigned char>(fp.at(index))); |
175 static_cast<unsigned char>(byteArray.at(index))); |
92 formatted.append(number); |
176 formatted.append(number); |
93 ++blockIndex; |
177 ++blockIndex; |
94 } |
178 } |
95 |
179 |
96 return formatted; |
180 return formatted; |
97 } |
181 } |
98 |
182 |
99 // ---------------------------------------------------------------------------- |
183 // ---------------------------------------------------------------------------- |
100 // UntrustedCertificateInfoBase::serialNumber() |
|
101 // ---------------------------------------------------------------------------- |
|
102 // |
|
103 const QByteArray UntrustedCertificateInfoBase::serialNumber() const |
|
104 { |
|
105 return mSerialNumber; |
|
106 } |
|
107 |
|
108 // ---------------------------------------------------------------------------- |
|
109 // UntrustedCertificateInfoBase::formattedSerialNumber() |
184 // UntrustedCertificateInfoBase::formattedSerialNumber() |
110 // ---------------------------------------------------------------------------- |
185 // ---------------------------------------------------------------------------- |
111 // |
186 // |
112 const QString UntrustedCertificateInfoBase::formattedSerialNumber() const |
187 const QString UntrustedCertificateInfoBase::formattedSerialNumber( |
|
188 const QByteArray &serialNumber) const |
113 { |
189 { |
114 QString formatted; |
190 QString formatted; |
115 QByteArray sn = serialNumber(); |
|
116 |
191 |
117 QString number; |
192 QString number; |
118 int count = sn.count(); |
193 int count = serialNumber.count(); |
119 for (int index = 0; index < count; ++index) { |
194 for (int index = 0; index < count; ++index) { |
120 number.sprintf(KHexNumberFormatSimple, |
195 number.sprintf(KHexNumberFormatSimple, |
121 static_cast<unsigned char>(sn.at(index))); |
196 static_cast<unsigned char>(serialNumber.at(index))); |
122 formatted.append(number); |
197 formatted.append(number); |
123 } |
198 } |
124 |
199 |
125 return formatted; |
200 return formatted; |
126 } |
|
127 |
|
128 // ---------------------------------------------------------------------------- |
|
129 // UntrustedCertificateInfoBase::validFrom() |
|
130 // ---------------------------------------------------------------------------- |
|
131 // |
|
132 const QDateTime UntrustedCertificateInfoBase::validFrom() const |
|
133 { |
|
134 return mValidFrom; |
|
135 } |
|
136 |
|
137 // ---------------------------------------------------------------------------- |
|
138 // UntrustedCertificateInfoBase::validTo() |
|
139 // ---------------------------------------------------------------------------- |
|
140 // |
|
141 const QDateTime UntrustedCertificateInfoBase::validTo() const |
|
142 { |
|
143 return mValidTo; |
|
144 } |
|
145 |
|
146 // ---------------------------------------------------------------------------- |
|
147 // UntrustedCertificateInfoBase::format() |
|
148 // ---------------------------------------------------------------------------- |
|
149 // |
|
150 const QString UntrustedCertificateInfoBase::format() const |
|
151 { |
|
152 QString format; |
|
153 switch (mFormat) { |
|
154 case X509Certificate: |
|
155 //: Type name for X509 certificates displayed in certificate details. |
|
156 // TODO: localised UI string |
|
157 format = tr("X509"); |
|
158 break; |
|
159 default: |
|
160 //: Type name for unknown certificates displayed in certificate details. |
|
161 // TODO: localised UI string |
|
162 format = tr("Unknown"); |
|
163 break; |
|
164 } |
|
165 return format; |
|
166 } |
|
167 |
|
168 // ---------------------------------------------------------------------------- |
|
169 // UntrustedCertificateInfoBase::digestAlgorithm() |
|
170 // ---------------------------------------------------------------------------- |
|
171 // |
|
172 const QString UntrustedCertificateInfoBase::digestAlgorithm() const |
|
173 { |
|
174 return algorithmName(mDigestAlgorithm); |
|
175 } |
|
176 |
|
177 // ---------------------------------------------------------------------------- |
|
178 // UntrustedCertificateInfoBase::AsymmetricAlgorithm() |
|
179 // ---------------------------------------------------------------------------- |
|
180 // |
|
181 const QString UntrustedCertificateInfoBase::asymmetricAlgorithm() const |
|
182 { |
|
183 return algorithmName(mAsymmetricAlgorithm); |
|
184 } |
|
185 |
|
186 // ---------------------------------------------------------------------------- |
|
187 // UntrustedCertificateInfoBase::AsymmetricAlgorithm() |
|
188 // ---------------------------------------------------------------------------- |
|
189 // |
|
190 const QString UntrustedCertificateInfoBase::combinedAlgorithmName() const |
|
191 { |
|
192 if (mDigestAlgorithm != Unknown && mAsymmetricAlgorithm != Unknown) { |
|
193 //: Format to combine digest and asymmetric algorithm names. |
|
194 //: %1 is digest (signing) and %2 is asymmetric (public-key) algorithm. |
|
195 // TODO: localised UI string needed |
|
196 return tr("%1%2").arg(digestAlgorithm()).arg(asymmetricAlgorithm()); |
|
197 } |
|
198 //: Algorithm name for unknown algorithm. |
|
199 // TODO: localised UI string needed |
|
200 return tr("Unknown"); |
|
201 } |
201 } |
202 |
202 |
203 // ---------------------------------------------------------------------------- |
203 // ---------------------------------------------------------------------------- |
204 // UntrustedCertificateInfoBase::isDateValid() |
204 // UntrustedCertificateInfoBase::isDateValid() |
205 // ---------------------------------------------------------------------------- |
205 // ---------------------------------------------------------------------------- |