Plasma
#include <credentials.h>
Public Member Functions | |
Credentials () | |
Credentials (const Credentials &other) | |
~Credentials () | |
bool | canSign () const |
QString | id () const |
bool | isValid () const |
bool | isValidSignature (const QByteArray &signature, const QByteArray &message) |
QString | name () const |
Credentials & | operator= (const Credentials &other) |
QByteArray | signMessage (const QByteArray &message) |
Credentials | toPublicCredentials () const |
TrustLevel | trustLevel () const |
Static Public Member Functions | |
static Credentials | createCredentials (const QString &name) |
Friends | |
QDataStream & | operator<< (QDataStream &, const Credentials &) |
QDataStream & | operator>> (QDataStream &, Credentials &) |
Detailed Description
This class encapsules someone's identity.
It contains a unique id that identifies the machine an incoming connection is coming from, it's name (which is not necesarily unique and/or trusted), a public key used to validate messages coming from the machine with this identity, and in the future the possibility to determine whether or not this identity can be trusted based on mechanisms different then pin pairing, e.g. a signature of the key that can be verified by a gpg trusted key.
Definition at line 42 of file credentials.h.
Constructor & Destructor Documentation
Plasma::Credentials::Credentials | ( | ) |
Default constructor.
Definition at line 82 of file credentials.cpp.
Plasma::Credentials::Credentials | ( | const Credentials & | other | ) |
Copy constructor.
Definition at line 87 of file credentials.cpp.
Plasma::Credentials::~Credentials | ( | ) |
Definition at line 93 of file credentials.cpp.
Member Function Documentation
bool Plasma::Credentials::canSign | ( | ) | const |
- Returns
- whether or not this identity can be used for signing a message (whether or not it includes a public key)
Definition at line 193 of file credentials.cpp.
|
static |
Create a new identity with a new set of random public/private keys.
Definition at line 104 of file credentials.cpp.
QString Plasma::Credentials::id | ( | ) | const |
- Returns
- an id to identify this identity. I use a Hash of the public key as ID. This way we don't have to send the complete public key with every message.
Definition at line 163 of file credentials.cpp.
bool Plasma::Credentials::isValid | ( | ) | const |
- Returns
- whether or not this is a null identity or an invalid one (hash of key doesn't match id). Maybe isValid() is a better name?
Definition at line 138 of file credentials.cpp.
bool Plasma::Credentials::isValidSignature | ( | const QByteArray & | signature, |
const QByteArray & | message | ||
) |
- Returns
- whether or not
signature
is correct formessage
.
Definition at line 168 of file credentials.cpp.
QString Plasma::Credentials::name | ( | ) | const |
- Returns
- the name of this identity. There's however no guarantee that if the name returns e.g. "Santa Claus", this message is actually from Mr. Claus, except if trustLevel returns a sufficiently high trust level.
Definition at line 158 of file credentials.cpp.
Credentials & Plasma::Credentials::operator= | ( | const Credentials & | other | ) |
Definition at line 98 of file credentials.cpp.
QByteArray Plasma::Credentials::signMessage | ( | const QByteArray & | message | ) |
- Returns
- the signature for the message.
Definition at line 207 of file credentials.cpp.
Credentials Plasma::Credentials::toPublicCredentials | ( | ) | const |
- Returns
- a Credentials stripped from any private key, so you can be sure it is save to send to somebody.
Definition at line 227 of file credentials.cpp.
TrustLevel Plasma::Credentials::trustLevel | ( | ) | const |
- Returns
- whether or not this identity can be trusted based on e.g. having the key signed with a trusted GPG key (not yet implemented) or having the key in a designated folder on disk (about to be impl.). If this function returns false, your shell should always instatiate pin pairing before allowing a connection from an untrusted source (AuthorizationRule::PinRequired flag should be set on the rule with setRules).
QString pemFile = KStandardDirs::locate("trustedkeys", id());
if (!pemFile.isEmpty()) { QCA::PublicKey pubKey = QCA::PublicKey::fromPEMFile(pemFile); if (pubKey == d->publicKey) { return true; } }
Definition at line 122 of file credentials.cpp.
Friends And Related Function Documentation
|
friend |
Streaming operators for sending/storing identities.
Definition at line 238 of file credentials.cpp.
|
friend |
Definition at line 262 of file credentials.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:23:12 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.