53 static shared_ptr<Impl> _nullimpl(
new Impl );
58 friend Impl * rwcowClone<Impl>(
const Impl * rhs );
61 {
return new Impl( *
this ); }
70 : _pimpl(
Impl::nullimpl() )
76 PublicKeyData::operator bool()
const
77 {
return !_pimpl->_fingerprint.empty(); }
111 return _(
"(does not expire)");
120 ret +=
_(
"(EXPIRED)");
124 ret +=
_(
"(expires within 24h)");
128 ret +=
str::form(
_PL(
"(expires in %d day)",
"(expires in %d days)", ttl ), ttl );
142 return str::form(
"[%s-%s] [%s] [%s] [TTL %d]",
152 str <<
"[" << obj.
name() <<
"]" << endl;
154 str <<
" id " << obj.
id() << endl;
180 void scan( std::string & line_r, std::list<PublicKeyData> & keys_r )
190 if ( line_r.empty() )
197 #define DOTEST( C1, C2, C3, E ) case C1: if ( line_r[1] == C2 && line_r[2] == C3 && line_r[3] == ':' ) _parseEntry = E; break
207 if ( line_r[line_r.size()-1] ==
'\n' )
208 line_r.erase( line_r.size()-1 );
220 key = &keys_r.back();
221 key->_pimpl->_id =
_words[4];
223 key->_pimpl->_created =
Date(str::strtonum<Date::ValueType>(
_words[5]));
224 key->_pimpl->_expires =
Date(str::strtonum<Date::ValueType>(
_words[6]));
231 Date cdate(str::strtonum<Date::ValueType>(
_words[5]));
232 if ( key->_pimpl->_created < cdate )
233 key->_pimpl->_created = cdate;
238 if ( key->_pimpl->_fingerprint.empty() )
239 key->_pimpl->_fingerprint =
_words[9];
243 if ( !
_words[9].empty() )
278 Impl(
const Pathname & keyFile_r )
280 PathInfo info( keyFile_r );
281 MIL <<
"Taking pubkey from " << keyFile_r <<
" of size " << info.size() <<
" and sha1 " <<
filesystem::checksum(keyFile_r,
"sha1") << endl;
283 if ( !info.isExist() )
284 ZYPP_THROW(
Exception(
"Can't read public key from " + keyFile_r.asString() +
", file not found"));
302 WAR <<
"Invalid PublicKeyData supplied: scanning from file" << endl;
321 MIL <<
"Reading pubkey from " << info.path() <<
" of size " << info.size() <<
" and sha1 " <<
filesystem::checksum(info.path(),
"sha1") << endl;
328 "--no-default-keyring",
330 "--with-fingerprint",
348 scanner.
scan( line );
352 switch ( scanner.
_keys.size() )
367 scanner.
_keys.pop_back();
372 MIL <<
"Read pubkey from " << info.path() <<
": " <<
_keyData << endl;
384 static shared_ptr<Impl> _nullimpl(
new Impl );
389 friend Impl * rwcowClone<Impl>(
const Impl * rhs );
392 {
return new Impl( *
this ); }
400 : _pimpl(
Impl::nullimpl() )
404 : _pimpl( new
Impl( file ) )
408 : _pimpl( new
Impl( sharedfile ) )
412 : _pimpl( new
Impl( sharedfile, keydata ) )
464 {
return sid ==
id(); }