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);
258 data->_algoName = keyAlgoName( sKey );
279 return new Impl( *
this );
300 PublicKeyData::operator
bool()
const
301 {
return !_pimpl->_fingerprint.empty(); }
344 str <<
", " << sub.id();
356 if ( id_r.size() == 8 )
366 str <<
"[" << obj.
name() <<
"]" << endl;
368 str <<
" id " << obj.
id() << endl;
369 str <<
" alg " << obj.
algoName() << endl;
373 for (
auto && sub : obj.
_pimpl->_subkeys )
374 str <<
" sub " << sub << endl;
392 Impl(
const Pathname & keyFile_r )
395 PathInfo info( keyFile_r );
396 MIL <<
"Taking pubkey from " << keyFile_r <<
" of size " << info.size() <<
" and sha1 " <<
filesystem::checksum(keyFile_r,
"sha1") << endl;
398 if ( !info.isExist() )
399 ZYPP_THROW(
Exception(
"Can't read public key from " + keyFile_r.asString() +
", file not found"));
402 ZYPP_THROW(
Exception(
"Can't copy public key data from " + keyFile_r.asString() +
" to " +
path().asString() ));
418 WAR <<
"Invalid PublicKeyData supplied: scanning from file" << endl;
441 PathInfo info(
path() );
442 MIL <<
"Reading pubkey from " << info.path() <<
" of size " << info.size() <<
" and sha1 " <<
filesystem::checksum(info.path(),
"sha1") << endl;
445 switch ( keys.size() )
458 WAR <<
"File " <<
path().asString() <<
" contains multiple keys: " << keys << endl;
465 MIL <<
"Read pubkey from " << info.path() <<
": " <<
_keyData << endl;
477 static shared_ptr<Impl> _nullimpl(
new Impl );
482 friend Impl * rwcowClone<Impl>(
const Impl * rhs );
485 {
return new Impl( *
this ); }
493 : _pimpl(
Impl::nullimpl() )
497 : _pimpl( new
Impl( file ) )
501 : _pimpl( new
Impl( sharedfile ) )
505 : _pimpl( new
Impl( sharedfile, keyData_r ) )
509 : _pimpl( new
Impl( keyData_r ) )
567 {
return sid ==
id(); }