KWallet

kwalletfreedesktopsession.h
1/*
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: 2021 Slava Aseev <nullptrnine@basealt.ru>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7#ifndef _KWALLETFREEDESKTOPSESSION_H_
8#define _KWALLETFREEDESKTOPSESSION_H_
9
10#include "kwalletfreedesktopservice.h"
11#include <QDBusContext>
12#include <QDBusObjectPath>
13#include <QDBusServiceWatcher>
14#include <QtCrypto>
15
16#define FDO_SECRETS_SESSION_PATH FDO_SECRETS_SERVICE_OBJECT "/session/"
17
18class KWalletD;
19
20class KWalletFreedesktopSessionAlgorithm
21{
22public:
23 virtual ~KWalletFreedesktopSessionAlgorithm() = default;
24 virtual QByteArray negotiationOutput() const = 0;
25 virtual bool encrypt(FreedesktopSecret &secret) const = 0;
26 virtual bool decrypt(FreedesktopSecret &secret) const = 0;
27};
28
29class KWalletFreedesktopSession : public QObject, protected QDBusContext
30{
32
33public:
34 KWalletFreedesktopSession(class KWalletFreedesktopService *parent,
35 std::unique_ptr<KWalletFreedesktopSessionAlgorithm> algorithm,
36 QString sessionPath,
38 const QDBusMessage &message);
39
40 KWalletFreedesktopSession(const KWalletFreedesktopSession &) = delete;
41 KWalletFreedesktopSession &operator=(const KWalletFreedesktopSession &) = delete;
42
43 KWalletFreedesktopSession(KWalletFreedesktopSession &&) = delete;
44 KWalletFreedesktopSession &operator=(KWalletFreedesktopSession &&) = delete;
45
46 KWalletFreedesktopService *fdoService() const;
47 KWalletD *backend() const;
48 QDBusObjectPath fdoObjectPath() const;
49
50 QByteArray negotiationOutput() const;
51 bool encrypt(const QDBusMessage &message, FreedesktopSecret &secret) const;
52 bool decrypt(const QDBusMessage &message, FreedesktopSecret &secret) const;
53
54private Q_SLOTS:
55 void slotServiceOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner);
56
57private:
58 class KWalletFreedesktopService *m_service;
59 std::unique_ptr<KWalletFreedesktopSessionAlgorithm> m_algorithm;
60 QString m_sessionPath;
61 QString m_serviceBusName;
62 QDBusServiceWatcher m_serviceWatcher;
63
64 /* Freedesktop API */
65
66 /* org.freedesktop.Secret.Session methods */
67public Q_SLOTS:
68 void Close();
69};
70
71class KWalletFreedesktopSessionAlgorithmPlain : public KWalletFreedesktopSessionAlgorithm
72{
73public:
74 QByteArray negotiationOutput() const override;
75 bool encrypt(FreedesktopSecret &secret) const override;
76 bool decrypt(FreedesktopSecret &secret) const override;
77};
78
79class KWalletFreedesktopSessionAlgorithmDhAes : public KWalletFreedesktopSessionAlgorithm
80{
81public:
82 KWalletFreedesktopSessionAlgorithmDhAes(const QCA::PublicKey &publicKey, QCA::SymmetricKey symmetricKey);
83
84 QByteArray negotiationOutput() const override;
85 bool encrypt(FreedesktopSecret &secret) const override;
86 bool decrypt(FreedesktopSecret &secret) const override;
87
88private:
89 QCA::PublicKey m_publicKey;
90 QCA::SymmetricKey m_symmetricKey;
91};
92
93#endif
QDBusConnection connection() const const
const QDBusMessage & message() const const
Q_OBJECTQ_OBJECT
Q_SLOTSQ_SLOTS
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:06 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.