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

KDE's Doxygen guidelines are available online.