CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
cond::RelationalAuthenticationService::RelationalAuthenticationService Class Reference

#include <RelationalAuthenticationService.h>

Inheritance diagram for cond::RelationalAuthenticationService::RelationalAuthenticationService:

Public Member Functions

const coral::IAuthenticationCredentials & credentials (const std::string &connectionString) const override
 
const coral::IAuthenticationCredentials & credentials (const std::string &connectionString, const std::string &role) const override
 
 RelationalAuthenticationService (const std::string &name)
 Standard Constructor. More...
 
void setAuthenticationPath (const std::string &inputPath)
 Sets the input file name. More...
 
 ~RelationalAuthenticationService () override
 Standard Destructor. More...
 

Private Attributes

std::string m_authenticationPath
 The input file with the data. More...
 
coral_bridge::AuthenticationCredentialSet m_cache
 
coral::Property::CallbackID m_callbackID
 
CredentialStore m_db
 The service providing the authentication data. More...
 

Detailed Description

Definition at line 26 of file RelationalAuthenticationService.h.

Constructor & Destructor Documentation

cond::RelationalAuthenticationService::RelationalAuthenticationService::RelationalAuthenticationService ( const std::string &  name)
explicit

Standard Constructor.

Definition at line 24 of file RelationalAuthenticationService.cc.

References cond::auth::COND_AUTH_PATH_PROPERTY, instance, m_callbackID, and setAuthenticationPath().

25  : coral::Service( key ),
27  m_db(),
28  m_cache(),
29  m_callbackID(0)
30 {
31  boost::function1<void, std::string> cb(boost::bind(&cond::RelationalAuthenticationService::RelationalAuthenticationService::setAuthenticationPath, this, _1));
32 
33  coral::Property* pm = dynamic_cast<coral::Property*>(coral::Context::instance().PropertyManager().property(auth::COND_AUTH_PATH_PROPERTY));
34  if(pm){
35  setAuthenticationPath( pm->get() );
36  m_callbackID = pm->registerCallback(cb);
37  }
38 }
static PFTauRenderPlugin instance
static constexpr const char *const COND_AUTH_PATH_PROPERTY
Definition: Auth.h:27
void setAuthenticationPath(const std::string &inputPath)
Sets the input file name.
CredentialStore m_db
The service providing the authentication data.
cond::RelationalAuthenticationService::RelationalAuthenticationService::~RelationalAuthenticationService ( )
override

Standard Destructor.

Definition at line 40 of file RelationalAuthenticationService.cc.

41 {
42 }

Member Function Documentation

const coral::IAuthenticationCredentials & cond::RelationalAuthenticationService::RelationalAuthenticationService::credentials ( const std::string &  connectionString) const
override

Returns a reference to the credentials object for a given connection string. If the connection string is not known to the service an UnknownConnectionException is thrown.

Definition at line 52 of file RelationalAuthenticationService.cc.

References Debug, coral_bridge::AuthenticationCredentialSet::get(), cond::CredentialStore::keyPrincipalName(), cmsBatch::log, m_authenticationPath, m_cache, m_db, mps_check::msg, cond::CredentialStore::selectForUser(), cond::CredentialStore::setUpForConnectionString(), AlCaHLTBitMon_QueryRunRegistry::string, and cond::throwException().

53 {
54  const coral::IAuthenticationCredentials* creds = m_cache.get( connectionString );
55  if( !creds ){
56  std::string credsStoreConn = m_db.setUpForConnectionString( connectionString, m_authenticationPath );
57  coral::MessageStream log("cond::RelationalAuthenticationService::credentials");
58  log << coral::Debug << "Connecting to the credential repository in \"" << credsStoreConn << "\" with principal \""<<m_db.keyPrincipalName()<<"\"."<<coral::MessageStream::endmsg;
60  }
61  creds = m_cache.get( connectionString );
62  if( ! creds ){
63  std::string msg("Connection to \"");
64  msg += connectionString + "\"";
65  msg += " with role \"COND_DEFAULT_ROLE\" is not available for ";
67  cond::throwException( msg, "cond::RelationalAuthenticationService::RelationalAuthenticationService::credentials" );
68  }
69  return *creds;
70 }
const std::string & keyPrincipalName()
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:21
std::string setUpForConnectionString(const std::string &connectionString, const std::string &authPath)
bool selectForUser(coral_bridge::AuthenticationCredentialSet &destinationData)
tuple msg
Definition: mps_check.py:285
const coral::IAuthenticationCredentials * get(const std::string &connectionString) const
CredentialStore m_db
The service providing the authentication data.
const bool Debug
const coral::IAuthenticationCredentials & cond::RelationalAuthenticationService::RelationalAuthenticationService::credentials ( const std::string &  connectionString,
const std::string &  role 
) const
override

Returns a reference to the credentials object for a given connection string. If the connection string is not known to the service an UnknownConnectionException is thrown. If the role is not known to the service an UnknownRoleException is thrown.

Definition at line 73 of file RelationalAuthenticationService.cc.

References Debug, DEFINE_CORALSERVICE, coral_bridge::AuthenticationCredentialSet::get(), cond::CredentialStore::keyPrincipalName(), cmsBatch::log, m_authenticationPath, m_cache, m_db, mps_check::msg, cond::CredentialStore::selectForUser(), cond::CredentialStore::setUpForConnectionString(), AlCaHLTBitMon_QueryRunRegistry::string, and cond::throwException().

75 {
76  const coral::IAuthenticationCredentials* creds = m_cache.get( connectionString, role );
77  if( !creds ){
78  std::string credsStoreConn = m_db.setUpForConnectionString( connectionString, m_authenticationPath );
79  coral::MessageStream log("cond::RelationalAuthenticationService::credentials");
80  log << coral::Debug << "Connecting to the credential repository in \"" << credsStoreConn << "\" with principal \""<<m_db.keyPrincipalName()<<"\"."<<coral::MessageStream::endmsg;
82  }
83  creds = m_cache.get( connectionString, role );
84  if( ! creds ){
85  std::string msg("Connection to \"");
86  msg += connectionString + "\"";
87  msg += " with role \"" + role + "\" is not available for ";
89  cond::throwException( msg, "cond::RelationalAuthenticationService::RelationalAuthenticationService::credentials" );
90  }
91  return *creds;
92 }
const std::string & keyPrincipalName()
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:21
std::string setUpForConnectionString(const std::string &connectionString, const std::string &authPath)
bool selectForUser(coral_bridge::AuthenticationCredentialSet &destinationData)
tuple msg
Definition: mps_check.py:285
const coral::IAuthenticationCredentials * get(const std::string &connectionString) const
CredentialStore m_db
The service providing the authentication data.
const bool Debug
void cond::RelationalAuthenticationService::RelationalAuthenticationService::setAuthenticationPath ( const std::string &  inputPath)

Member Data Documentation

std::string cond::RelationalAuthenticationService::RelationalAuthenticationService::m_authenticationPath
private

The input file with the data.

Definition at line 59 of file RelationalAuthenticationService.h.

Referenced by credentials(), and setAuthenticationPath().

coral_bridge::AuthenticationCredentialSet cond::RelationalAuthenticationService::RelationalAuthenticationService::m_cache
mutableprivate

Definition at line 64 of file RelationalAuthenticationService.h.

Referenced by credentials(), and setAuthenticationPath().

coral::Property::CallbackID cond::RelationalAuthenticationService::RelationalAuthenticationService::m_callbackID
private

Definition at line 66 of file RelationalAuthenticationService.h.

Referenced by RelationalAuthenticationService().

CredentialStore cond::RelationalAuthenticationService::RelationalAuthenticationService::m_db
mutableprivate

The service providing the authentication data.

Definition at line 62 of file RelationalAuthenticationService.h.

Referenced by credentials().