Imported Upstream version 15.0.0
[platform/upstream/libzypp.git] / zypp / FileChecker.cc
index e9a8a38..f6b7abc 100644 (file)
 
 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() )
@@ -44,7 +42,7 @@ namespace zypp
       }
       else
       {
-        ZYPP_THROW( ExceptionType( file.basename() + " has no checksum" ) );
+        ZYPP_THROW( FileCheckException( file.basename() + " has no checksum" ) );
       }
     }
     else
@@ -52,7 +50,6 @@ namespace zypp
       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;
@@ -60,7 +57,7 @@ namespace zypp
         }
         else
         {
-          ZYPP_THROW( ExceptionType( file.basename() + " has wrong checksum" ) );
+          ZYPP_THROW( FileCheckException( file.basename() + " has wrong checksum" ) );
         }
       }
     }
@@ -90,15 +87,23 @@ namespace zypp
   }
 
   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; }
@@ -114,18 +119,19 @@ namespace zypp
 
   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() ) );
 }
 
   /******************************************************************
   **