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,
37 const QDBusConnection &connection,
38 const QDBusMessage &message);
39
40 KWalletFreedesktopService *fdoService() const;
41
42 QByteArray negotiationOutput() const;
43 bool encrypt(const QDBusMessage &message, FreedesktopSecret &secret) const;
44 bool decrypt(const QDBusMessage &message, FreedesktopSecret &secret) const;
45
46private Q_SLOTS:
47 void slotServiceOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner);
48
49private:
50 class KWalletFreedesktopService *m_service;
51 std::unique_ptr<KWalletFreedesktopSessionAlgorithm> m_algorithm;
52 QString m_sessionPath;
53 QString m_serviceBusName;
54 QDBusServiceWatcher m_serviceWatcher;
55
56 /* Freedesktop API */
57
58 /* org.freedesktop.Secret.Session methods */
59public Q_SLOTS:
60 void Close();
61};
62
63class KWalletFreedesktopSessionAlgorithmPlain : public KWalletFreedesktopSessionAlgorithm
64{
65public:
66 QByteArray negotiationOutput() const override;
67 bool encrypt(FreedesktopSecret &secret) const override;
68 bool decrypt(FreedesktopSecret &secret) const override;
69};
70
71class KWalletFreedesktopSessionAlgorithmDhAes : public KWalletFreedesktopSessionAlgorithm
72{
73public:
74 KWalletFreedesktopSessionAlgorithmDhAes(const QCA::PublicKey &publicKey, QCA::SymmetricKey symmetricKey);
75
76 QByteArray negotiationOutput() const override;
77 bool encrypt(FreedesktopSecret &secret) const override;
78 bool decrypt(FreedesktopSecret &secret) const override;
79
80private:
81 QCA::PublicKey m_publicKey;
82 QCA::SymmetricKey m_symmetricKey;
83};
84
85#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-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:48:58 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.