Plasma
Plasma::Credentials Class Reference
This class encapsules someone's identity. More...
#include <credentials.h>
Public Member Functions | |
| Credentials (const Credentials &other) | |
| Credentials () | |
| ~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 41 of file credentials.h.
Constructor & Destructor Documentation
| Plasma::Credentials::Credentials | ( | ) |
Default constructor.
Definition at line 81 of file credentials.cpp.
| Plasma::Credentials::Credentials | ( | const Credentials & | other | ) |
Copy constructor.
Definition at line 86 of file credentials.cpp.
| Plasma::Credentials::~Credentials | ( | ) |
Definition at line 92 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 192 of file credentials.cpp.
| Credentials Plasma::Credentials::createCredentials | ( | const QString & | name | ) | [static] |
Create a new identity with a new set of random public/private keys.
Definition at line 103 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 162 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 137 of file credentials.cpp.
| bool Plasma::Credentials::isValidSignature | ( | const QByteArray & | signature, | |
| const QByteArray & | message | |||
| ) |
- Returns:
- wheter or not
signatureis correct formessage.
Definition at line 167 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 157 of file credentials.cpp.
| Credentials & Plasma::Credentials::operator= | ( | const Credentials & | other | ) |
Definition at line 97 of file credentials.cpp.
| QByteArray Plasma::Credentials::signMessage | ( | const QByteArray & | message | ) |
- Returns:
- the signature for the message.
Definition at line 206 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 226 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 121 of file credentials.cpp.
Friends And Related Function Documentation
| QDataStream& operator<< | ( | QDataStream & | , | |
| const Credentials & | ||||
| ) | [friend] |
| QDataStream& operator>> | ( | QDataStream & | , | |
| Credentials & | ||||
| ) | [friend] |
The documentation for this class was generated from the following files:
KDE 4.4 API Reference