Commit 8f6cc539 authored by Andrew den Exter's avatar Andrew den Exter

Add a generic validator type which third parties can use to authenticate using the device lock.

This includes additional provisions for verifying an allowed
authentication method was used by the expected application.
parent 82172d2f
......@@ -4,6 +4,8 @@
<interface name="org.nemomobile.devicelock.Authorization">
<method name="RequestChallenge">
<arg name="client" type="o" direction="in"/>
<arg name="requested_methods" type="u" direction="in"/>
<arg name="authenticating_pid" type="u" direction="in"/>
<arg name="challenge_code" type="v" direction="out"/>
<arg name="allowed_methods" type="u" direction="out"/>
</method>
......
......@@ -16,7 +16,6 @@ BuildRequires: pkgconfig(libsystemd-daemon)
BuildRequires: pkgconfig(mce)
BuildRequires: pkgconfig(nemodbus)
Obsoletes: nemo-qml-plugin-devicelock-default < 0.2.0
Requires: nemo-devicelock-daemon
%description
%{summary}.
......@@ -43,7 +42,6 @@ Requires: pkgconfig(nemodbus)
Summary: Development libraries for device lock daemons
Group: Development/Libraries
Requires: %{name}-devel = %{version}-%{release}
Requires: nemo-devicelock-daemon-cli = %{version}-%{release}
Requires: pkgconfig(keepalive)
Requires: pkgconfig(libsystemd-daemon)
Requires: pkgconfig(mce)
......
......@@ -35,6 +35,7 @@
#include <clidevicelocksettings.h>
#include <clidevicereset.h>
#include <cliencryptionsettings.h>
#include <clivalidator.h>
#include <hostfingerprintsensor.h>
#include <hostfingerprintsettings.h>
#include <hostservice.h>
......@@ -50,6 +51,7 @@ int main(int argc, char *argv[])
NemoDeviceLock::CliDeviceLockSettings deviceLockSettings;
NemoDeviceLock::CliDeviceReset deviceReset;
NemoDeviceLock::CliEncryptionSettings encryptionSettings;
NemoDeviceLock::CliValidator validator;
NemoDeviceLock::HostFingerprintSensor fingerprintSensor;
NemoDeviceLock::HostFingerprintSettings fingerprintSettings;
......@@ -60,7 +62,8 @@ int main(int argc, char *argv[])
&deviceReset,
&encryptionSettings,
&fingerprintSensor,
&fingerprintSettings);
&fingerprintSettings,
&validator);
return application.exec();
}
......@@ -66,7 +66,7 @@ class NEMODEVICELOCK_EXPORT AuthenticationInput : public QObject, private Connec
Q_OBJECT
Q_PROPERTY(Authenticator::Methods utilizedMethods READ utilizedMethods NOTIFY utilizedMethodsChanged)
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
Q_PROPERTY(bool authenticatingProcess READ authenticatingPid NOTIFY authenticatingPidChanged)
Q_PROPERTY(int authenticatingProcess READ authenticatingPid NOTIFY authenticatingPidChanged)
Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged)
Q_PROPERTY(bool registered READ isRegistered WRITE setRegistered NOTIFY registeredChanged)
Q_PROPERTY(int minimumCodeLength READ minimumCodeLength CONSTANT)
......
......@@ -69,7 +69,8 @@ public:
enum Method {
NoAuthentication = 0x00,
SecurityCode = 0x01,
Fingerprint = 0x02
Fingerprint = 0x02,
AllAvailable = SecurityCode | Fingerprint
};
Q_DECLARE_FLAGS(Methods, Method)
......@@ -81,7 +82,7 @@ public:
bool isAuthenticating() const;
Q_INVOKABLE void authenticate(
const QVariant &challengeCode, Methods methods = Methods(SecurityCode | Fingerprint));
const QVariant &challengeCode, Methods methods = AllAvailable);
Q_INVOKABLE void cancel();
signals:
......
......@@ -6,6 +6,7 @@ PUBLIC_HEADERS += \
$$PWD/clidevicelock.h \
$$PWD/clidevicelocksettings.h \
$$PWD/clidevicereset.h \
$$PWD/clivalidator.h \
$$PWD/cliencryptionsettings.h
HEADERS += \
......@@ -17,4 +18,5 @@ SOURCES += \
$$PWD/clidevicelocksettings.cpp \
$$PWD/clidevicereset.cpp \
$$PWD/cliencryptionsettings.cpp \
$$PWD/clivalidator.cpp \
$$PWD/lockcodewatcher.cpp
......@@ -103,7 +103,7 @@ void CliAuthenticator::enterSecurityCode(const QString &code)
m_securityCode.clear();
}
QVariant CliAuthenticator::authenticateChallengeCode(const QVariant &)
QVariant CliAuthenticator::authenticateChallengeCode(const QVariant &, Authenticator::Method, uint)
{
return m_securityCode;
}
......
......@@ -58,7 +58,8 @@ public:
bool clearCode(const QString &code) override;
void enterSecurityCode(const QString &code);
QVariant authenticateChallengeCode(const QVariant &challengeCode);
QVariant authenticateChallengeCode(
const QVariant &challengeCode, Authenticator::Method method, uint authenticatingPid) override;
private:
QExplicitlySharedDataPointer<LockCodeWatcher> m_watcher;
......
/*
* Copyright (C) 2016 Jolla Ltd
* Contact: Andrew den Exter <andrew.den.exter@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
* "Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Nemo Mobile nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
*/
#include "clivalidator.h"
#include <hostauthenticationinput.h>
#include "lockcodewatcher.h"
namespace NemoDeviceLock
{
CliValidator::CliValidator(QObject *parent)
: HostValidator(parent)
, m_watcher(LockCodeWatcher::instance())
{
}
CliValidator::~CliValidator()
{
}
void CliValidator::verifyToken(const QString &, const QVariant &authenticationToken)
{
if (m_watcher->runPlugin({ QStringLiteral("--check-code"), authenticationToken.toString() }) != HostAuthenticationInput::Success) {
QDBusContext::sendErrorReply(QDBusError::InternalError);
}
}
}
/*
* Copyright (C) 2016 Jolla Ltd
* Contact: Andrew den Exter <andrew.den.exter@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
* "Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Nemo Mobile nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
*/
#ifndef NEMODEVICELOCK_CLIHOSTVALIDATOR_H
#define NEMODEVICELOCK_CLIHOSTVALIDATOR_H
#include <nemo-devicelock/host/hostvalidator.h>
#include <QSharedDataPointer>
namespace NemoDeviceLock
{
class LockCodeWatcher;
class CliValidator : public HostValidator
{
public:
explicit CliValidator(QObject *parent = nullptr);
~CliValidator();
void verifyToken(const QString &requestor, const QVariant &authenticationToken) override;
private:
QExplicitlySharedDataPointer<LockCodeWatcher> m_watcher;
};
}
#endif
......@@ -33,6 +33,7 @@ PUBLIC_HEADERS += \
$$PWD/hostfingerprintsettings.h \
$$PWD/hostobject.h \
$$PWD/hostservice.h \
$$PWD/hostvalidator.h \
$$PWD/mcedevicelock.h
SOURCES += \
......@@ -47,6 +48,7 @@ SOURCES += \
$$PWD/hostfingerprintsettings.cpp \
$$PWD/hostobject.cpp \
$$PWD/hostservice.cpp \
$$PWD/hostvalidator.cpp \
$$PWD/mcedevicelock.cpp
include (cli/cli.pri)
......
......@@ -90,8 +90,11 @@ HostAuthenticationInput::~HostAuthenticationInput()
void HostAuthenticationInput::authenticationStarted(
Authenticator::Methods methods,
uint authenticatingPid,
AuthenticationInput::Feedback)
{
Q_UNUSED(authenticatingPid);
qCDebug(daemon, "Authentication started");
m_authenticating = true;
......@@ -109,7 +112,7 @@ void HostAuthenticationInput::startAuthentication(
const uint pid = connectionPid(QDBusContext::connection());
if (pid != 0 && !m_inputStack.isEmpty()) {
authenticationStarted(methods, feedback);
authenticationStarted(methods, pid, feedback);
NemoDBus::send(
m_inputStack.last().connection,
......
......@@ -119,6 +119,7 @@ public:
Authenticator::Methods methods);
virtual void authenticationStarted(
Authenticator::Methods methods,
uint authenticatingPid,
AuthenticationInput::Feedback feedback = AuthenticationInput::EnterSecurityCode);
void authenticationUnavailable(AuthenticationInput::Error error);
void authenticationResumed(
......@@ -132,7 +133,7 @@ public:
virtual void authenticationActive(Authenticator::Methods methods);
virtual void authenticationInactive();
virtual void confirmAuthentication() = 0;
virtual void confirmAuthentication(Authenticator::Method method) = 0;
virtual void abortAuthentication(AuthenticationInput::Error error);
// Signals
......
......@@ -99,6 +99,7 @@ HostAuthenticator::HostAuthenticator(Authenticator::Methods supportedMethods, QO
, m_adaptor(this)
, m_securityCodeAdaptor(this)
, m_repeatsRequired(0)
, m_authenticatingPid(0)
, m_state(Idle)
{
}
......@@ -136,7 +137,7 @@ void HostAuthenticator::authenticate(
switch (availability) {
case AuthenticationNotRequired:
qCDebug(daemon, "Authentication requested. Unsecured, authenticating immediately.");
confirmAuthentication();
confirmAuthentication(Authenticator::SecurityCode);
break;
case CanAuthenticateSecurityCode:
methods &= Authenticator::SecurityCode;
......@@ -237,7 +238,7 @@ void HostAuthenticator::enterSecurityCode(const QString &code)
switch ((attempts = checkCode(code))) {
case Success:
case SecurityCodeExpired:
confirmAuthentication();
confirmAuthentication(Authenticator::SecurityCode);
return;
case LockedOut:
lockedOut();
......@@ -349,7 +350,8 @@ void HostAuthenticator::setCodeFinished(int result)
m_currentCode.clear();
qCDebug(daemon, "Security code changed.");
securityCodeChanged(authenticateChallengeCode(m_challengeCode));
securityCodeChanged(authenticateChallengeCode(
m_challengeCode, Authenticator::SecurityCode, m_authenticatingPid));
break;
case SecurityCodeInHistory:
if (m_state == ChangeCanceled) {
......@@ -377,9 +379,9 @@ void HostAuthenticator::setCodeFinished(int result)
}
}
void HostAuthenticator::confirmAuthentication()
void HostAuthenticator::confirmAuthentication(Authenticator::Method method)
{
authenticated(authenticateChallengeCode(m_challengeCode));
authenticated(authenticateChallengeCode(m_challengeCode, method, m_authenticatingPid));
}
void HostAuthenticator::abortAuthentication(AuthenticationInput::Error error)
......@@ -404,10 +406,19 @@ void HostAuthenticator::abortAuthentication(AuthenticationInput::Error error)
HostAuthenticationInput::abortAuthentication(error);
}
void HostAuthenticator::authenticationStarted(
Authenticator::Methods methods, uint authenticatingPid, AuthenticationInput::Feedback feedback)
{
m_authenticatingPid = authenticatingPid;
HostAuthenticationInput::authenticationStarted(methods, authenticatingPid, feedback);
}
void HostAuthenticator::authenticationEnded(bool confirmed)
{
clearActiveClient();
m_authenticatingPid = 0;
m_challengeCode.clear();
m_state = Idle;
m_currentCode.clear();
......
......@@ -102,7 +102,8 @@ public:
// Authenticator
virtual Authenticator::Methods availableMethods() const = 0;
virtual QVariant authenticateChallengeCode(const QVariant &challengeCode) = 0;
virtual QVariant authenticateChallengeCode(
const QVariant &challengeCode, Authenticator::Method method, uint authenticatingPid) = 0;
// SecurityCodeSettings
virtual bool authorizeSecurityCodeSettings(unsigned long pid);
......@@ -118,8 +119,10 @@ public:
void requestSecurityCode() override;
void cancel() override;
void confirmAuthentication() override;
void confirmAuthentication(Authenticator::Method method) override;
void abortAuthentication(AuthenticationInput::Error error) override;
void authenticationStarted(
Authenticator::Methods methods, uint authenticatingPid, AuthenticationInput::Feedback feedback) override;
void authenticationEnded(bool confirmed) override;
void setCodeFinished(int result);
......@@ -173,6 +176,7 @@ private:
QString m_newCode;
QString m_generatedCode;
int m_repeatsRequired;
int m_authenticatingPid;
State m_state;
};
......
......@@ -45,9 +45,10 @@ HostAuthorizationAdaptor::HostAuthorizationAdaptor(HostAuthorization *authorizat
{
}
void HostAuthorizationAdaptor::RequestChallenge(const QDBusObjectPath &path)
void HostAuthorizationAdaptor::RequestChallenge(
const QDBusObjectPath &path, uint requestedMethods, uint authenticatingPid)
{
m_authorization->requestChallenge(path.path());
m_authorization->requestChallenge(path.path(), Authenticator::Methods(requestedMethods), authenticatingPid);
}
void HostAuthorizationAdaptor::RelinquishChallenge(const QDBusObjectPath &path)
......@@ -67,13 +68,14 @@ HostAuthorization::~HostAuthorization()
{
}
void HostAuthorization::requestChallenge(const QString &)
void HostAuthorization::requestChallenge(const QString &, Authenticator::Methods requestedMethods, uint)
{
if (m_allowedMethods) {
const auto methods = m_allowedMethods & requestedMethods;
if (methods) {
QDBusContext::setDelayedReply(true);
QDBusContext::connection().send(QDBusContext::message().createReply(NemoDBus::marshallArguments(
QVariant(0), uint(m_allowedMethods))));
QVariant(0), uint(methods))));
} else {
QDBusContext::sendErrorReply(QDBusError::NotSupported);
}
......
......@@ -52,7 +52,7 @@ public:
explicit HostAuthorizationAdaptor(HostAuthorization *authorization);
public slots:
void RequestChallenge(const QDBusObjectPath &path);
void RequestChallenge(const QDBusObjectPath &path, uint requestedMethods, uint authenticatingPid);
void RelinquishChallenge(const QDBusObjectPath &path);
private:
......@@ -68,7 +68,7 @@ public:
~HostAuthorization();
protected:
virtual void requestChallenge(const QString &client);
virtual void requestChallenge(const QString &client, Authenticator::Methods requestedMethods, uint authenticatingPid);
virtual void relinquishChallenge(const QString &client);
void challengeExpired(const QString &connection, const QString &client);
......
......@@ -149,7 +149,7 @@ void HostDeviceLock::enterSecurityCode(const QString &code)
case Authenticating: {
switch (const int result = checkCode(code)) {
case Success:
unlockFinished(unlockWithCode(code));
unlockFinished(unlockWithCode(code), Authenticator::SecurityCode);
break;
case SecurityCodeExpired:
m_state = EnteringNewSecurityCode;
......@@ -237,11 +237,11 @@ void HostDeviceLock::requestSecurityCode()
}
}
void HostDeviceLock::unlockFinished(int result)
void HostDeviceLock::unlockFinished(int result, Authenticator::Method method)
{
switch (result) {
case Success:
confirmAuthentication();
confirmAuthentication(method);
break;
case Evaluating:
if (m_state == Authenticating) {
......@@ -274,7 +274,7 @@ void HostDeviceLock::setCodeFinished(int result)
qCDebug(daemon, "Security code changed.");
m_currentCode.clear();
if (m_state == ChangingSecurityCode || m_state == RepeatingNewSecurityCode) {
unlockFinished(unlockWithCode(m_newCode));
unlockFinished(unlockWithCode(m_newCode), Authenticator::SecurityCode);
} else if (m_state == Canceled) {
m_state = Idle;
......@@ -329,7 +329,7 @@ void HostDeviceLock::cancel()
}
}
void HostDeviceLock::confirmAuthentication()
void HostDeviceLock::confirmAuthentication(Authenticator::Method)
{
m_state = Idle;
......
......@@ -94,7 +94,7 @@ public:
virtual bool isLocked() const = 0;
virtual void setLocked(bool locked) = 0;
void confirmAuthentication() override;
void confirmAuthentication(Authenticator::Method method) override;
void abortAuthentication(AuthenticationInput::Error error) override;
void lockedChanged();
......@@ -102,7 +102,7 @@ public:
virtual void automaticLockingChanged();
void unlockFinished(int result);
void unlockFinished(int result, Authenticator::Method method);
void setCodeFinished(int result);
// Signals
......
......@@ -39,6 +39,7 @@
#include "hostencryptionsettings.h"
#include "hostfingerprintsensor.h"
#include "hostfingerprintsettings.h"
#include "hostvalidator.h"
#include <QDBusConnection>
#include <QDBusMetaType>
......@@ -109,16 +110,17 @@ HostService::HostService(
HostEncryptionSettings *encryptionSettings,
HostFingerprintSensor *fingerprintSensor,
HostFingerprintSettings *fingerprintSettings,
HostValidator *validator,
QObject *parent)
: HostService(
QVector<HostObject *>()
<< authenticator
<< deviceLock
<< deviceLockSettings
<< deviceReset
<< encryptionSettings
<< fingerprintSensor
<< fingerprintSettings
: HostService({
authenticator,
deviceLock,
deviceLockSettings,
deviceReset,
encryptionSettings,
fingerprintSensor,
fingerprintSettings,
validator}
, parent)
{
}
......
......@@ -47,6 +47,7 @@ class HostDeviceReset;
class HostEncryptionSettings;
class HostFingerprintSensor;
class HostFingerprintSettings;
class HostValidator;
class HostObject;
class HostService : public QDBusServer
......@@ -62,6 +63,7 @@ public:
HostEncryptionSettings *encryptionSettings,
HostFingerprintSensor *fingerprintSensor,
HostFingerprintSettings *fingerprintSettings,
HostValidator *validator,
QObject *parent = nullptr);
~HostService();
......
/*
* Copyright (C) 2016 Jolla Ltd
* Contact: Andrew den Exter <andrew.den.exter@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
* "Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Nemo Mobile nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
*/
#include "hostvalidator.h"
namespace NemoDeviceLock
{
HostValidatorAdaptor::HostValidatorAdaptor(HostValidator *validator)
: QDBusAbstractAdaptor(validator)
, m_validator(validator)
{
}
void HostValidatorAdaptor::VerifyToken(
const QDBusObjectPath &path, const QDBusVariant &authenticationToken)
{
m_validator->verifyToken(path.path(), authenticationToken.variant());
}
HostValidator::HostValidator(QObject *parent)
: HostValidator(Authenticator::Methods(), parent)
{
}
HostValidator::HostValidator(Authenticator::Methods allowedMethods, QObject *parent)
: HostAuthorization(QStringLiteral("/validator"), allowedMethods, parent)
, m_adaptor(this)
{
}
HostValidator::~HostValidator()
{
}
}
/*
* Copyright (C) 2016 Jolla Ltd
* Contact: Andrew den Exter <andrew.den.exter@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
* "Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Nemo Mobile nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
*/
#ifndef NEMODEVICELOCK_HOSTVALIDATOR_H
#define NEMODEVICELOCK_HOSTVALIDATOR_H
#include <nemo-devicelock/validator.h>
#include <nemo-devicelock/host/hostauthorization.h>
#include <QDBusVariant>
namespace NemoDeviceLock
{
class HostValidator;
class HostValidatorAdaptor : public QDBusAbstractAdaptor
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.nemomobile.devicelock.Validator")
public:
explicit HostValidatorAdaptor(HostValidator *validator);
public slots:
void VerifyToken(const QDBusObjectPath &path, const QDBusVariant &authenticationToken);
private:
HostValidator * const m_validator;
};
class HostValidator : public HostAuthorization
{
Q_OBJECT
public:
explicit HostValidator(QObject *parent = nullptr);
explicit HostValidator(Authenticator::Methods allowedMethods, QObject *parent = nullptr);
~HostValidator();
protected:
virtual void verifyToken(const QString &client, const QVariant &authenticationToken) = 0;
private:
friend class HostValidatorAdaptor;
HostValidatorAdaptor m_adaptor;
};
}
#endif
......@@ -31,7 +31,8 @@ PUBLIC_HEADERS += \
encryptionsettings.h \
fingerprintsensor.h \
global.h \
securitycodesettings.h
securitycodesettings.h \
validator.h
SOURCES += \
authenticationinput.cpp \
......@@ -42,7 +43,8 @@ SOURCES += \
devicereset.cpp \
encryptionsettings.cpp \
fingerprintsensor.cpp \
securitycodesettings.cpp
securitycodesettings.cpp \
validator.cpp
include(private/private.pri)
......
......@@ -32,6 +32,9 @@
#include "clientauthorization.h"
#include <QCoreApplication>
namespace NemoDeviceLock
{
......@@ -56,6 +59,8 @@ ClientAuthorization::ClientAuthorization(
QStringLiteral("org.nemomobile.devicelock.Authorization"),