CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CredentialStore.h
Go to the documentation of this file.
1 #ifndef INCLUDE_COND_CREDENTIALSTORE_H
2 #define INCLUDE_COND_CREDENTAILSTORE_H
3 
5 //
6 #include <map>
7 #include <string>
8 //#include <memory>
9 #include <boost/shared_ptr.hpp>
10 //
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 
31 
32 
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 
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 installAdmin( 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 
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  int addUser( const std::string& principalName, const std::string& authenticationKey, const std::string& principalKey, const std::string& adminKey );
156 
157  bool setPermission( int principalId, const std::string& principalKey, const std::string& role, const std::string& connectionString, int connectionId, const std::string& connectionKey );
158 
159  std::pair<int,std::string> updateConnection( const std::string& connectionLabel, const std::string& userName, const std::string& password, bool forceUpdate );
160 
161  private:
162 
163  boost::shared_ptr<coral::IConnection> m_connection;
164  boost::shared_ptr<coral::ISession> m_session;
165 
168 
171 
173 
174  };
175 
176 }
177 
178 
179 
180 
181 #endif
const std::string & keyPrincipalName()
std::map< std::pair< std::string, std::string >, coral::AuthenticationCredentials * > m_data
credentials for the specific roles
bool updatePrincipal(const std::string &principal, const std::string &principalKey, bool setAdmin=false)
CredentialStore()
Standard Constructor.
virtual ~AuthenticationCredentialSet()
Destructor.
bool removeConnection(const std::string &connectionLabel)
void openSession(const std::string &schemaName, const std::string &userName, const std::string &password, bool readMode)
bool listConnections(std::map< std::string, std::pair< std::string, std::string > > &destination)
const ServiceCredentials * m_serviceData
static const std::string serviceName
void closeSession(bool commit=true)
void registerItem(const std::string &connectionString, const std::string &itemName, const std::string &itemValue)
const std::map< std::pair< std::string, std::string >, coral::AuthenticationCredentials * > & data() const
void startSession(bool readMode)
bool updateConnection(const std::string &connectionLabel, const std::string &userName, const std::string &password)
bool createSchema(const std::string &connectionString, const std::string &userName, const std::string &password)
bool exportAll(coral_bridge::AuthenticationCredentialSet &data)
std::string schemaLabel(const std::string &serviceName, const std::string &userName)
bool listPrincipals(std::vector< std::string > &destination)
std::string setUpForConnectionString(const std::string &connectionString, const std::string &authPath)
int addUser(const std::string &principalName, const std::string &authenticationKey, const std::string &principalKey, const std::string &adminKey)
std::string setUpForService(const std::string &serviceName, const std::string &authPath)
Sets the initialization parameters.
bool importForPrincipal(const std::string &principal, const coral_bridge::AuthenticationCredentialSet &data, bool forceUpdateConnection=false)
import data
bool setPermission(const std::string &principal, const std::string &role, const std::string &connectionString, const std::string &connectionLabel)
virtual ~CredentialStore()
Standard Destructor.
bool selectForUser(coral_bridge::AuthenticationCredentialSet &destinationData)
string connectionString
Definition: autoCondHLT.py:4
bool removePrincipal(const std::string &principal)
void startSuperSession(const std::string &connectionString, const std::string &userName, const std::string &password)
bool installAdmin(const std::string &userName, const std::string &password)
boost::shared_ptr< coral::ISession > m_session
bool selectPermissions(const std::string &principalName, const std::string &role, const std::string &connectionString, std::vector< Permission > &destination)
static const std::string DEFAULT_DATA_SOURCE
boost::shared_ptr< coral::IConnection > m_connection
void registerCredentials(const std::string &connectionString, const std::string &userName, const std::string &password)
std::pair< std::string, std::string > openConnection(const std::string &connectionString)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
bool drop(const std::string &connectionString, const std::string &userName, const std::string &password)
bool unsetPermission(const std::string &principal, const std::string &role, const std::string &connectionString)