Go to the documentation of this file.
33 #undef ZYPP_BASE_LOGGER_LOGGROUP
34 #define ZYPP_BASE_LOGGER_LOGGROUP "zypp::gpg"
42 inline bool isExpired(
const Date & expires_r )
43 {
return( expires_r && expires_r <
Date::now() ); }
45 inline int hasDaysToLive(
const Date & expires_r )
51 if ( exp < 0 ) ret -= 1;
57 inline std::string expiresDetail(
const Date & expires_r )
63 str <<
_(
"does not expire");
65 else if ( isExpired( expires_r ) )
68 str << ( str::Format(
_(
"expired: %1%") ) % expires_r.printDate() );
73 str << ( str::Format(
_(
"expires: %1%") ) % expires_r.printDate() );
78 inline std::string expiresDetailVerbose(
const Date & expires_r )
82 return _(
"(does not expire)");
84 std::string ret( expires_r.asString() );
85 int ttl( hasDaysToLive( expires_r ) );
91 ret +=
_(
"(EXPIRED)");
95 ret +=
_(
"(expires within 24h)");
99 ret +=
str::form(
PL_(
"(expires in %d day)",
"(expires in %d days)", ttl ), ttl );
105 std::string keyAlgoName(
const gpgme_subkey_t & key_r )
108 if (
const char * n = ::gpgme_pubkey_algo_name( key_r->pubkey_algo ) )
109 ret = str::Str() << n <<
' ' << key_r->length;
134 friend Impl * rwcowClone<Impl>(
const Impl * rhs );
141 static shared_ptr<Impl> _nullimpl(
new Impl );
147 return new Impl( *
this );
169 PublicSubkeyData::operator
bool()
const
170 {
return !_pimpl->_id.empty(); }
209 bool hasSubkeyId(
const std::string & id_r )
const;
214 static shared_ptr<Impl>
fromGpgmeKey(gpgme_key_t rawData);
217 friend Impl * rwcowClone<Impl>(
const Impl * rhs );
227 if ( sub.id() == id_r )
238 static shared_ptr<Impl> _nullimpl(
new Impl );
247 gpgme_subkey_t sKey = rawData->subkeys;
249 shared_ptr<PublicKeyData::Impl> data(
new Impl);
251 if ( rawData->uids && rawData->uids->signatures ) {
252 data->_created =
zypp::Date(rawData->uids->signatures->timestamp);
256 for (
auto t = rawData->uids->signatures->next; t; t = t->next ) {
257 if ( t->timestamp > data->_created )
258 data->_created = t->timestamp;
266 data->_algoName = keyAlgoName( sKey );
287 return new Impl( *
this );
308 PublicKeyData::operator
bool()
const
309 {
return !_pimpl->_fingerprint.empty(); }
352 str <<
", " << sub.id();
364 if ( id_r.size() == 8 )
374 str <<
"[" << obj.
name() <<
"]" << endl;
376 str <<
" id " << obj.
id() << endl;
381 for (
auto && sub : obj.
_pimpl->_subkeys )
382 str <<
" sub " << sub << endl;
404 MIL <<
"Taking pubkey from " << keyFile_r <<
" of size " << info.
size() <<
" and sha1 " <<
filesystem::checksum(keyFile_r,
"sha1") << endl;
426 WAR <<
"Invalid PublicKeyData supplied: scanning from file" << endl;
453 switch ( keys.size() )
466 WAR <<
"File " <<
path().
asString() <<
" contains multiple keys: " << keys << endl;
485 static shared_ptr<Impl> _nullimpl(
new Impl );
490 friend Impl * rwcowClone<Impl>(
const Impl * rhs );
493 {
return new Impl( *
this ); }
501 : _pimpl(
Impl::nullimpl() )
505 : _pimpl( new
Impl( file ) )
509 : _pimpl( new
Impl( sharedfile ) )
513 : _pimpl( new
Impl( sharedfile, keyData_r ) )
517 : _pimpl( new
Impl( keyData_r ) )
575 {
return sid ==
id(); }
shared_ptr< filesystem::TmpFile > _dontUseThisPtrDirectly
const Pathname & path() const
Return current Pathname.
std::string hexstring(char n, int w=4)
bool isExist() const
Return whether valid stat info exists.
Date created() const
Creation date.
Base class for Exception.
bool expired() const
Whether the key has expired.
const std::list< PublicKeyData > & hiddenKeys() const
Additional keys data in case the ASCII armored blob containes multiple keys.
Impl * clone() const
clone for RWCOW_pointer
const PublicKeyData & keyData() const
The public keys data (.
static const ValueType day
Date expires() const
Expiry date, or Date() if the key never expires.
#define PL_(MSG1, MSG2, N)
Class representing a GPG Public Keys subkeys.
std::string asString() const
Simple string representation.
Class representing one GPG Public Keys data.
std::string asString() const
Simple string representation.
Impl(const filesystem::TmpFile &sharedFile_r, const PublicKeyData &keyData_r)
int daysToLive() const
Number of days (24h) until the key expires (or since it exired).
Date created() const
Creation / last modification date (latest selfsig).
RWCOW_pointer< Impl > _pimpl
PublicSubkeyData()
Default constructed: empty data.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
bool operator==(const SetRelation::Enum &lhs, const SetCompare &rhs)
This is an overloaded member function, provided for convenience. It differs from the above function o...
@ language
language support
bool expired() const
Whether the key has expired.
std::list< PublicKeyData > _hiddenKeys
Date expires() const
Expiry date, or Date() if the key never expires.
std::string printDate(DateFormat dateFormat_r=DateFormat::calendar, TimeBase base_r=TB_LOCALTIME) const
Convenience for printing the date only ['2014-02-07'] The default is DateFormat::calendar and TB_LOCA...
Iterable< SubkeyIterator > subkeys() const
Iterate any subkeys.
RWCOW_pointer< Impl > _pimpl
std::list< PublicKeyData > readKeyFromFile(const Pathname &file)
Returns a list of all PublicKeyData found in file.
PublicKeyData implementation.
std::string gpgPubkeyRelease() const
Gpg-pubkey release as computed by rpm (hexencoded created)
std::string expiresAsString() const
static shared_ptr< Impl > fromGpgmeKey(gpgme_key_t rawData)
PublicSubkeyData implementation.
bool operator==(const PublicKey &rhs) const
std::string expiresAsString() const
std::string rpmName() const
Random art fingerprint visualization Visualize fingerprint data on a [17x9] (SSH) or [19x11] (GPG) or...
PublicKeyData()
Default constructed: empty data.
Wrapper class for ::stat/::lstat.
static KeyManagerCtx createForOpenPGP()
Creates a new KeyManagerCtx for PGP using a volatile temp.
Provide a new empty temporary file and delete it when no longer needed.
std::string algoName() const
Key algorithm string like RSA 2048
static shared_ptr< Impl > nullimpl()
Offer default Impl.
Impl * clone() const
clone for RWCOW_pointer
static shared_ptr< Impl > nullimpl()
Offer default Impl.
std::string gpgPubkeyVersion() const
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
Impl(const Pathname &keyFile_r)
std::string name() const
Key name.
std::string checksum(const Pathname &file, const std::string &algorithm)
Compute a files checksum.
std::vector< PublicSubkeyData > _subkeys
int daysToLive() const
Number of days (24h) until the key expires (or since it exired).
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Easy-to use interface to the ZYPP dependency resolver.
std::string toLower(const std::string &s)
Return lowercase version of s.
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
bool providesKey(const std::string &id_r) const
Whether id_r is the id of the primary key or of a subkey.
PublicKey implementation.
Impl * clone() const
clone for RWCOW_pointer
Impl(const PublicKeyData &keyData_r)
bool hasSubkeyId(const std::string &id_r) const
std::string fingerprint() const
Class representing one GPG Public Key (PublicKeyData + ASCII armored in a tempfile).
std::string gpgPubkeyRelease() const
std::string fingerprint() const
Key fingerprint.
Store and operate on date (time_t).
Pathname path() const
File containig the ASCII armored key.
Exception thrown when the supplied key is not a valid gpg key.
const std::string & asString(const std::string &t)
Global asString() that works with std::string too.
static PublicKeyData fromGpgmeKey(_gpgme_key *data)
bool endsWithCI(const C_Str &str_r, const C_Str &prefix_r)
bool hasSubkeys() const
Whether subkeys is not empty.
static Date now()
Return the current time.
std::string id() const
Subkey ID.
AsciiArt asciiArt() const
Random art fingerprint visualization (base::DrunkenBishop).
std::string asString() const
static shared_ptr< Impl > nullimpl()
Offer default Impl.
String related utilities and Regular expression matching.
Impl(const filesystem::TmpFile &sharedFile_r)
std::string rpmName() const
Gpg-pubkey name as computed by rpm.
int hardlinkCopy(const Pathname &oldpath, const Pathname &newpath)
Create newpath as hardlink or copy of oldpath.
const std::list< PublicKeyData > & hiddenKeys() const
const std::string & asString() const
String representation.
std::string gpgPubkeyVersion() const
Gpg-pubkey version as computed by rpm (trailing 8 byte id)
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
std::string algoName() const
const PublicKeyData & keyData() const
base::DrunkenBishop AsciiArt
Random art fingerprint visualization type (base::DrunkenBishop).
std::string id() const
Key ID.