Mercurial > trustbridge
comparison ui/administratorwindow.cpp @ 679:75cd2fbf9ac6
(Issue 9) Log key's sha256 fingerprint
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Mon, 30 Jun 2014 17:21:44 +0200 |
parents | c9d296f04995 |
children | 0b7bb4f68f5a |
comparison
equal
deleted
inserted
replaced
678:237af0c82454 | 679:75cd2fbf9ac6 |
---|---|
222 else { | 222 else { |
223 removeButton->setEnabled(true); | 223 removeButton->setEnabled(true); |
224 } | 224 } |
225 } | 225 } |
226 | 226 |
227 void AdministratorWindow::logChanges(const QString ¤tCerts) | 227 void AdministratorWindow::logChanges(const QString ¤tCerts, const QString& keyFingerprint) |
228 { | 228 { |
229 QDir logDir(QStandardPaths::writableLocation(QStandardPaths::DataLocation)); | 229 QDir logDir(QStandardPaths::writableLocation(QStandardPaths::DataLocation)); |
230 QString logFilePath = logDir.filePath("log.txt"); | 230 QString logFilePath = logDir.filePath("log.txt"); |
231 QFile logFile(logFilePath); | 231 QFile logFile(logFilePath); |
232 | 232 |
237 return; | 237 return; |
238 } | 238 } |
239 | 239 |
240 CertificateList newCertList; | 240 CertificateList newCertList; |
241 newCertList.readList(currentCerts.toLocal8Bit()); | 241 newCertList.readList(currentCerts.toLocal8Bit()); |
242 QByteArray entries = createLogEntries(newCertList); | 242 QByteArray entries = createLogEntries(newCertList, keyFingerprint); |
243 if(logFile.write(entries) != entries.size()) { | 243 if(logFile.write(entries) != entries.size()) { |
244 QMessageBox::warning(this, tr("Error!"), tr("Failed to write log file: ") + | 244 QMessageBox::warning(this, tr("Error!"), tr("Failed to write log file: ") + |
245 logFilePath + tr(" Changes are not logged!")); | 245 logFilePath + tr(" Changes are not logged!")); |
246 return; | 246 return; |
247 } | 247 } |
248 logFile.close(); | 248 logFile.close(); |
249 } | 249 } |
250 | 250 |
251 QByteArray AdministratorWindow::createLogEntries(const CertificateList &list) | 251 QByteArray AdministratorWindow::createLogEntries(const CertificateList &list, const QString& keyFingerprint) |
252 { | 252 { |
253 QByteArray entries; | 253 QByteArray entries; |
254 QByteArray removeListEntries; | 254 QByteArray removeListEntries; |
255 | 255 |
256 QDateTime currentDate = QDateTime::currentDateTime(); | 256 QDateTime currentDate = QDateTime::currentDateTime(); |
263 newListDate.toString(Qt::ISODate) + | 263 newListDate.toString(Qt::ISODate) + |
264 tr(" based on list from ") + | 264 tr(" based on list from ") + |
265 listDate.toString(Qt::ISODate) + | 265 listDate.toString(Qt::ISODate) + |
266 "#####\r\n"); | 266 "#####\r\n"); |
267 entries.append(tr("signing certificate: \r\n")); | 267 entries.append(tr("signing certificate: \r\n")); |
268 entries.append(tr("new certificates:\r\n")); | 268 entries.append(keyFingerprint); |
269 | |
270 entries.append(tr("\r\nnew certificates:\r\n")); | |
269 | 271 |
270 foreach (const Certificate& cert, list.getCertificates()) { | 272 foreach (const Certificate& cert, list.getCertificates()) { |
271 if (!mCertList.getCertificates().contains(cert)) { | 273 if (!mCertList.getCertificates().contains(cert)) { |
272 QString certEntry(cert.subjectCN() + ": " + cert.base64Line() + "\r\n"); | 274 QString certEntry(cert.subjectCN() + ": " + cert.base64Line() + "\r\n"); |
273 if (cert.isInstallCert()) { | 275 if (cert.isInstallCert()) { |