MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / applyCertificate

Method applyCertificate

app/src/Licensing/OfflineLicense.cpp:344–374  ·  view source on GitHub ↗

* @brief Verifies a certificate and, on success, installs the token and persists it. */

Source from the content-addressed store, hash-verified

342 * @brief Verifies a certificate and, on success, installs the token and persists it.
343 */
344bool Licensing::OfflineLicense::applyCertificate(const QByteArray& framedCert, bool persist)
345{
346 const qint64 nowSecs = MonotonicClock::now().toSecsSinceEpoch();
347
348 CertificateFields fields;
349 const auto status =
350 verifyCertificate(framedCert, kOfflinePublicKey, machineId(), nowSecs, fields);
351 if (status != CertStatus::Valid) {
352 m_lastError = certStatusReason(status);
353 if (persist)
354 showOfflineError(m_lastError);
355
356 return false;
357 }
358
359 m_activated = true;
360 m_lastError = QString();
361 m_variantName = fields.variant;
362 m_expiresAt = QDateTime::fromSecsSinceEpoch(fields.expiresAt);
363
364 if (!LemonSqueezy::instance().isOnlineActivated()) {
365 const int days = qMax(0, static_cast<int>((fields.expiresAt - nowSecs) / 86400));
366 installOfflineToken(fields, days);
367 }
368
369 if (persist)
370 writeSettings(framedCert);
371
372 Q_EMIT activatedChanged();
373 return true;
374}

Callers

nothing calls this directly

Calls 3

showOfflineErrorFunction · 0.85
installOfflineTokenFunction · 0.85
isOnlineActivatedMethod · 0.80

Tested by

no test coverage detected