CMS 3D CMS Logo

DecodingKey.h
Go to the documentation of this file.
1 #ifndef CondCore_CondDB_DecodingKey_h
2 #define CondCore_CondDB_DecodingKey_h
3 
4 #include <iostream>
5 #include <string>
6 #include <set>
7 #include <map>
8 
9 namespace cond {
10 
11  namespace auth {
12 
18  };
19 
20  class KeyGenerator {
21  public:
22  KeyGenerator();
23 
24  std::string make(size_t keySize);
26 
27  private:
29  };
30 
31  class DecodingKey {
32  public:
33  static constexpr const char* const KEY_FMT_VERSION = "2.0";
34  static constexpr const char* const FILE_NAME = "db.key";
35  static constexpr const char* const FILE_PATH = ".cms_cond/db.key";
36  static constexpr size_t DEFAULT_KEY_SIZE = 100;
37 
38  static std::string templateFile();
39 
40  public:
41  DecodingKey();
42 
43  virtual ~DecodingKey() {}
44 
45  size_t init(const std::string& keyFileName, const std::string& password, bool readMode = true);
46 
47  size_t createFromInputFile(const std::string& inputFileName, size_t generatedKeySize = 0);
48 
49  void list(std::ostream& out);
50 
51  void flush();
52 
53  const std::string& version() const;
54 
55  const std::string& principalName() const;
56 
57  const std::string& principalKey() const;
58 
59  bool isNominal() const;
60 
61  const std::string& ownerName() const;
62 
63  const std::map<std::string, ServiceCredentials>& services() const;
64 
66 
69  const std::string& userName,
70  const std::string& password);
71 
72  private:
74 
76 
77  bool m_mode;
78 
80 
82 
84 
86 
87  std::map<std::string, ServiceCredentials> m_services;
88  };
89  } // namespace auth
90 } // namespace cond
91 
92 inline cond::auth::KeyGenerator::KeyGenerator() : m_iteration(0) {}
93 
95 
97  : m_fileName(""),
98  m_version(""),
99  m_mode(true),
100  m_pwd(""),
101  m_principalName(""),
102  m_principalKey(""),
103  m_owner(""),
104  m_services() {}
105 
106 inline const std::string& cond::auth::DecodingKey::version() const { return m_version; }
107 
108 inline const std::string& cond::auth::DecodingKey::principalName() const { return m_principalName; }
109 
110 inline const std::string& cond::auth::DecodingKey::principalKey() const { return m_principalKey; }
111 
112 inline bool cond::auth::DecodingKey::isNominal() const { return !m_owner.empty(); }
113 
114 inline const std::string& cond::auth::DecodingKey::ownerName() const { return m_owner; }
115 
116 inline const std::map<std::string, cond::auth::ServiceCredentials>& cond::auth::DecodingKey::services() const {
117  return m_services;
118 }
119 
120 #endif // CondCore_CondDB_DecodingKey_h
size_t init(const std::string &keyFileName, const std::string &password, bool readMode=true)
Definition: DecodingKey.cc:113
void addService(const std::string &serviceName, const std::string &connectionString, const std::string &userName, const std::string &password)
Definition: DecodingKey.cc:303
static const std::string serviceName
size_t createFromInputFile(const std::string &inputFileName, size_t generatedKeySize=0)
Definition: DecodingKey.cc:195
std::string m_fileName
Definition: DecodingKey.h:73
static std::string templateFile()
Definition: DecodingKey.cc:97
void addDefaultService(const std::string &connectionString)
Definition: DecodingKey.cc:299
std::string m_principalName
Definition: DecodingKey.h:81
static constexpr const char *const KEY_FMT_VERSION
Definition: DecodingKey.h:33
static constexpr size_t DEFAULT_KEY_SIZE
Definition: DecodingKey.h:36
std::string makeWithRandomSize(size_t maxSize)
Definition: DecodingKey.cc:88
const std::string & principalName() const
Definition: DecodingKey.h:108
std::string make(size_t keySize)
Definition: DecodingKey.cc:75
std::string m_principalKey
Definition: DecodingKey.h:83
bool isNominal() const
Definition: DecodingKey.h:112
const std::string & version() const
Definition: DecodingKey.h:106
const std::string & ownerName() const
Definition: DecodingKey.h:114
Definition: plugin.cc:23
static constexpr const char *const FILE_NAME
Definition: DecodingKey.h:34
const std::map< std::string, ServiceCredentials > & services() const
Definition: DecodingKey.h:116
void list(std::ostream &out)
Definition: DecodingKey.cc:247
static constexpr const char *const FILE_PATH
Definition: DecodingKey.h:35
const std::string & principalKey() const
Definition: DecodingKey.h:110
std::map< std::string, ServiceCredentials > m_services
Definition: DecodingKey.h:87