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 FILE_NAME = "db.key";
34  static constexpr const char* const FILE_PATH = ".cms_cond/db.key";
35  static constexpr size_t DEFAULT_KEY_SIZE = 100;
36 
37  static std::string templateFile();
38 
39  public:
40  DecodingKey();
41 
42  virtual ~DecodingKey() {}
43 
44  size_t init(const std::string& keyFileName, const std::string& password, bool readMode = true);
45 
46  size_t createFromInputFile(const std::string& inputFileName, size_t generatedKeySize = 0);
47 
48  void list(std::ostream& out);
49 
50  void flush();
51 
52  const std::string& principalName() const;
53 
54  const std::string& principalKey() const;
55 
56  bool isNominal() const;
57 
58  const std::string& ownerName() const;
59 
60  const std::map<std::string, ServiceCredentials>& services() const;
61 
63 
66  const std::string& userName,
67  const std::string& password);
68 
69  private:
71 
72  bool m_mode;
73 
75 
77 
79 
81 
82  std::map<std::string, ServiceCredentials> m_services;
83  };
84  } // namespace auth
85 } // namespace cond
86 
87 inline cond::auth::KeyGenerator::KeyGenerator() : m_iteration(0) {}
88 
90 
92  : m_fileName(""), m_mode(true), m_pwd(""), m_principalName(""), m_principalKey(""), m_owner(""), m_services() {}
93 
94 inline const std::string& cond::auth::DecodingKey::principalName() const { return m_principalName; }
95 
96 inline const std::string& cond::auth::DecodingKey::principalKey() const { return m_principalKey; }
97 
98 inline bool cond::auth::DecodingKey::isNominal() const { return !m_owner.empty(); }
99 
100 inline const std::string& cond::auth::DecodingKey::ownerName() const { return m_owner; }
101 
102 inline const std::map<std::string, cond::auth::ServiceCredentials>& cond::auth::DecodingKey::services() const {
103  return m_services;
104 }
105 
106 #endif // CondCore_CondDB_DecodingKey_h
cond::auth::DecodingKey::principalName
const std::string & principalName() const
Definition: DecodingKey.h:94
cond::auth::DecodingKey
Definition: DecodingKey.h:31
cond::auth::DecodingKey::m_owner
std::string m_owner
Definition: DecodingKey.h:80
cond::auth::DecodingKey::ownerName
const std::string & ownerName() const
Definition: DecodingKey.h:100
cond::auth::ServiceCredentials::connectionString
std::string connectionString
Definition: DecodingKey.h:15
cond::auth::KeyGenerator::KeyGenerator
KeyGenerator()
Definition: DecodingKey.h:87
cond::auth::KeyGenerator::make
std::string make(size_t keySize)
Definition: DecodingKey.cc:74
cond::auth::DecodingKey::m_principalName
std::string m_principalName
Definition: DecodingKey.h:76
cond::auth::DecodingKey::init
size_t init(const std::string &keyFileName, const std::string &password, bool readMode=true)
Definition: DecodingKey.cc:111
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:35
EcalCondDBWriter_cfi.userName
userName
Definition: EcalCondDBWriter_cfi.py:61
cond::auth::ServiceCredentials::ServiceCredentials
ServiceCredentials()
Definition: DecodingKey.h:89
cond::auth::DecodingKey::flush
void flush()
Definition: DecodingKey.cc:252
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:70
cond::auth::DecodingKey::FILE_PATH
static constexpr const char *const FILE_PATH
Definition: DecodingKey.h:34
cond::auth::DecodingKey::m_pwd
std::string m_pwd
Definition: DecodingKey.h:74
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cond
Definition: plugin.cc:23
cond::auth::DecodingKey::DecodingKey
DecodingKey()
Definition: DecodingKey.h:91
funct::true
true
Definition: Factorize.h:173
cond::auth::DecodingKey::FILE_NAME
static constexpr const char *const FILE_NAME
Definition: DecodingKey.h:33
cond::auth::DecodingKey::isNominal
bool isNominal() const
Definition: DecodingKey.h:98
cond::auth::KeyGenerator::m_iteration
int m_iteration
Definition: DecodingKey.h:28
cond::auth::DecodingKey::m_mode
bool m_mode
Definition: DecodingKey.h:72
cond::auth::ServiceCredentials::password
std::string password
Definition: DecodingKey.h:17
cond::auth::DecodingKey::m_principalKey
std::string m_principalKey
Definition: DecodingKey.h:78
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:96
cond::auth::DecodingKey::~DecodingKey
virtual ~DecodingKey()
Definition: DecodingKey.h:42
cond::auth::DecodingKey::services
const std::map< std::string, ServiceCredentials > & services() const
Definition: DecodingKey.h:102
cond::auth::DecodingKey::addDefaultService
void addDefaultService(const std::string &connectionString)
Definition: DecodingKey.cc:287
cond::auth::KeyGenerator::makeWithRandomSize
std::string makeWithRandomSize(size_t maxSize)
Definition: DecodingKey.cc:87
cond::auth::ServiceCredentials
Definition: DecodingKey.h:13
cond::auth::DecodingKey::list
void list(std::ostream &out)
Definition: DecodingKey.cc:239
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:190
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:291
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:82
cond::auth::DecodingKey::principalKey
const std::string & principalKey() const
Definition: DecodingKey.h:96