CMS 3D CMS Logo

CredentialStore.h
Go to the documentation of this file.
1 #ifndef CondCore_CondDB_CredentialStore_h
2 #define CondCore_CondDB_CredentialStore_h
3 
5 //
6 #include <map>
7 #include <memory>
8 #include <string>
9 //
10 #include "CoralBase/MessageStream.h"
11 
12 namespace coral {
13 
14  class AuthenticationCredentials;
15  class IAuthenticationCredentials;
16  class ISession;
17  class IConnection;
18 
19 } // namespace coral
20 
21 namespace coral_bridge {
22 
24  public:
27 
29  virtual ~AuthenticationCredentialSet();
30 
31  void registerItem(const std::string& connectionString, const std::string& itemName, const std::string& itemValue);
32 
33  void registerItem(const std::string& connectionString,
34  const std::string& role,
35  const std::string& itemName,
36  const std::string& itemValue);
37 
41  void registerCredentials(const std::string& connectionString,
42  const std::string& userName,
43  const std::string& password);
44 
48  void registerCredentials(const std::string& connectionString,
49  const std::string& role,
50  const std::string& userName,
51  const std::string& password);
52 
53  void import(const AuthenticationCredentialSet& data);
54 
55  const coral::IAuthenticationCredentials* get(const std::string& connectionString) const;
56 
57  const coral::IAuthenticationCredentials* get(const std::string& connectionString, const std::string& role) const;
58 
59  const std::map<std::pair<std::string, std::string>, coral::AuthenticationCredentials*>& data() const;
60 
61  void reset();
62 
63  private:
65  std::map<std::pair<std::string, std::string>, coral::AuthenticationCredentials*> m_data;
66  };
67 
68 } // namespace coral_bridge
69 
70 namespace cond {
71 
72  class Cipher;
73 
75 
76  //
78  public:
79  // default service is pointed in case the specific one has not been found in the key list
81 
82  public:
85 
87  virtual ~CredentialStore();
88 
89  public:
91  std::string setUpForService(const std::string& serviceName, const std::string& authPath);
92 
93  std::string setUpForConnectionString(const std::string& connectionString, const std::string& authPath);
94 
95  bool createSchema(const std::string& connectionString, const std::string& userName, const std::string& password);
96 
97  bool drop(const std::string& connectionString, const std::string& userName, const std::string& password);
98 
99  bool resetAdmin(const std::string& userName, const std::string& password);
100 
101  bool updatePrincipal(const std::string& principal, const std::string& principalKey, bool setAdmin = false);
102 
103  bool setPermission(const std::string& principal,
104  const std::string& role,
106  const std::string& connectionLabel);
107 
108  bool unsetPermission(const std::string& principal, const std::string& role, const std::string& connectionString);
109 
110  bool updateConnection(const std::string& connectionLabel, const std::string& userName, const std::string& password);
111 
112  bool removePrincipal(const std::string& principal);
113 
114  bool removeConnection(const std::string& connectionLabel);
115 
116  bool selectForUser(coral_bridge::AuthenticationCredentialSet& destinationData);
117 
119  bool importForPrincipal(const std::string& principal,
121  bool forceUpdateConnection = false);
122 
123  bool listPrincipals(std::vector<std::string>& destination);
124 
125  bool listConnections(std::map<std::string, std::pair<std::string, std::string> >& destination);
126 
127  struct Permission {
132  };
133  bool selectPermissions(const std::string& principalName,
134  const std::string& role,
136  std::vector<Permission>& destination);
137 
139 
140  const std::string& keyPrincipalName();
141 
142  private:
143  friend class CSScopedSession;
144 
145  std::pair<std::string, std::string> openConnection(const std::string& connectionString);
146  void openSession(const std::string& schemaName,
147  const std::string& userName,
148  const std::string& password,
149  bool readMode);
150  void startSuperSession(const std::string& connectionString,
151  const std::string& userName,
152  const std::string& password);
153  void startSession(bool readMode);
154 
155  void openSession(bool readOnly = true);
156 
157  void closeSession(bool commit = true);
158 
159  private:
160  std::shared_ptr<coral::IConnection> m_connection;
161  std::shared_ptr<coral::ISession> m_session;
162 
164  // the key used to encrypt the db credentials accessibles by the owner of the authenticated key.
166 
169 
171  };
172 
173 } // namespace cond
174 
175 #endif
std::map< std::pair< std::string, std::string >, coral::AuthenticationCredentials * > m_data
credentials for the specific roles
static const std::string serviceName
std::string schemaLabel(const std::string &serviceName, const std::string &userName)
bool closeSession(Session *&session)
Definition: TensorFlow.cc:161
Definition: Binary.h:9
const int drop
auth::DecodingKey m_key
static const std::string DEFAULT_DATA_SOURCE
std::shared_ptr< coral::ISession > m_session
Definition: plugin.cc:23
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
std::shared_ptr< coral::IConnection > m_connection
const auth::ServiceCredentials * m_serviceData
void reset(double vett[256])
Definition: TPedValues.cc:11