CMS 3D CMS Logo

Public Member Functions | Private Attributes

cond::RelationalAuthenticationService::RelationalAuthenticationService Class Reference

#include <RelationalAuthenticationService.h>

List of all members.

Public Member Functions

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

Private Attributes

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

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().

  : coral::Service( key ),
    m_authenticationPath(""),
    m_db(),
    m_cache(),
    m_callbackID(0)
{
  boost::function1<void, std::string> cb(boost::bind(&cond::RelationalAuthenticationService::RelationalAuthenticationService::setAuthenticationPath, this, _1));
       
  coral::Property* pm = dynamic_cast<coral::Property*>(coral::Context::instance().PropertyManager().property(Auth::COND_AUTH_PATH_PROPERTY));
  if(pm){
    setAuthenticationPath( pm->get() );
    m_callbackID = pm->registerCallback(cb);
  } 
}
cond::RelationalAuthenticationService::RelationalAuthenticationService::~RelationalAuthenticationService ( ) [virtual]

Standard Destructor.

Definition at line 40 of file RelationalAuthenticationService.cc.

{
}

Member Function Documentation

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

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, edm::endmsg(), funct::log(), and lumiQueryAPI::msg.

{
  const coral::IAuthenticationCredentials* creds = m_cache.get( connectionString );
  if( !creds ){
    std::string credsStoreConn = m_db.setUpForConnectionString( connectionString, m_authenticationPath );
    coral::MessageStream log("cond::RelationalAuthenticationService::credentials");
    log << coral::Debug << "Connecting to the credential repository in \"" << credsStoreConn << "\" with principal \""<<m_db.keyPrincipalName()<<"\"."<<coral::MessageStream::endmsg;
    m_db.selectForUser( m_cache );
  } 
  creds = m_cache.get( connectionString );
  if( ! creds ){
    std::string msg("No Authentication available for connection=\"");
    msg += connectionString + "\".";
    throw coral::AuthenticationServiceException( msg, "cond::RelationalAuthenticationService::RelationalAuthenticationService::credentials", "");
  }
  return *creds;
}
const coral::IAuthenticationCredentials & cond::RelationalAuthenticationService::RelationalAuthenticationService::credentials ( const std::string &  connectionString,
const std::string &  role 
) const

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 71 of file RelationalAuthenticationService.cc.

References Debug, edm::endmsg(), funct::log(), and lumiQueryAPI::msg.

{
  const coral::IAuthenticationCredentials* creds = m_cache.get( connectionString, role );
  if( !creds ){
    std::string credsStoreConn = m_db.setUpForConnectionString( connectionString, m_authenticationPath );
    coral::MessageStream log("cond::RelationalAuthenticationService::credentials");
    log << coral::Debug << "Connecting to the credential repository in \"" << credsStoreConn << "\" with principal \""<<m_db.keyPrincipalName()<<"\"."<<coral::MessageStream::endmsg;
    m_db.selectForUser( m_cache );
  } 
  creds = m_cache.get( connectionString, role );
  if( ! creds ){
    std::string msg("No Authentication available for connection=\"");
    msg += connectionString + "\".";
    msg += " and role=\"" + role + "\".";
    throw coral::AuthenticationServiceException( msg, "cond::RelationalAuthenticationService::RelationalAuthenticationService::credentials","");
  }
  return *creds;
}
void cond::RelationalAuthenticationService::RelationalAuthenticationService::setAuthenticationPath ( const std::string &  inputPath)

Sets the input file name.

Definition at line 45 of file RelationalAuthenticationService.cc.

Referenced by RelationalAuthenticationService().

{
  m_authenticationPath = inputPath;
  m_cache.reset();
}

Member Data Documentation

The input file with the data.

Definition at line 59 of file RelationalAuthenticationService.h.

Definition at line 64 of file RelationalAuthenticationService.h.

Definition at line 66 of file RelationalAuthenticationService.h.

Referenced by RelationalAuthenticationService().

The service providing the authentication data.

Definition at line 62 of file RelationalAuthenticationService.h.