void ChecksumFileChecker::operator()( const Pathname &file ) const
{
- MIL << "checking " << file << " file against checksum '" << _checksum << "'" << endl;
+ //MIL << "checking " << file << " file against checksum '" << _checksum << "'" << endl;
callback::SendReport<DigestReport> report;
- CheckSum real_checksum( _checksum.type(), filesystem::checksum( file, _checksum.type() ));
-
+
if ( _checksum.empty() )
{
MIL << "File " << file << " has no checksum available." << std::endl;
}
else
{
- ZYPP_THROW(FileCheckException("No checksum available"));
+ ZYPP_THROW( FileCheckException( file.basename() + " has no checksum" ) );
}
}
else
{
+ CheckSum real_checksum( _checksum.type(), filesystem::checksum( file, _checksum.type() ));
if ( (real_checksum != _checksum) )
{
if ( report->askUserToAcceptWrongDigest( file, _checksum.checksum(), real_checksum.checksum() ) )
}
else
{
- ZYPP_THROW(FileCheckException("Wrong checksum"));
+ ZYPP_THROW( FileCheckException( file.basename() + " has wrong checksum" ) );
}
}
}
}
}
}
-
+
void CompositeFileChecker::add( const FileChecker &checker )
{
//MIL << "||# " << _checkers.size() << endl;
_checkers.push_back(checker);
//MIL << "||* " << _checkers.size() << endl;
-
+
}
- SignatureFileChecker::SignatureFileChecker( const Pathname &signature )
- : _signature(signature)
+ SignatureFileChecker::SignatureFileChecker( const Pathname &signature )
+ : _signature(signature)
{
+
}
-
+
+
SignatureFileChecker::SignatureFileChecker()
{
}
-
- void SignatureFileChecker::addPublicKey( const Pathname &publickey )
+
+ void SignatureFileChecker::setKeyContext(const KeyContext & keycontext)
+ { _context = keycontext; }
+
+ void SignatureFileChecker::addPublicKey( const Pathname & publickey, const KeyContext & keycontext )
+ { addPublicKey( PublicKey(publickey), keycontext ); }
+
+ void SignatureFileChecker::addPublicKey( const PublicKey & publickey, const KeyContext & keycontext )
{
- ZYpp::Ptr z = getZYpp();
- z->keyRing()->importKey(publickey, false);
+ getZYpp()->keyRing()->importKey(publickey, false);
+ _context = keycontext;
}
-
+
void SignatureFileChecker::operator()(const Pathname &file ) const
{
ZYpp::Ptr z = getZYpp();
}
MIL << "checking " << file << " file validity using digital signature.." << endl;
- bool valid = z->keyRing()->verifyFileSignatureWorkflow( file, string(), _signature);
+ bool valid = z->keyRing()->verifyFileSignatureWorkflow( file, file.basename(), _signature, _context);
+
if (!valid)
- ZYPP_THROW(FileCheckException("Signature verification failed"));
+ ZYPP_THROW( FileCheckException( "Signature verification failed for " + file.basename() ) );
}
/******************************************************************