libzypp  17.24.1
FileChecker.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_FILECHECKER_H
13 #define ZYPP_FILECHECKER_H
14 
15 #include <iosfwd>
16 #include <list>
18 #include <zypp/base/Exception.h>
19 #include <zypp/base/Function.h>
20 #include <zypp/PathInfo.h>
21 #include <zypp/CheckSum.h>
22 #include <zypp/KeyContext.h>
23 
25 namespace zypp
26 {
27 
28  class PublicKey;
29 
37  typedef function<void ( const Pathname &file )> FileChecker;
38 
40  {
41  public:
42  FileCheckException(const std::string &msg)
43  : Exception(msg)
44  {}
45  };
46 
48  {
49  public:
50  CheckSumCheckException(const std::string &msg)
52  {}
53  };
54 
56  {
57  public:
58  SignatureCheckException(const std::string &msg)
60  {}
61  };
62 
71  {
72  public:
85  void operator()( const Pathname &file ) const;
86  private:
88  };
89 
94  {
95  public:
97 
98  public:
103  SignatureFileChecker( const Pathname &signature );
104 
112 
120  void setKeyContext(const KeyContext & keycontext);
121 
123  const KeyContext & keyContext() const
124  { return _context; }
125 
130  bool fileAccepted() const
131  { return _fileAccepted; }
132 
137  bool fileValidated() const
138  { return _fileValidated; }
139 
143  void addPublicKey( const PublicKey & publickey, const KeyContext & keycontext = KeyContext());
145  void addPublicKey( const Pathname & publickey, const KeyContext & keycontext = KeyContext());
146 
159  void operator()( const Pathname &file ) const;
160 
161  protected:
166  };
167 
173  {
174  public:
175  void operator()( const Pathname &file ) const;
176  };
177 
193  {
194  public:
195  void add( const FileChecker &checker );
199  void operator()( const Pathname &file ) const;
200 
201  int checkersSize() const { return _checkers.size(); }
202  private:
203  std::list<FileChecker> _checkers;
204  };
205 
207  std::ostream & operator<<( std::ostream & str, const FileChecker & obj );
208 
210 } // namespace zypp
212 #endif // ZYPP_FILECHECKER_H
zypp::ChecksumFileChecker::ExceptionType
CheckSumCheckException ExceptionType
Definition: FileChecker.h:73
zypp::ChecksumFileChecker::ChecksumFileChecker
ChecksumFileChecker(const CheckSum &checksum)
Constructor.
Definition: FileChecker.cc:28
zypp::NullFileChecker::operator()
void operator()(const Pathname &file) const
Definition: FileChecker.cc:85
KeyContext.h
PathInfo.h
zypp::SignatureFileChecker::operator()
void operator()(const Pathname &file) const
Calls KeyRing::verifyFileSignatureWorkflow to verify the file.
Definition: FileChecker.cc:131
zypp::SignatureFileChecker::_fileValidated
DefaultIntegral< bool, false > _fileValidated
Definition: FileChecker.h:165
zypp::SignatureFileChecker::ExceptionType
SignatureCheckException ExceptionType
Definition: FileChecker.h:96
zypp::Exception
Base class for Exception.
Definition: Exception.h:145
zypp::CheckSum
Definition: CheckSum.h:33
zypp::CheckSumCheckException
Definition: FileChecker.h:47
zypp::CompositeFileChecker::checkersSize
int checkersSize() const
Definition: FileChecker.h:201
zypp::FileCheckException::FileCheckException
FileCheckException(const std::string &msg)
Definition: FileChecker.h:42
zypp::CompositeFileChecker::add
void add(const FileChecker &checker)
Definition: FileChecker.cc:108
zypp::FileCheckException
Definition: FileChecker.h:39
CheckSum.h
zypp::SignatureCheckException
Definition: FileChecker.h:55
zypp::SignatureFileChecker::_signature
Pathname _signature
Definition: FileChecker.h:162
zypp::SignatureFileChecker
Checks for the validity of a signature.
Definition: FileChecker.h:93
zypp::SignatureFileChecker::fileValidated
bool fileValidated() const
Return whether the last file passed to operator() was actually sucessfully verified.
Definition: FileChecker.h:137
zypp::SignatureFileChecker::_context
KeyContext _context
Definition: FileChecker.h:163
zypp::KeyContext
Definition: KeyContext.h:8
zypp::NullFileChecker
Checks for nothing Used as the default checker.
Definition: FileChecker.h:172
Exception.h
zypp::SignatureCheckException::SignatureCheckException
SignatureCheckException(const std::string &msg)
Definition: FileChecker.h:58
zypp::filesystem::checksum
std::string checksum(const Pathname &file, const std::string &algorithm)
Compute a files checksum.
Definition: PathInfo.cc:999
zypp::SignatureFileChecker::fileAccepted
bool fileAccepted() const
Return whether the last file passed to operator() was accepted.
Definition: FileChecker.h:130
zypp::SignatureFileChecker::setKeyContext
void setKeyContext(const KeyContext &keycontext)
Set context for this checker.
Definition: FileChecker.cc:119
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
zypp::ChecksumFileChecker::operator()
void operator()(const Pathname &file) const
Try to validate the file.
Definition: FileChecker.cc:32
zypp::SignatureFileChecker::SignatureFileChecker
SignatureFileChecker()
Default Constructor.
Definition: FileChecker.cc:116
zypp::DefaultIntegral< bool, false >
zypp::CompositeFileChecker::operator()
void operator()(const Pathname &file) const
Definition: FileChecker.cc:91
zypp::operator<<
std::ostream & operator<<(std::ostream &str, const Exception &obj)
Definition: Exception.cc:147
zypp::PublicKey
Class representing one GPG Public Key (PublicKeyData + ASCII armored in a tempfile).
Definition: PublicKey.h:275
zypp::ChecksumFileChecker::_checksum
CheckSum _checksum
Definition: FileChecker.h:87
zypp::CompositeFileChecker
Checker composed of more checkers.
Definition: FileChecker.h:192
zypp::SignatureFileChecker::addPublicKey
void addPublicKey(const PublicKey &publickey, const KeyContext &keycontext=KeyContext())
add a public key to the list of known keys
Definition: FileChecker.cc:125
Function.h
zypp::filesystem::Pathname
Pathname.
Definition: Pathname.h:44
zypp::SignatureFileChecker::_fileAccepted
DefaultIntegral< bool, false > _fileAccepted
Definition: FileChecker.h:164
zypp::FileChecker
function< void(const Pathname &file)> FileChecker
Functor signature used to check files.
Definition: FileChecker.h:28
zypp::CheckSumCheckException::CheckSumCheckException
CheckSumCheckException(const std::string &msg)
Definition: FileChecker.h:50
zypp::SignatureFileChecker::keyContext
const KeyContext & keyContext() const
Return the current context.
Definition: FileChecker.h:123
str
String related utilities and Regular expression matching.
zypp::ChecksumFileChecker
Built in file checkers.
Definition: FileChecker.h:70
zypp::CompositeFileChecker::_checkers
std::list< FileChecker > _checkers
Definition: FileChecker.h:203
zypp::Exception::msg
const std::string & msg() const
Return the message string provided to the ctor.
Definition: Exception.h:195
DefaultIntegral.h