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 }
20 
21 namespace coral_bridge {
22 
24 
25  public:
28 
30  virtual ~AuthenticationCredentialSet();
31 
32 
33  void registerItem( const std::string& connectionString,
34  const std::string& itemName,
35  const std::string& itemValue );
36 
37 
38  void registerItem( const std::string& connectionString,
39  const std::string& role,
40  const std::string& itemName,
41  const std::string& itemValue );
42 
46  void registerCredentials( const std::string& connectionString,
47  const std::string& userName,
48  const std::string& password );
49 
53  void registerCredentials( const std::string& connectionString,
54  const std::string& role,
55  const std::string& userName,
56  const std::string& password );
57 
58  void import( const AuthenticationCredentialSet& data );
59 
60  const coral::IAuthenticationCredentials* get( const std::string& connectionString ) const;
61 
62  const coral::IAuthenticationCredentials* get( const std::string& connectionString, const std::string& role ) const;
63 
64  const std::map< std::pair<std::string,std::string>, coral::AuthenticationCredentials* >& data() const ;
65 
66  void reset();
67 
68  private:
70  std::map< std::pair<std::string,std::string>, coral::AuthenticationCredentials* > m_data;
71 
72  };
73 
74 }
75 
76 namespace cond {
77 
78  class Cipher;
79 
80  std::string schemaLabel( const std::string& serviceName, const std::string& userName );
81 
82  //
84 
85  public:
86  // default service is pointed in case the specific one has not been found in the key list
88 
89  public:
92 
94  virtual ~CredentialStore();
95 
96  public:
97 
99  std::string setUpForService( const std::string& serviceName, const std::string& authPath );
100 
101  std::string setUpForConnectionString( const std::string& connectionString, const std::string& authPath );
102 
103  bool createSchema( const std::string& connectionString, const std::string& userName, const std::string& password );
104 
105  bool drop( const std::string& connectionString, const std::string& userName, const std::string& password );
106 
107  bool resetAdmin( const std::string& userName, const std::string& password );
108 
109  bool updatePrincipal( const std::string& principal, const std::string& principalKey, bool setAdmin=false);
110 
111  bool setPermission( const std::string& principal, const std::string& role, const std::string& connectionString, const std::string& connectionLabel );
112 
113  bool unsetPermission( const std::string& principal, const std::string& role, const std::string& connectionString );
114 
115  bool updateConnection( const std::string& connectionLabel, const std::string& userName, const std::string& password );
116 
117  bool removePrincipal( const std::string& principal );
118 
119  bool removeConnection( const std::string& connectionLabel );
120 
121  bool selectForUser( coral_bridge::AuthenticationCredentialSet& destinationData );
122 
124  bool importForPrincipal( const std::string& principal, const coral_bridge::AuthenticationCredentialSet& data, bool forceUpdateConnection=false );
125 
126  bool listPrincipals( std::vector<std::string>& destination );
127 
128  bool listConnections( std::map<std::string,std::pair<std::string,std::string> >& destination );
129 
130  struct Permission {
135  };
136  bool selectPermissions( const std::string& principalName, const std::string& role, const std::string& connectionString, std::vector<Permission>& destination );
137 
139 
140  const std::string& keyPrincipalName ();
141 
142  private:
143 
144  friend class CSScopedSession;
145 
146  std::pair<std::string,std::string> openConnection( const std::string& connectionString );
147  void openSession( const std::string& schemaName, const std::string& userName, const std::string& password, bool readMode );
148  void startSuperSession( const std::string& connectionString, const std::string& userName, const std::string& password );
149  void startSession( bool readMode );
150 
151  void openSession( bool readOnly=true );
152 
153  void closeSession( bool commit=true );
154 
155  private:
156 
157  std::shared_ptr<coral::IConnection> m_connection;
158  std::shared_ptr<coral::ISession> m_session;
159 
161  // the key used to encrypt the db credentials accessibles by the owner of the authenticated key.
163 
166 
168 
169  };
170 
171 }
172 
173 
174 
175 
176 #endif
std::map< std::pair< std::string, std::string >, coral::AuthenticationCredentials * > m_data
credentials for the specific roles
static const std::string serviceName
def principal(options)
std::string schemaLabel(const std::string &serviceName, const std::string &userName)
bool closeSession(Session *&session)
Definition: TensorFlow.cc:193
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:24
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
std::shared_ptr< coral::IConnection > m_connection
const auth::ServiceCredentials * m_serviceData
void reset(double vett[256])
Definition: TPedValues.cc:11