File indexing completed on 2024-12-01 09:47:26

0001 /*
0002     SPDX-FileCopyrightText: 2008 Nicola Gigante <nicola.gigante@gmail.com>
0003     SPDX-FileCopyrightText: 2009-2010 Dario Freddi <drf@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.1-or-later
0006 */
0007 
0008 #ifndef KAUTH_AUTH_BACKEND_H
0009 #define KAUTH_AUTH_BACKEND_H
0010 
0011 #include <QObject>
0012 
0013 #include "action.h"
0014 
0015 namespace KAuth
0016 {
0017 typedef Action::DetailsMap DetailsMap;
0018 
0019 class AuthBackend : public QObject
0020 {
0021     Q_OBJECT
0022     Q_DISABLE_COPY(AuthBackend)
0023 
0024 public:
0025     enum Capability {
0026         NoCapability = 0,
0027         AuthorizeFromClientCapability = 1,
0028         AuthorizeFromHelperCapability = 2,
0029         CheckActionExistenceCapability = 4,
0030         PreAuthActionCapability = 8,
0031     };
0032     Q_DECLARE_FLAGS(Capabilities, Capability)
0033 
0034     enum ExtraCallerIDVerificationMethod {
0035         NoExtraCallerIDVerificationMethod,
0036         VerifyAgainstDBusServiceName,
0037         VerifyAgainstDBusServicePid,
0038     };
0039 
0040     AuthBackend();
0041     ~AuthBackend() override;
0042     virtual void setupAction(const QString &action) = 0;
0043     virtual void preAuthAction(const QString &action, QWidget *parent);
0044     virtual Action::AuthStatus authorizeAction(const QString &action) = 0;
0045     virtual Action::AuthStatus actionStatus(const QString &action) = 0;
0046     virtual QByteArray callerID() const = 0;
0047     virtual ExtraCallerIDVerificationMethod extraCallerIDVerificationMethod() const;
0048     virtual bool isCallerAuthorized(const QString &action, const QByteArray &callerID, const QVariantMap &details) = 0;
0049     virtual bool actionExists(const QString &action);
0050     virtual QVariantMap backendDetails(const DetailsMap &details);
0051 
0052     Capabilities capabilities() const;
0053 
0054 protected:
0055     void setCapabilities(Capabilities capabilities);
0056 
0057 Q_SIGNALS:
0058     void actionStatusChanged(const QString &action, KAuth::Action::AuthStatus status);
0059 
0060 private:
0061     class Private;
0062     Private *const d;
0063 };
0064 
0065 Q_DECLARE_OPERATORS_FOR_FLAGS(AuthBackend::Capabilities)
0066 
0067 } // namespace Auth
0068 
0069 Q_DECLARE_INTERFACE(KAuth::AuthBackend, "org.kde.kf5auth.AuthBackend/0.1")
0070 
0071 #endif