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
cond::auth::DecodingKey::principalName
const std::string & principalName() const
Definition: DecodingKey.h:108
cond::auth::DecodingKey
Definition: DecodingKey.h:31
cond::auth::DecodingKey::m_owner
std::string m_owner
Definition: DecodingKey.h:85
cond::auth::DecodingKey::ownerName
const std::string & ownerName() const
Definition: DecodingKey.h:114
cond::auth::ServiceCredentials::connectionString
std::string connectionString
Definition: DecodingKey.h:15
cond::auth::KeyGenerator::KeyGenerator
KeyGenerator()
Definition: DecodingKey.h:92
cond::auth::KeyGenerator::make
std::string make(size_t keySize)
Definition: DecodingKey.cc:75
cond::auth::DecodingKey::m_principalName
std::string m_principalName
Definition: DecodingKey.h:81
cond::auth::DecodingKey::init
size_t init(const std::string &keyFileName, const std::string &password, bool readMode=true)
Definition: DecodingKey.cc:113
serviceName
static const std::string serviceName
Definition: CredentialStore.cc:31
cond::auth::DecodingKey::DEFAULT_KEY_SIZE
static constexpr size_t DEFAULT_KEY_SIZE
Definition: DecodingKey.h:36
EcalCondDBWriter_cfi.userName
userName
Definition: EcalCondDBWriter_cfi.py:61
cond::auth::ServiceCredentials::ServiceCredentials
ServiceCredentials()
Definition: DecodingKey.h:94
cond::auth::DecodingKey::flush
void flush()
Definition: DecodingKey.cc:261
EcalCondDBWriter_cfi.password
password
Definition: EcalCondDBWriter_cfi.py:62
InefficientDoubleROC.inputFileName
inputFileName
Definition: InefficientDoubleROC.py:437
cond::auth::DecodingKey::m_fileName
std::string m_fileName
Definition: DecodingKey.h:73
cond::auth::DecodingKey::KEY_FMT_VERSION
static constexpr const char *const KEY_FMT_VERSION
Definition: DecodingKey.h:33
cond::auth::DecodingKey::FILE_PATH
static constexpr const char *const FILE_PATH
Definition: DecodingKey.h:35
cond::auth::DecodingKey::m_pwd
std::string m_pwd
Definition: DecodingKey.h:79
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cond
Definition: plugin.cc:23
cond::auth::DecodingKey::DecodingKey
DecodingKey()
Definition: DecodingKey.h:96
funct::true
true
Definition: Factorize.h:173
cond::auth::DecodingKey::FILE_NAME
static constexpr const char *const FILE_NAME
Definition: DecodingKey.h:34
cond::auth::DecodingKey::isNominal
bool isNominal() const
Definition: DecodingKey.h:112
cond::auth::KeyGenerator::m_iteration
int m_iteration
Definition: DecodingKey.h:28
cond::auth::DecodingKey::m_mode
bool m_mode
Definition: DecodingKey.h:77
cond::auth::ServiceCredentials::password
std::string password
Definition: DecodingKey.h:17
cond::auth::DecodingKey::m_principalKey
std::string m_principalKey
Definition: DecodingKey.h:83
cond::auth::KeyGenerator
Definition: DecodingKey.h:20
beamvalidation.auth
auth
Definition: beamvalidation.py:384
reco_skim_cfg_mod.maxSize
maxSize
Definition: reco_skim_cfg_mod.py:154
cond::auth::DecodingKey::templateFile
static std::string templateFile()
Definition: DecodingKey.cc:97
cond::auth::DecodingKey::~DecodingKey
virtual ~DecodingKey()
Definition: DecodingKey.h:43
cond::auth::DecodingKey::services
const std::map< std::string, ServiceCredentials > & services() const
Definition: DecodingKey.h:116
cond::auth::DecodingKey::addDefaultService
void addDefaultService(const std::string &connectionString)
Definition: DecodingKey.cc:299
cond::auth::KeyGenerator::makeWithRandomSize
std::string makeWithRandomSize(size_t maxSize)
Definition: DecodingKey.cc:88
cond::auth::DecodingKey::version
const std::string & version() const
Definition: DecodingKey.h:106
cond::auth::ServiceCredentials
Definition: DecodingKey.h:13
cond::auth::DecodingKey::list
void list(std::ostream &out)
Definition: DecodingKey.cc:247
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
cond::auth::DecodingKey::createFromInputFile
size_t createFromInputFile(const std::string &inputFileName, size_t generatedKeySize=0)
Definition: DecodingKey.cc:195
l1RCTOmdsFedVectorProducer_cfi.connectionString
connectionString
Definition: l1RCTOmdsFedVectorProducer_cfi.py:4
cond::auth::DecodingKey::addService
void addService(const std::string &serviceName, const std::string &connectionString, const std::string &userName, const std::string &password)
Definition: DecodingKey.cc:303
cond::auth::DecodingKey::m_version
std::string m_version
Definition: DecodingKey.h:75
cond::auth::ServiceCredentials::userName
std::string userName
Definition: DecodingKey.h:16
cond::auth::DecodingKey::m_services
std::map< std::string, ServiceCredentials > m_services
Definition: DecodingKey.h:87
cond::auth::DecodingKey::principalKey
const std::string & principalKey() const
Definition: DecodingKey.h:110