using namespace std;
-#undef ZYPP_BASE_LOGGER_LOGGROUP
-#define ZYPP_BASE_LOGGER_LOGGROUP "FileChecker"
-
///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
ChecksumFileChecker::ChecksumFileChecker( const CheckSum &checksum )
: _checksum(checksum)
- {}
+ {
+ }
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;
if ( _checksum.empty() )
}
else
{
- ZYPP_THROW( ExceptionType( file.basename() + " has no checksum" ) );
+ ZYPP_THROW( FileCheckException( file.basename() + " has no checksum" ) );
}
}
else
CheckSum real_checksum( _checksum.type(), filesystem::checksum( file, _checksum.type() ));
if ( (real_checksum != _checksum) )
{
- WAR << "File " << file << " has wrong checksum " << real_checksum << " (expected " << _checksum << ")" << endl;
if ( report->askUserToAcceptWrongDigest( file, _checksum.checksum(), real_checksum.checksum() ) )
{
WAR << "User accepted " << file << " with WRONG CHECKSUM." << std::endl;
}
else
{
- ZYPP_THROW( ExceptionType( file.basename() + " has wrong checksum" ) );
+ ZYPP_THROW( FileCheckException( file.basename() + " has wrong checksum" ) );
}
}
}
}
void CompositeFileChecker::add( const FileChecker &checker )
- { _checkers.push_back(checker); }
+ {
+ //MIL << "||# " << _checkers.size() << endl;
+ _checkers.push_back(checker);
+ //MIL << "||* " << _checkers.size() << endl;
+ }
- SignatureFileChecker::SignatureFileChecker( const Pathname & signature )
+ SignatureFileChecker::SignatureFileChecker( const Pathname &signature )
: _signature(signature)
- {}
+ {
+
+ }
+
SignatureFileChecker::SignatureFileChecker()
- {}
+ {
+ }
void SignatureFileChecker::setKeyContext(const KeyContext & keycontext)
{ _context = keycontext; }
void SignatureFileChecker::operator()(const Pathname &file ) const
{
- if ( (! PathInfo(_signature).isExist()) && (!_signature.empty()) )
+ ZYpp::Ptr z = getZYpp();
+
+ if ( (! PathInfo(_signature).isExist()) && (!_signature.empty()))
{
- ZYPP_THROW( ExceptionType("Signature " + _signature.asString() + " not found.") );
+ ZYPP_THROW(FileCheckException("Signature " + _signature.asString() + " not found."));
}
MIL << "checking " << file << " file validity using digital signature.." << endl;
- _fileValidated = false;
- _fileAccepted = getZYpp()->keyRing()->verifyFileSignatureWorkflow( file, file.basename(), _signature, _fileValidated, _context );
+ bool valid = z->keyRing()->verifyFileSignatureWorkflow( file, file.basename(), _signature, _context);
- if ( !_fileAccepted )
- ZYPP_THROW( ExceptionType( "Signature verification failed for " + file.basename() ) );
- }
+ if (!valid)
+ ZYPP_THROW( FileCheckException( "Signature verification failed for " + file.basename() ) );
+ }
/******************************************************************
**