AusweisApp2/src/activation/customscheme/CustomSchemeActivationHandl...

48 lines
1.2 KiB
C++
Raw Normal View History

2017-07-03 09:30:10 +02:00
/*!
2019-05-22 10:08:38 +02:00
* \copyright Copyright (c) 2014-2019 Governikus GmbH & Co. KG, Germany
2017-07-03 09:30:10 +02:00
*/
#include "CustomSchemeActivationHandler.h"
#include "CustomSchemeActivationContext.h"
#include <QDesktopServices>
#include <QLoggingCategory>
using namespace governikus;
Q_DECLARE_LOGGING_CATEGORY(activation)
bool CustomSchemeActivationHandler::start()
{
QDesktopServices::setUrlHandler(QStringLiteral("eid"), this, "onCustomUrl");
return true;
}
void CustomSchemeActivationHandler::stop()
{
QDesktopServices::unsetUrlHandler(QStringLiteral("eid"));
}
void CustomSchemeActivationHandler::onCustomUrl(const QUrl& pUrl)
{
qCDebug(activation) << "Got new request";
qCDebug(activation) << "Request URL:" << pUrl;
2017-12-20 14:54:05 +01:00
if (pUrl.port() != 24727 ||
(pUrl.host() != QLatin1String("127.0.0.1") && pUrl.host() != QLatin1String("localhost")) ||
(pUrl.path() != QLatin1String("/eID-Client")))
2017-07-03 09:30:10 +02:00
{
qCWarning(activation) << "Request type: unknown";
return;
}
2017-12-20 14:54:05 +01:00
qCDebug(activation) << "Request type: authentication";
2019-01-03 15:06:22 +01:00
const auto& context = QSharedPointer<CustomSchemeActivationContext>::create(pUrl);
2017-12-20 14:54:05 +01:00
connect(context.data(), &CustomSchemeActivationContext::fireShowUserInformation, this, &ActivationHandler::fireShowUserInformation);
Q_EMIT fireAuthenticationRequest(context);
2017-07-03 09:30:10 +02:00
}