Ejemplo n.º 1
0
/**
 * \brief Constructor
 * \param sessionKey The session key of the session
 * \param timeout Lenght of the connection before timeout
 */
SessionServer::SessionServer(std::string sessionKey, int timeout)
  : mtimeout(timeout)
{
  DbFactory factory;
  msession.setSessionKey(sessionKey);
  mdatabase = factory.getDatabaseInstance();
}
Ejemplo n.º 2
0
/**
 * \brief Constructor
 * \param session The session data structure
 * \param timeout Lenght of the connection before timeout
 */
SessionServer::SessionServer(const UMS_Data::Session& session, int timeout)
  : msession(session),
    mtimeout(timeout)
{
  DbFactory factory;
  mdatabase = factory.getDatabaseInstance();
}
Ejemplo n.º 3
0
/**
* \brief Constructor
* \fn UserServer(std::string userId, std::string password)
* \param userId The userId of the user
* \param password The password of the user
*/
UserServer::UserServer(std::string userId, std::string password) {
  DbFactory factory;
  muser.setUserId(userId);
  muser.setPassword(password);
  mdatabaseVishnu = factory.getDatabaseInstance();
  msessionServer = NULL;
}
Ejemplo n.º 4
0
/**
 * \brief Constructor
 */
SessionServer::SessionServer()
  : mtimeout(DEFAULT_CONNECTION_TIMEOUT)
{
  DbFactory factory;
  msession.setSessionKey("");
  mdatabase = factory.getDatabaseInstance();
}
Ejemplo n.º 5
0
bool
UMSAuthenticator::authenticate(UMS_Data::User& user) {
  DbFactory factory;
  Database* databaseVishnu = factory.getDatabaseInstance();

  //To encrypt the clear password
  user.setPassword(vishnu::cryptPassword(user.getUserId(), user.getPassword()));
  std::string sqlCommand = (boost::format("SELECT numuserid"
                                          " FROM users"
                                          " WHERE userid='%1%'"
                                          " AND pwd='%2%'"
                                          " AND users.status<>%3%"
                              )%databaseVishnu->escapeData(user.getUserId()) %databaseVishnu->escapeData(user.getPassword()) %vishnu::STATUS_DELETED).str();
  boost::scoped_ptr<DatabaseResult> result(databaseVishnu->getResult(sqlCommand.c_str()));
  return (result->getFirstElement().size() != 0);
}
Ejemplo n.º 6
0
int
registerSeD(const std::string& sedUri,
            const std::string& dispUri,
            const std::string& sedType,
            const ExecConfiguration& config,
            std::vector<std::string>& services) {

  std::string mid;
  std::string uriSupervisor;

  // Getting the machine id
  if (sedType == "umssed") { // if ums
    config.getConfigValue<std::string>(vishnu::MACHINEID, mid);
  } else {
    config.getRequiredConfigValue<std::string>(vishnu::MACHINEID, mid);
  }

  int timeout  = vishnu::DEFAUT_TIMEOUT;
  config.getConfigValue<int>(vishnu::TIMEOUT, timeout);

  if (config.getConfigValue<std::string>(vishnu::URISUPERVISOR, uriSupervisor) &&
      vishnu::isNew(uriSupervisor, mid, sedType)) {
    try {
      DbFactory factory;
      Database* database = factory.getDatabaseInstance();

      std::string request = (boost::format("INSERT INTO process (dietname, launchscript,"
                                           "            machineid, pstatus, uptime, vishnuname)"
                                           " VALUES ('%1%','%2%','%3%',%4%,CURRENT_TIMESTAMP, '%5%')")
                             %uriSupervisor
                             %database->escapeData(config.scriptToString())
                             %mid
                             %vishnu::convertToString(vishnu::PRUNNING)
                             %sedType
                             ).str();

      database->process(request.c_str());
    } catch (...) {
      if (sedType == "umssed") { throw; }
    }
  }

  return 0;
}
Ejemplo n.º 7
0
SysInfoServer::SysInfoServer(const UserServer session):msession(session) {
  DbFactory factory;
  mdatabase = factory.getDatabaseInstance();
  mvishnuId = 1;
}
Ejemplo n.º 8
0
/**
* \brief Constructor
* \fn UserServer(SessionServer sessionServer)
* \param sessionServer The object to manipulate session
*/
UserServer::UserServer(SessionServer sessionServer): msessionServer(&sessionServer) {
  DbFactory factory;
  mdatabaseVishnu = factory.getDatabaseInstance();
}
Ejemplo n.º 9
0
/**
* \brief Constructor
* \fn UserServer(const UMS_Data::User& user)
* \param user The user data structure
*/
UserServer::UserServer(const UMS_Data::User& user):muser(user) {
  DbFactory factory;
  mdatabaseVishnu = factory.getDatabaseInstance();
  msessionServer = NULL;
}
Ejemplo n.º 10
0
bool
LDAPAuthenticator::authenticate(UMS_Data::User& user) {
  bool authenticated = false;
  std::string uri, authlogin, authpassword, ldapbase, authSystemStatus, userid, pwd;

  DbFactory factory;
  Database* databaseVishnu = factory.getDatabaseInstance();
  std::string sqlCommand = (boost::format("SELECT uri, authlogin, authpassword, ldapbase, authsystem.status, userid, pwd"
                                          " FROM ldapauthsystem, authsystem, authaccount, users"
                                          " WHERE aclogin='******'"
                                          " AND authsystem.authtype=%2%"
                                          " AND authaccount.authsystem_authsystemid=authsystem.numauthsystemid"
                                          " AND ldapauthsystem.authsystem_authsystemid=authsystem.numauthsystemid"
                                          " AND authaccount.users_numuserid=users.numuserid"
                                          " AND authsystem.status<>%3%"
                                          " AND users.status<>%4%"
                              )%databaseVishnu->escapeData(user.getUserId()) %LDAPTYPE %vishnu::STATUS_DELETED %vishnu::STATUS_DELETED).str();

  boost::scoped_ptr<DatabaseResult> result(databaseVishnu->getResult(sqlCommand.c_str()));

  //If there is no results
  if (result->getNbTuples() == 0) {
    UMSVishnuException e (ERRCODE_UNKNOWN_USER, "There is no user-authentication account declared in VISHNU with this identifier");
    throw e;
  }

  std::vector<std::string> tmp;
  std::vector<std::string>::iterator ii;
  for (int i = 0; i < static_cast <int> (result->getNbTuples()); ++i) {
    tmp.clear();
    tmp = result->get(i);

    ii=tmp.begin();
    uri = *ii;
    authlogin = *(++ii);
    authpassword = *(++ii);
    ldapbase = *(++ii);
    authSystemStatus = *(++ii);
    userid = *(++ii);
    pwd = *(++ii);

    if (vishnu::convertToInt(authSystemStatus) != vishnu::STATUS_ACTIVE) {
      UMSVishnuException e (ERRCODE_UNKNOWN_AUTH_SYSTEM, "It is locked");
      throw e;
    }

    try {
      LDAPProxy ldapPoxy(uri,
                         user.getUserId(),
                         "",
                         user.getPassword());
      ldapPoxy.connectLDAP(ldapbase);
      authenticated = true;
      user.setUserId(userid);
      user.setPassword(pwd);
      break;
    }
    catch (UMSVishnuException& e) {
      if (e.getMsgI() != ERRCODE_UNKNOWN_USER) {
        throw UMSVishnuException(e);
      }
    }
    catch (SystemException& e) {
      //If there is a connection problem to LDAP and it is not the last LDAP account to check
      if ((e.getMsgI() == ERRCODE_AUTHENTERR) && (i == (static_cast <int> (result->getNbTuples())-1))) {
        throw SystemException(e);
      }
    }
  }
  return authenticated;
}
Ejemplo n.º 11
0
/**
* \brief Constructor
* \param machine The machine data structure
* \param session The object which encapsulates session data
*/
MachineServer::MachineServer(UMS_Data::Machine*& machine, SessionServer& session):
  mmachine(machine), msessionServer(session)
{
  DbFactory factory;
  mdatabase = factory.getDatabaseInstance();
}
Ejemplo n.º 12
0
/**
* \brief Constructor
* \param machine The machine data structure
*/
MachineServer::MachineServer(UMS_Data::Machine*& machine):
  mmachine(machine)
{
  DbFactory factory;
  mdatabase = factory.getDatabaseInstance();
}
Ejemplo n.º 13
0
/**
 * \brief Constructor
 * \param session The session data structure
 */
SessionServer::SessionServer(const UMS_Data::Session& session):msession(session) {
  DbFactory factory;
  mdatabaseVishnu = factory.getDatabaseInstance();
}
Ejemplo n.º 14
0
/**
 * \brief Constructor
 * \param sessionKey The session key of the session
 */
SessionServer::SessionServer(std::string sessionKey) {
  DbFactory factory;
  msession.setSessionKey(sessionKey);
  mdatabaseVishnu = factory.getDatabaseInstance();
}
Ejemplo n.º 15
0
/**
 * \brief Constructor
 */
SessionServer::SessionServer() {
  DbFactory factory;
  msession.setSessionKey("");
  mdatabaseVishnu = factory.getDatabaseInstance();
}