Kleo::KeyResolver

Search for usage in LXR

Kleo::KeyResolver Class Reference

#include <keyresolver.h>

Public Member Functions

 KeyResolver (bool encToSelf, bool showApproval, bool oppEncryption, unsigned int format, const std::shared_ptr< Kleo::ExpiryChecker > &expiryChecker)
 
Action checkEncryptionPreferences (bool encryptionRequested) const
 
Action checkSigningPreferences (bool signingRequested) const
 
std::vector< SplitInfo > encryptionItems (CryptoMessageFormat f) const
 
std::vector< GpgME::Key > encryptToSelfKeysFor (CryptoMessageFormat f) const
 
Kleo::Result resolveAllKeys (bool &signingRequested, bool &encryptionRequested)
 
void setAkonadiLookupEnabled (bool akonadiLookupEnabled)
 
void setAutocryptEnabled (bool autocryptEnabled)
 
void setContactPreferences (const QString &address, const MessageComposer::ContactPreference &preference)
 
Kleo::Result setEncryptToSelfKeys (const QStringList &fingerprints)
 
void setPrimaryRecipients (const QStringList &addresses)
 
void setSecondaryRecipients (const QStringList &addresses)
 
Kleo::Result setSigningKeys (const QStringList &fingerprints)
 
std::vector< GpgME::Key > signingKeys (CryptoMessageFormat f) const
 
std::map< QByteArray, QStringuseAutocrypt () const
 

Detailed Description

A class to resolve signing/encryption keys w.r.t.

per-recipient preferences

1: Set the information needed

The constructor takes some basic options as arguments, such as whether or not encryption was actually requested. Recipient and sender information is then set by using setEncryptToSelfKeys(), setSigningKeys(), setPrimaryRecipients() (To/Cc) and setSecondaryRecipients() (Bcc).

1: Set the information needed

First, checkSigningPreferences() goes through all recipient's signing preferences, to determine whether or not to sign. It also takes into account the available signing keys and whether or not the user explicitly requested signing.

checkEncryptionPreferences() does the same for encryption preferences. If opportunistic encryption is enabled, recipients without encryption preferences set are treated as if they had a preference of AskWheneverPossible.

In both cases an Action code is returned, with the following meanings:

Conflict

A conflict was detected. E.g. one recipient's preference was set to "always encrypt", while another one's preference was set to "never encrypt". You should ask the user what to do.

DoIt, DontDoIt

Do/Don't sign/encrypt

Ask

(Some) crypto preferences request to prompt the user, so do it.

Impossible
Signing or encryption is impossible, e.g. due to missing keys or unsupported formats.

1: Set the information needed

In case signing or encryption was implicitly or explicitly requested by the user, resolveAllKeys() tries to find signing keys for each required format, as well as encryption keys for all recipients (incl. the sender, if encrypt-to-self is set).

1: Set the information needed

If, after key resolving, signing is still requested and apparently possible, you can get the result of all this by iterating over the available message formats and retrieving the set of signing keys to use with a call to signingKeys().

1: Set the information needed

If after key resolving, encryption is still requested and apparently possible, you can get the result of all this by calling encryptionItems() with the current message format at hand as its argument.

This will return a list of recipient-list/key-list pairs that each describe a copy of the (possibly signed) message to be encrypted independently.

Note that it's only necessary to sign the message once for each message format, although it might be necessary to create more than one message when encrypting. This is because encryption allows the recipients to learn about the other recipients the message was encrypted to, so each secondary (BCC) recipient need a copy of it's own to hide the other secondary recipients.

Definition at line 114 of file keyresolver.h.

Constructor & Destructor Documentation

◆ KeyResolver()

Kleo::KeyResolver::KeyResolver ( bool encToSelf,
bool showApproval,
bool oppEncryption,
unsigned int format,
const std::shared_ptr< Kleo::ExpiryChecker > & expiryChecker )

Definition at line 623 of file keyresolver.cpp.

Member Function Documentation

◆ checkEncryptionPreferences()

Kleo::Action Kleo::KeyResolver::checkEncryptionPreferences ( bool encryptionRequested) const

Determine whether to encrypt or not, depending on the per-recipient encryption preferences, as well as the availability of usable encryption keys.

Definition at line 797 of file keyresolver.cpp.

◆ checkSigningPreferences()

Kleo::Action Kleo::KeyResolver::checkSigningPreferences ( bool signingRequested) const

Determine whether to sign or not, depending on the per-recipient signing preferences, as well as the availability of usable signing keys.

Definition at line 771 of file keyresolver.cpp.

◆ encryptionItems()

std::vector< Kleo::KeyResolver::SplitInfo > Kleo::KeyResolver::encryptionItems ( CryptoMessageFormat f) const
Returns
the found distinct sets of items for format f. The returned vector will contain more than one item only if secondary recipients have been specified.

Definition at line 1392 of file keyresolver.cpp.

◆ encryptToSelfKeysFor()

std::vector< GpgME::Key > Kleo::KeyResolver::encryptToSelfKeysFor ( CryptoMessageFormat f) const

Definition at line 1174 of file keyresolver.cpp.

◆ resolveAllKeys()

Kleo::Result Kleo::KeyResolver::resolveAllKeys ( bool & signingRequested,
bool & encryptionRequested )

Queries the user for missing keys and displays a key approval dialog if needed.

Definition at line 852 of file keyresolver.cpp.

◆ setAkonadiLookupEnabled()

void Kleo::KeyResolver::setAkonadiLookupEnabled ( bool akonadiLookupEnabled)

Disable ContactSearchJob in KeyResolver.

A usecase is that ests won't fireup an Akonadi instance only for this feature. @default is true: The ContactSearchJob is executed.

Definition at line 1409 of file keyresolver.cpp.

◆ setAutocryptEnabled()

void Kleo::KeyResolver::setAutocryptEnabled ( bool autocryptEnabled)

If Autocrypt keys are used to find valid PGP Keys.

Definition at line 1399 of file keyresolver.cpp.

◆ setContactPreferences()

void Kleo::KeyResolver::setContactPreferences ( const QString & address,
const MessageComposer::ContactPreference & preference )

Sets crypto preferences for given email address.

This is an alternative to setting crypto preferences for a contact when Akonadi lookup is disabled - useful mostly for testing cases when it's not possible to index contacts on demand.

Definition at line 1669 of file keyresolver.cpp.

◆ setEncryptToSelfKeys()

Kleo::Result Kleo::KeyResolver::setEncryptToSelfKeys ( const QStringList & fingerprints)

Set the fingerprints of keys to be used for encrypting to self.

Also looks them up and complains if they're not usable or found.

Definition at line 635 of file keyresolver.cpp.

◆ setPrimaryRecipients()

void Kleo::KeyResolver::setPrimaryRecipients ( const QStringList & addresses)

Set the list of primary (To/CC) recipient addresses.

Also looks up possible keys, but doesn't interact with the user.

Definition at line 724 of file keyresolver.cpp.

◆ setSecondaryRecipients()

void Kleo::KeyResolver::setSecondaryRecipients ( const QStringList & addresses)

Set the list of secondary (BCC) recipient addresses.

Also looks up possible keys, but doesn't interact with the user.

Definition at line 729 of file keyresolver.cpp.

◆ setSigningKeys()

Kleo::Result Kleo::KeyResolver::setSigningKeys ( const QStringList & fingerprints)

Set the fingerprints of keys to be used for signing.

Also looks them up and complains if they're not usable or found.

Definition at line 683 of file keyresolver.cpp.

◆ signingKeys()

std::vector< GpgME::Key > Kleo::KeyResolver::signingKeys ( CryptoMessageFormat f) const
Returns
the signing keys to use (if any) for the given message format.

Definition at line 1414 of file keyresolver.cpp.

◆ useAutocrypt()

std::map< QByteArray, QString > Kleo::KeyResolver::useAutocrypt ( ) const

Definition at line 1404 of file keyresolver.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:12:44 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.