CernVM-FS  2.10.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
manifest_fetch.h
Go to the documentation of this file.
1 
5 #ifndef CVMFS_MANIFEST_FETCH_H_
6 #define CVMFS_MANIFEST_FETCH_H_
7 
8 #include <cstdlib>
9 #include <string>
10 
11 #include "manifest.h"
12 
13 namespace shash {
14 struct Any;
15 }
16 
17 namespace signature {
18 class SignatureManager;
19 }
20 
21 namespace download {
22 class DownloadManager;
23 }
24 
25 namespace manifest {
26 
27 enum Failures {
28  kFailOk = 0,
39 
41 };
42 
43 inline const char *Code2Ascii(const Failures error) {
44  const char *texts[kFailNumEntries + 1];
45  texts[0] = "OK";
46  texts[1] = "failed to download";
47  texts[2] = "incomplete manifest";
48  texts[3] = "repository name mismatch";
49  texts[4] = "catalog root path mismatch";
50  texts[5] = "outdated manifest";
51  texts[6] = "bad certificate, failed to verify repository manifest";
52  texts[7] = "bad signature, failed to verify repository manifest";
53  texts[8] = "bad whitelist";
54  texts[9] = "invalid certificate";
55  texts[10] = "unknown error";
56  texts[11] = "no text";
57  return texts[error];
58 }
59 
66  manifest = NULL;
69  }
70  virtual ~ManifestEnsemble() {
71  delete manifest;
73  if (cert_buf) free(cert_buf);
74  if (whitelist_buf) free(whitelist_buf);
76  }
77  // Can be overwritte to fetch certificate from cache
78  virtual void FetchCertificate(const shash::Any &hash) {}
79 
81  unsigned char *raw_manifest_buf;
82  unsigned char *cert_buf;
83  unsigned char *whitelist_buf;
84  unsigned char *whitelist_pkcs7_buf;
86  unsigned cert_size;
87  unsigned whitelist_size;
89 };
90 
91 // TODO(jblomer): analogous to the Fetcher class, make a ManifestFetcher class
92 Failures Fetch(const std::string &base_url, const std::string &repository_name,
93  const uint64_t minimum_timestamp, const shash::Any *base_catalog,
94  signature::SignatureManager *signature_manager,
95  download::DownloadManager *download_manager,
96  ManifestEnsemble *ensemble);
97 
98 Failures Verify(char *manifest_data, size_t manifest_size,
99  const std::string &base_url, const std::string &repository_name,
100  const uint64_t minimum_timestamp,
101  const shash::Any *base_catalog,
102  signature::SignatureManager *signature_manager,
103  download::DownloadManager *download_manager,
104  ManifestEnsemble *ensemble);
105 
106 } // namespace manifest
107 
108 #endif // CVMFS_MANIFEST_FETCH_H_
const manifest::Manifest * manifest() const
Definition: repository.h:123
unsigned char * raw_manifest_buf
Failures Verify(char *manifest_data, size_t manifest_size, const std::string &base_url, const std::string &repository_name, const uint64_t minimum_timestamp, const shash::Any *base_catalog, signature::SignatureManager *signature_manager, download::DownloadManager *download_manager, ManifestEnsemble *ensemble)
virtual void FetchCertificate(const shash::Any &hash)
unsigned char * whitelist_buf
Failures Fetch(const std::string &base_url, const std::string &repository_name, const uint64_t minimum_timestamp, const shash::Any *base_catalog, signature::SignatureManager *signature_manager, download::DownloadManager *download_manager, ManifestEnsemble *ensemble)
unsigned char * whitelist_pkcs7_buf
const char * Code2Ascii(const Failures error)