Back to index

nordugrid-arc-nox  1.1.0~rc6
Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes
Arc::UserConfig Class Reference

User configuration class More...

#include <UserConfig.h>

Collaboration diagram for Arc::UserConfig:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 UserConfig (initializeCredentialsType initializeCredentials=initializeCredentialsType())
 Create a UserConfig object.
 UserConfig (const std::string &conffile, initializeCredentialsType initializeCredentials=initializeCredentialsType(), bool loadSysConfig=true)
 Create a UserConfig object.
 UserConfig (const std::string &conffile, const std::string &jfile, initializeCredentialsType initializeCredentials=initializeCredentialsType(), bool loadSysConfig=true)
 Create a UserConfig object.
 UserConfig (const long int &ptraddr)
 Language binding constructor.
 ~UserConfig ()
void InitializeCredentials ()
 Initialize user credentials.
bool CredentialsFound () const
 Validate credential location.
bool LoadConfigurationFile (const std::string &conffile, bool ignoreJobListFile=true)
 Load specified configuration file.
bool SaveToFile (const std::string &filename) const
 Save to INI file.
void ApplyToConfig (BaseConfig &ccfg) const
 Apply credentials to BaseConfig.
 operator bool () const
 Check for validity.
bool operator! () const
 Check for non-validity.
bool JobListFile (const std::string &path)
 Set path to job list file.
const std::string & JobListFile () const
 Get a reference to the path of the job list file.
bool AddServices (const std::list< std::string > &services, ServiceType st)
 Add selected and rejected services.
bool AddServices (const std::list< std::string > &selected, const std::list< std::string > &rejected, ServiceType st)
 Add selected and rejected services.
const URLListMapGetSelectedServices (ServiceType st) const
 Get selected services.
const URLListMapGetRejectedServices (ServiceType st) const
 Get rejected services.
void ClearSelectedServices ()
 Clear selected services.
void ClearSelectedServices (ServiceType st)
 Clear selected services with specified ServiceType.
void ClearRejectedServices ()
 Clear selected services.
void ClearRejectedServices (ServiceType st)
 Clear rejected services with specified ServiceType.
bool Timeout (int newTimeout)
 Set timeout.
int Timeout () const
 Get timeout.
bool Verbosity (const std::string &newVerbosity)
 Set verbosity.
const std::string & Verbosity () const
 Get the user selected level of verbosity.
bool Broker (const std::string &name)
 Set broker to use in target matching.
bool Broker (const std::string &name, const std::string &argument)
 Set broker to use in target matching.
const std::pair< std::string,
std::string > & 
Broker () const
 Get the broker and corresponding arguments.
bool Bartender (const std::vector< URL > &urls)
 Set bartenders, used to contact Chelonia.
void AddBartender (const URL &url)
 Set bartenders, used to contact Chelonia.
const std::vector< URL > & Bartender () const
 Get bartenders.
bool VOMSServerPath (const std::string &path)
 Set path to file containing VOMS configuration.
const std::string & VOMSServerPath () const
 Get path to file containing VOMS configuration.
bool UserName (const std::string &name)
 Set user-name for SLCS.
const std::string & UserName () const
 Get user-name.
bool Password (const std::string &newPassword)
 Set password.
const std::string & Password () const
 Get password.
bool ProxyPath (const std::string &newProxyPath)
 Set path to user proxy.
const std::string & ProxyPath () const
 Get path to user proxy.
bool CertificatePath (const std::string &newCertificatePath)
 Set path to certificate.
const std::string & CertificatePath () const
 Get path to certificate.
bool KeyPath (const std::string &newKeyPath)
 Set path to key.
const std::string & KeyPath () const
 Get path to key.
bool KeyPassword (const std::string &newKeyPassword)
 Set password for generated key.
const std::string & KeyPassword () const
 Get password for generated key.
bool KeySize (int newKeySize)
 Set key size.
int KeySize () const
 Get key size.
bool CACertificatePath (const std::string &newCACertificatePath)
 Set CA-certificate path.
const std::string & CACertificatePath () const
 Get path to CA-certificate.
bool CACertificatesDirectory (const std::string &newCACertificatesDirectory)
 Set path to CA-certificate directory.
const std::string & CACertificatesDirectory () const
 Get path to CA-certificate directory.
bool CertificateLifeTime (const Period &newCertificateLifeTime)
 Set certificate life time.
const PeriodCertificateLifeTime () const
 Get certificate life time.
bool SLCS (const URL &newSLCS)
 Set the URL to the Short Lived Certificate Service (SLCS).
const URLSLCS () const
 Get the URL to the Short Lived Certificate Service (SLCS).
bool StoreDirectory (const std::string &newStoreDirectory)
 Set store directory.
const std::string & StoreDirectory () const
 Get store diretory.
bool IdPName (const std::string &name)
 Set IdP name.
const std::string & IdPName () const
 Get IdP name.
bool OverlayFile (const std::string &path)
 Set path to configuration overlay file.
const std::string & OverlayFile () const
 Get path to configuration overlay file.
bool UtilsDirPath (const std::string &dir)
 Set path to directory storing utility files for DataPoints.
const std::string & UtilsDirPath () const
 Get path to directory storing utility files for DataPoints.

Static Public Attributes

static const std::string ARCUSERDIRECTORY = Glib::build_filename(User().Home(), ".arc")
 Path to ARC user home directory.
static const std::string SYSCONFIG = Glib::build_filename(PKGSYSCONFDIR, "client.conf")
 Path to system configuration.
static const std::string DEFAULTCONFIG = Glib::build_filename(ARCUSERDIRECTORY, "client.conf")
 Path to default configuration file.
static const std::string EXAMPLECONFIG = Glib::build_filename(PKGDATADIR G_DIR_SEPARATOR_S "examples", "client.conf.example")
 Path to example configuration.
static const int DEFAULT_TIMEOUT = 20
 Default timeout in seconds.
static const std::string DEFAULT_BROKER = "Random"
 Default broker.

Private Member Functions

void setDefaults ()
bool ResolveAlias (URLListMap &services, ServiceType st, std::list< std::string > &resolvedAlias)
bool ResolveAlias (std::pair< URLListMap, URLListMap > &services, std::list< std::string > &resolvedAlias)
bool CreateDefaultConfigurationFile () const

Static Private Member Functions

static bool makeDir (const std::string &path)
static bool copyFile (const std::string &source, const std::string &destination)

Private Attributes

std::string joblistfile
int timeout
std::string verbosity
std::pair< std::string,
std::string > 
broker
std::pair< URLListMap, URLListMapselectedServices
std::pair< URLListMap, URLListMaprejectedServices
std::vector< URLbartenders
std::string proxyPath
std::string certificatePath
std::string keyPath
std::string keyPassword
int keySize
std::string caCertificatePath
std::string caCertificatesDirectory
Period certificateLifeTime
URL slcs
std::string vomsServerPath
std::string storeDirectory
std::string idPName
std::string username
std::string password
std::string overlayfile
std::string utilsdir
XMLNode aliasMap
bool ok

Static Private Attributes

static Logger logger

Detailed Description

User configuration class

This class provides a container for a selection of various attributes/parameters which can be configured to needs of the user, and can be read by implementing instances or programs. The class can be used in two ways. One can create a object from a configuration file, or simply set the desired attributes by using the setter method, associated with every setable attribute. The list of attributes which can be configured in this class are:

where the first term is the name of the attribute used in the configuration file, and the second term is the associated setter method (for more information about a given attribute see the description of the setter method).

The configuration file should have a INI-style format and the IniConfig class will thus be used to parse the file. The above mentioned attributes should be placed in the common section. Another section is also valid in the configuration file, which is the alias section. Here it is possible to define aliases representing one or multiple services. These aliases can be used in the AddServices(const std::list<std::string>&, ServiceType) and AddServices(const std::list<std::string>&, const std::list<std::string>&, ServiceType) methods.

The UserConfig class also provides a method InitializeCredentials() for locating user credentials by searching in different standard locations. The CredentialsFound() method can be used to test if locating the credentials succeeded.

Definition at line 96 of file UserConfig.h.


Constructor & Destructor Documentation

Create a UserConfig object.

The UserConfig object created by this constructor initializes only default values, and if specified by the initializeCredentials boolean credentials will be tried initialized using the InitializeCredentials() method. The object is only non-valid if initialization of credentials fails which can be checked with the operator bool() method.

Parameters:
initializeCredentialsis a optional boolean indicating if the InitializeCredentials() method should be invoked, the default is true.
See also:
InitializeCredentials()
operator bool()

Definition at line 63 of file UserConfig.cpp.

                                                                        {
    if (initializeCredentials != initializeCredentialsType::SkipCredentials) {
      InitializeCredentials();
      if ((!CredentialsFound()) && (initializeCredentials == initializeCredentialsType::RequireCredentials))
        return;
    }

    ok = true;

    setDefaults();
  }

Here is the call graph for this function:

Arc::UserConfig::UserConfig ( const std::string &  conffile,
initializeCredentialsType  initializeCredentials = initializeCredentialsType(),
bool  loadSysConfig = true 
)

Create a UserConfig object.

The UserConfig object created by this constructor will, if specified by the loadSysConfig boolean, first try to load the system configuration file by invoking the LoadConfigurationFile() method, and if this fails a WARNING is reported. Then the configuration file passed will be tried loaded using the before mentioned method, and if this fails an ERROR is reported, and the created object will be non-valid. Note that if the passed file path is empty the example configuration will be tried copied to the default configuration file path specified by DEFAULTCONFIG. If the example file cannot be copied one or more WARNING messages will be reported and no configration will be loaded. If loading the configurations file succeeded and if initializeCredentials is true then credentials will be initialized using the InitializeCredentials() method, and if no valid credentials are found the created object will be non-valid.

Parameters:
conffileis the path to a INI-configuration file.
initializeCredentialsis a boolean indicating if credentials should be initialized, the default is true.
loadSysConfigis a boolean indicating if the system configuration file should be loaded aswell, the default is true.
See also:
LoadConfigurationFile(const std::string&, bool)
InitializeCredentials()
operator bool()
SYSCONFIG
EXAMPLECONFIG

Definition at line 75 of file UserConfig.cpp.

    : ok(false) {
    if (loadSysConfig) {
      if (!Glib::file_test(SYSCONFIG, Glib::FILE_TEST_IS_REGULAR))
        logger.msg(INFO, "System configuration file (%s) does not exist.", SYSCONFIG);
      else if (!LoadConfigurationFile(SYSCONFIG, true))
        logger.msg(INFO, "System configuration file (%s) contains errors.", SYSCONFIG);
    }

    if (conffile.empty()) {
      if (CreateDefaultConfigurationFile()) {
        if (!LoadConfigurationFile(DEFAULTCONFIG, false)) {
          logger.msg(WARNING, "User configuration file (%s) contains errors.", DEFAULTCONFIG);
          return;
        }
      }
      else
        logger.msg(INFO, "No configuration file could be loaded.");
    }
    else if (!Glib::file_test(conffile, Glib::FILE_TEST_IS_REGULAR)) {
      logger.msg(WARNING, "User configuration file (%s) does not exist or cannot be loaded.", conffile);
      return;
    }
    else if (!LoadConfigurationFile(conffile)) {
      logger.msg(WARNING, "User configuration file (%s) contains errors.", conffile);
      return;
    }

    if (initializeCredentials != initializeCredentialsType::SkipCredentials) {
      InitializeCredentials();
      if ((!CredentialsFound()) && (initializeCredentials == initializeCredentialsType::RequireCredentials))
        return;
    }

    ok = true;

    setDefaults();
  }

Here is the call graph for this function:

Arc::UserConfig::UserConfig ( const std::string &  conffile,
const std::string &  jfile,
initializeCredentialsType  initializeCredentials = initializeCredentialsType(),
bool  loadSysConfig = true 
)

Create a UserConfig object.

The UserConfig object created by this constructor does only differ from the UserConfig(const std::string&, bool, bool) constructor in that it is possible to pass the path of the job list file directly to this constructor. If the job list file joblistfile is empty, the behaviour of this constructor is exactly the same as the before mentioned, otherwise the job list file will be initilized by invoking the setter method JobListFile(const std::string&). If it fails the created object will be non-valid, otherwise the specified configuration file conffile will be loaded with the ignoreJobListFile argument set to true.

Parameters:
conffileis the path to a INI-configuration file
jfileis the path to a (non-)existing job list file.
initializeCredentialsis a boolean indicating if credentials should be initialized, the default is true.
loadSysConfigis a boolean indicating if the system configuration file should be loaded aswell, the default is true.
See also:
JobListFile(const std::string&)
LoadConfigurationFile(const std::string&, bool)
InitializeCredentials()
operator bool()

Definition at line 116 of file UserConfig.cpp.

    : ok(false) {
    // If job list file have been specified, try to initialize it, and
    // if it fails then this object is non-valid (ok = false).
    if (!jfile.empty() && !JobListFile(jfile))
      return;

    if (loadSysConfig) {
      if (!Glib::file_test(SYSCONFIG, Glib::FILE_TEST_IS_REGULAR))
        logger.msg(INFO, "System configuration file (%s) does not exist.", SYSCONFIG);
      else if (!LoadConfigurationFile(SYSCONFIG, true))
        logger.msg(INFO, "System configuration file (%s) contains errors.", SYSCONFIG);
    }

    if (conffile.empty()) {
      if (CreateDefaultConfigurationFile()) {
        if (!LoadConfigurationFile(DEFAULTCONFIG, !jfile.empty())) {
          logger.msg(WARNING, "User configuration file (%s) contains errors.", DEFAULTCONFIG);
          return;
        }
      }
      else
        logger.msg(INFO, "No configuration file could be loaded.");
    }
    else if (!Glib::file_test(conffile, Glib::FILE_TEST_IS_REGULAR)) {
      logger.msg(WARNING, "User configuration file (%s) does not exist or cannot be loaded.", conffile);
      return;
    }
    else if (!LoadConfigurationFile(conffile)) {
      logger.msg(WARNING, "User configuration file (%s) contains errors.", conffile);
      return;
    }

    // If no job list file have been initialized use the default. If the
    // job list file cannot be initialized this object is non-valid.
    if (joblistfile.empty() && !JobListFile(Glib::build_filename(ARCUSERDIRECTORY, "jobs.xml")))
      return;

    if (initializeCredentials != initializeCredentialsType::SkipCredentials) {
      InitializeCredentials();
      if ((!CredentialsFound()) && (initializeCredentials == initializeCredentialsType::RequireCredentials))
        return;
    }

    ok = true;

    setDefaults();
  }

Here is the call graph for this function:

Arc::UserConfig::UserConfig ( const long int &  ptraddr)

Language binding constructor.

The passed long int should be a pointer address to a UserConfig object, and this address is then casted into this UserConfig object.

Parameters:
ptraddris an memory address to a UserConfig object.

Definition at line 166 of file UserConfig.cpp.

{ *this = *((UserConfig*)ptraddr); }

Definition at line 186 of file UserConfig.h.

{}

Member Function Documentation

void Arc::UserConfig::AddBartender ( const URL url) [inline]

Set bartenders, used to contact Chelonia.

Takes as input a Bartender URL and adds this to the list of bartenders.

Parameters:
urlis a URL to be added to the list of bartenders.
See also:
Bartender(const std::list<URL>&)
Bartender() const

Definition at line 686 of file UserConfig.h.

{ bartenders.push_back(url); }
bool Arc::UserConfig::AddServices ( const std::list< std::string > &  services,
ServiceType  st 
)

Add selected and rejected services.

This method adds selected services and adds services to reject from the specified list services, which contains string objects. The syntax of a single element in the list must be expressed in the following two formats:

\[ [-]<flavour>:<service\_url>|[-]<alias> \]

where the optional '-' indicate that the service should be added to the private list of services to reject. In the first format the <flavour> part indicates the type of ACC plugin to use when contacting the service, which is specified by the URL <service_url>, and in the second format the <alias> part specifies a alias defined in a parsed configuration file, note that the alias must not contain any of the charaters ':', '.', ' ' or '\t'. If a alias cannot be resolved an ERROR will be reported to the logger and the method will return false. If a element in the list services cannot be parsed an ERROR will be reported, and the element is skipped.

Two attributes are indirectly associated with this setter method 'defaultservices' and 'rejectservices'. The values specified with the 'defaultservices' attribute will be added to the list of selected services, and like-wise with the 'rejectservices' attribute.

Parameters:
servicesis a list of services to either select or reject.
stindicates the type of the specfied services.
Returns:
This method returns false in case an alias cannot be resolved. In any other case true is returned.
See also:
AddServices(const std::string&, const std::string&, ServiceType)
GetSelectedServices()
GetRejectedServices()
ClearSelectedServices()
ClearRejectedServices()
LoadConfigurationFile()

Definition at line 728 of file UserConfig.cpp.

                                                                                 {
    const std::string serviceType = tostring(st);
    for (std::list<std::string>::const_iterator it = services.begin();
         it != services.end(); it++) {
      URLListMap& servicesRef = ((*it)[0] != '-' ? (st == COMPUTING ? selectedServices.first : selectedServices.second)
                                                 : (st == COMPUTING ? rejectedServices.first : rejectedServices.second));

      const std::string service = ((*it)[0] != '-' ? *it : it->substr(1));

      // Alias cannot contain '.', ':', ' ' or '\t' and a URL must contain atleast one of ':' or '.'.
      if (service.find_first_of(":. \t") == std::string::npos) { // Alias.
        if (!aliasMap[service]) {
          logger.msg(ERROR, "Could not resolve alias \"%s\" it is not defined.", service);
          return false;
        }

        std::list<std::string> resolvedAliases(1, service);
        if (!ResolveAlias(servicesRef, st, resolvedAliases))
          return false;
      }
      else { // URL
        const std::size_t pos = service.find(":");
        if (pos == std::string::npos) {
          logger.msg(WARNING, "Cannot parse the specified %s service (%s)", serviceType, service);
          continue;
        }

        const URL url(service.substr(pos+1));
        if (!url || url.Protocol() == "file") {
          logger.msg(WARNING, "The specified %s service (%s) is not a valid URL", serviceType, service.substr(pos+1));
          continue;
        }
        const std::string flavour = service.substr(0, pos);
        logger.msg(VERBOSE, "Adding %s service %s:%s ", (*it)[0] != '-' ? "selected" : "rejected", flavour, url.str());
        servicesRef[flavour].push_back(url);
      }
    }

    return true;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

bool Arc::UserConfig::AddServices ( const std::list< std::string > &  selected,
const std::list< std::string > &  rejected,
ServiceType  st 
)

Add selected and rejected services.

The only diffence in behaviour of this method compared to the AddServices(const std::list<std::string>&, ServiceType) method is the input parameters and the format these parameters should follow. Instead of having an optional '-' in front of the string selected and rejected services should be specified in the two different arguments.

Two attributes are indirectly associated with this setter method 'defaultservices' and 'rejectservices'. The values specified with the 'defaultservices' attribute will be added to the list of selected services, and like-wise with the 'rejectservices' attribute.

Parameters:
selectedis a list of services which will be added to the selected services of this object.
rejectedis a list of services which will be added to the rejected services of this object.
stspecifies the ServiceType of the services to add.
Returns:
This method return false in case an alias cannot be resolved. In any other case true is returned.
See also:
AddServices(const std::list<std::string>&, ServiceType)
GetSelectedServices()
GetRejectedServices()
ClearSelectedServices()
ClearRejectedServices()
LoadConfigurationFile()

Definition at line 769 of file UserConfig.cpp.

                                               {
    bool isSelectedNotRejected = true;
    const std::string serviceType = tostring(st);
    for (std::list<std::string>::const_iterator it = selected.begin();
         it != selected.end(); it++) {
      if (it == selected.end()) {
        if (selected.empty())
          break;
        it = selected.begin();
        isSelectedNotRejected = false;
      }

      URLListMap& servicesRef = (isSelectedNotRejected ? (st == COMPUTING ? selectedServices.first : selectedServices.second)
                                                       : (st == COMPUTING ? rejectedServices.first : rejectedServices.second));
      const std::string& service = *it;

      // Alias cannot contain '.', ':', ' ' or '\t' and a URL must contain atleast one of ':' or '.'.
      if (service.find_first_of(":. \t") == std::string::npos) { // Alias.
        if (!aliasMap[service]) {
          logger.msg(ERROR, "Could not resolve alias \"%s\" it is not defined.", service);
          return false;
        }

        std::list<std::string> resolvedAliases(1, service);
        if (!ResolveAlias(servicesRef, st, resolvedAliases))
          return false;
      }
      else { // URL
        const std::size_t pos = service.find(":");
        if (pos == std::string::npos) {
          logger.msg(WARNING, "Cannot parse the specified %s service (%s)", serviceType, service);
          continue;
        }

        const URL url(service.substr(pos+1));
        if (!url || url.Protocol() == "file") {
          logger.msg(WARNING, "The specified %s service (%s) is not a valid URL", serviceType, service.substr(pos+1));
          continue;
        }
        const std::string flavour = service.substr(0, pos);
        logger.msg(VERBOSE, "Adding %s service %s:%s ", isSelectedNotRejected ? "selected" : "rejected", flavour, url.str());
        servicesRef[flavour].push_back(url);
      }
    }

    return true;
  }

Here is the call graph for this function:

Apply credentials to BaseConfig.

This methods sets the BaseConfig credentials to the credentials contained in this object. It also passes user defined configuration overlay if any.

See also:
InitializeCredentials()
CredentialsFound()
BaseConfig
Parameters:
ccfga BaseConfig object which will configured with the credentials of this object.

Definition at line 168 of file UserConfig.cpp.

                                                       {
    if (!proxyPath.empty())
      ccfg.AddProxy(proxyPath);
    else {
      ccfg.AddCertificate(certificatePath);
      ccfg.AddPrivateKey(keyPath);
    }

    ccfg.AddCADir(caCertificatesDirectory);

    if(!overlayfile.empty())
      ccfg.GetOverlay(overlayfile);
  }

Here is the call graph for this function:

bool Arc::UserConfig::Bartender ( const std::vector< URL > &  urls) [inline]

Set bartenders, used to contact Chelonia.

Takes as input a vector of Bartender URLs.

The attribute associated with this setter method is 'bartender'.

Parameters:
urlsis a list of URL object to be set as bartenders.
Returns:
This method always returns true.
See also:
AddBartender(const URL&)
Bartender() const

Definition at line 676 of file UserConfig.h.

{ bartenders = urls; return true; }

Here is the caller graph for this function:

const std::vector<URL>& Arc::UserConfig::Bartender ( ) const [inline]

Get bartenders.

Returns a list of Bartender URLs

Returns:
The list of bartender URL objects is returned.
See also:
Bartender(const std::list<URL>&)
AddBartender(const URL&)

Definition at line 695 of file UserConfig.h.

{ return bartenders; }
bool Arc::UserConfig::Broker ( const std::string &  name)

Set broker to use in target matching.

The string passed to this method should be in the format:

\[<name>[:<argument>]\]

where the <name> is the name of the broker and cannot contain any ':', and the optional <argument> should contain arguments which should be passed to the broker.

Two attributes are associated with this setter method 'brokername' and 'brokerarguments'.

Parameters:
namethe broker name and argument specified in the format given above.
Returns:
This method allways returns true.
See also:
Broker
Broker(const std::string&, const std::string&)
Broker() const
DEFAULT_BROKER

Definition at line 236 of file UserConfig.cpp.

                                                           {
    const std::size_t pos = nameandarguments.find(":");
    if (pos != std::string::npos) // Arguments given in 'nameandarguments'
      broker = std::make_pair<std::string, std::string>(nameandarguments.substr(0, pos),
                                                        nameandarguments.substr(pos+1));
    else
      broker = std::make_pair<std::string, std::string>(nameandarguments, "");

    return true;
  }

Here is the caller graph for this function:

bool Arc::UserConfig::Broker ( const std::string &  name,
const std::string &  argument 
) [inline]

Set broker to use in target matching.

As opposed to the Broker(const std::string&) method this method sets broker name and arguments directly from the passed two arguments.

Two attributes are associated with this setter method 'brokername' and 'brokerarguments'.

Parameters:
nameis the name of the broker.
argumentis the arguments of the broker.
Returns:
This method always returns true.
See also:
Broker
Broker(const std::string&)
Broker() const
DEFAULT_BROKER

Definition at line 653 of file UserConfig.h.

{ broker = std::make_pair<std::string, std::string>(name, argument); return true;}
const std::pair<std::string, std::string>& Arc::UserConfig::Broker ( ) const [inline]

Get the broker and corresponding arguments.

The returned pair contains the broker name as the first component and the argument as the second.

See also:
Broker(const std::string&)
Broker(const std::string&, const std::string&)
DEFAULT_BROKER

Definition at line 663 of file UserConfig.h.

{ return broker; }
bool Arc::UserConfig::CACertificatePath ( const std::string &  newCACertificatePath) [inline]

Set CA-certificate path.

The path to the file containing CA-certificate will be set when calling this method. This configuration parameter is deprecated - use CACertificatesDirectory instead. Only arcslcs uses it.

The attribute associated with this setter method is 'cacertificatepath'.

Parameters:
newCACertificatePathis the path to the CA-certificate.
Returns:
This method always returns true.
See also:
CACertificatePath() const

Definition at line 920 of file UserConfig.h.

{ caCertificatePath = newCACertificatePath; return true; }

Here is the caller graph for this function:

const std::string& Arc::UserConfig::CACertificatePath ( ) const [inline]

Get path to CA-certificate.

Retrieve the path to the file containing CA-certificate. This configuration parameter is deprecated.

Returns:
The path to the CA-certificate is returned.
See also:
CACertificatePath(const std::string&)

Definition at line 929 of file UserConfig.h.

{ return caCertificatePath; }

Here is the caller graph for this function:

bool Arc::UserConfig::CACertificatesDirectory ( const std::string &  newCACertificatesDirectory) [inline]

Set path to CA-certificate directory.

The path to the directory containing CA-certificates will be set when calling this method. Note that the InitializeCredentials() method will also try to set this path, by searching in different locations.

The attribute associated with this setter method is 'cacertificatesdirectory'.

Parameters:
newCACertificatesDirectoryis the path to the CA-certificate directory.
Returns:
This method always returns true.
See also:
InitializeCredentials()
CredentialsFound() const
CACertificatesDirectory() const

Definition at line 948 of file UserConfig.h.

{ caCertificatesDirectory = newCACertificatesDirectory; return true; }

Here is the caller graph for this function:

const std::string& Arc::UserConfig::CACertificatesDirectory ( ) const [inline]

Get path to CA-certificate directory.

Retrieve the path to the CA-certificate directory.

Returns:
The path to the CA-certificate directory is returned.
See also:
InitializeCredentials()
CredentialsFound() const
CACertificatesDirectory(const std::string&)

Definition at line 958 of file UserConfig.h.

Here is the caller graph for this function:

bool Arc::UserConfig::CertificateLifeTime ( const Period newCertificateLifeTime) [inline]

Set certificate life time.

Sets lifetime of user certificate which will be obtained from Short Lived Credentials Service.

The attribute associated with this setter method is 'certificatelifetime'.

Parameters:
newCertificateLifeTimeis the life time of a certificate, as a Period object.
Returns:
This method always returns true.
See also:
CertificateLifeTime() const

Definition at line 973 of file UserConfig.h.

{ certificateLifeTime = newCertificateLifeTime; return true; }

Here is the caller graph for this function:

const Period& Arc::UserConfig::CertificateLifeTime ( ) const [inline]

Get certificate life time.

Gets lifetime of user certificate which will be obtained from Short Lived Credentials Service.

Returns:
The certificate life time is returned as a Period object.
See also:
CertificateLifeTime(const Period&)

Definition at line 982 of file UserConfig.h.

{ return certificateLifeTime; }
bool Arc::UserConfig::CertificatePath ( const std::string &  newCertificatePath) [inline]

Set path to certificate.

The path to user certificate will be set by this method. The path to the correcsponding key can be set with the KeyPath(const std::string&) method. Note that the InitializeCredentials() method will also try to set this path, by searching in different locations.

The attribute associated with this setter method is 'certificatepath'.

Parameters:
newCertificatePathis the path to the new certificate.
Returns:
This method always returns true.
See also:
InitializeCredentials()
CredentialsFound() const
CertificatePath() const
KeyPath(const std::string&)

Definition at line 807 of file UserConfig.h.

{ certificatePath = newCertificatePath; return true; }

Here is the caller graph for this function:

const std::string& Arc::UserConfig::CertificatePath ( ) const [inline]

Get path to certificate.

The path to the cerficate is returned when invoking this method.

Returns:
The certificate path is returned.
See also:
InitializeCredentials()
CredentialsFound() const
CertificatePath(const std::string&)
KeyPath() const

Definition at line 817 of file UserConfig.h.

{ return certificatePath; }

Here is the caller graph for this function:

Clear selected services.

Calling this method will cause the internally stored rejected services to be cleared.

See also:
ClearRejectedServices(ServiceType)
ClearSelectedServices()
AddServices(const std::list<std::string>&, ServiceType)
AddServices(const std::list<std::string>&, const std::list<std::string>&, ServiceType)
GetRejectedServices()

Definition at line 846 of file UserConfig.cpp.

                                         {
    rejectedServices.first.clear();
    rejectedServices.second.clear();
  }

Clear rejected services with specified ServiceType.

Calling this method will cause the internally stored rejected services with the ServiceType st to be cleared.

See also:
ClearRejectedServices()
ClearSelectedServices(ServiceType)
AddServices(const std::list<std::string>&, ServiceType)
AddServices(const std::list<std::string>&, const std::list<std::string>&, ServiceType)
GetRejectedServices()

Definition at line 839 of file UserConfig.cpp.

                                                       {
    if (st == COMPUTING)
      rejectedServices.first.clear();
    else
      rejectedServices.second.clear();
  }

Clear selected services.

Calling this method will cause the internally stored selected services to be cleared.

See also:
ClearSelectedServices(ServiceType)
ClearRejectedServices()
AddServices(const std::list<std::string>&, ServiceType)
AddServices(const std::list<std::string>&, const std::list<std::string>&, ServiceType)
GetSelectedServices()

Definition at line 834 of file UserConfig.cpp.

                                         {
    selectedServices.first.clear();
    selectedServices.second.clear();
  }

Here is the caller graph for this function:

Clear selected services with specified ServiceType.

Calling this method will cause the internally stored selected services with the ServiceType st to be cleared.

See also:
ClearSelectedServices()
ClearRejectedServices(ServiceType)
AddServices(const std::list<std::string>&, ServiceType)
AddServices(const std::list<std::string>&, const std::list<std::string>&, ServiceType)
GetSelectedServices()

Definition at line 827 of file UserConfig.cpp.

                                                       {
    if (st == COMPUTING)
      selectedServices.first.clear();
    else
      selectedServices.second.clear();
  }
bool Arc::UserConfig::copyFile ( const std::string &  source,
const std::string &  destination 
) [static, private]

Definition at line 994 of file UserConfig.cpp.

                                                                                 {
#ifdef HAVE_GIOMM
    try {
      return Gio::File::create_for_path(source)->copy(Gio::File::create_for_path(destination), Gio::FILE_COPY_NONE);
    } catch (Gio::Error e) {
      logger.msg(WARNING, "%s", (std::string)e.what());
      return false;
    }
#else
    std::ifstream ifsSource(source.c_str(), std::ios::in | std::ios::binary);
    if (!ifsSource)
      return false;

    std::ofstream ofsDestination(destination.c_str(), std::ios::out | std::ios::binary);
    if (!ofsDestination)
      return false;

    int bytesRead = -1;
    char buff[1024];
    while (bytesRead != 0) {
      ifsSource.read((char*)buff, 1024);
      bytesRead = ifsSource.gcount();
      ofsDestination.write((char*)buff, bytesRead);
    }

    return true;
#endif
  }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 688 of file UserConfig.cpp.

                                                        {
    // If the default configuration file does not exist, copy an example file.
    if (!Glib::file_test(DEFAULTCONFIG, Glib::FILE_TEST_EXISTS)) {

      // Check if the parent directory exist.
      if (!Glib::file_test(ARCUSERDIRECTORY, Glib::FILE_TEST_EXISTS)) {
        // Create directory.
        if (!makeDir(ARCUSERDIRECTORY)) {
          logger.msg(WARNING, "Unable to create %s directory.", ARCUSERDIRECTORY);
          return false;
        }
      }

      if (Glib::file_test(ARCUSERDIRECTORY, Glib::FILE_TEST_IS_DIR)) {
        if (Glib::file_test(EXAMPLECONFIG, Glib::FILE_TEST_IS_REGULAR)) {
          // Destination: Get basename, remove example prefix and add .arc directory.
          if (copyFile(EXAMPLECONFIG, DEFAULTCONFIG))
            logger.msg(INFO, "Configuration example file created (%s)", DEFAULTCONFIG);
          else
            logger.msg(WARNING, "Unable to copy example configuration from existing configuration (%s)", EXAMPLECONFIG);
            return false;
        }
        else {
          logger.msg(WARNING, "Cannot copy example configuration (%s), it is not a regular file", EXAMPLECONFIG);
          return false;
        }
      }
      else {
        logger.msg(WARNING, "Example configuration (%s) not created.", DEFAULTCONFIG);
        return false;
      }
    }
    else if (!Glib::file_test(DEFAULTCONFIG, Glib::FILE_TEST_IS_REGULAR)) {
      logger.msg(WARNING, "The default configuration file (%s) is not a regular file.", DEFAULTCONFIG);
      return false;
    }

    return true;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

bool Arc::UserConfig::CredentialsFound ( ) const [inline]

Validate credential location.

Valid credentials consists of a combination of a path to existing CA-certificate directory and either a path to existing proxy or a path to existing user key/certificate pair. If valid credentials are found this method returns true, otherwise false is returned.

Returns:
true if valid credentials are found, otherwise false.
See also:
InitializeCredentials()

Definition at line 266 of file UserConfig.h.

                                  {
      return !((proxyPath.empty() && (certificatePath.empty() || keyPath.empty())) || caCertificatesDirectory.empty());
    }

Here is the caller graph for this function:

Get rejected services.

Get the rejected services with the ServiceType specified by st.

Parameters:
stspecifies which ServiceType should be returned by the method.
Returns:
The rejected services is returned.
See also:
AddServices(const std::list<std::string>&, ServiceType)
AddServices(const std::list<std::string>&, const std::list<std::string>&, ServiceType)
GetSelectedServices(ServiceType)
ClearRejectedServices()

Definition at line 823 of file UserConfig.cpp.

                                                                        {
    return st == COMPUTING ? rejectedServices.first : rejectedServices.second;
  }

Here is the caller graph for this function:

Get selected services.

Get the selected services with the ServiceType specified by st.

Parameters:
stspecifies which ServiceType should be returned by the method.
Returns:
The selected services is returned.
See also:
AddServices(const std::list<std::string>&, ServiceType)
AddServices(const std::list<std::string>&, const std::list<std::string>&, ServiceType)
GetRejectedServices(ServiceType) const
ClearSelectedServices()

Definition at line 819 of file UserConfig.cpp.

                                                                        {
    return st == COMPUTING ? selectedServices.first : selectedServices.second;
  }

Here is the caller graph for this function:

bool Arc::UserConfig::IdPName ( const std::string &  name) [inline]

Set IdP name.

Sets Identity Provider name (Shibboleth) to which user belongs. It is used for contacting Short Lived Certificate Service.

The attribute associated with this setter method is 'idpname'.

Parameters:
nameis the new IdP name.
Returns:
This method always returns true.
See also:

Definition at line 1034 of file UserConfig.h.

{ idPName = name; return true; }

Here is the caller graph for this function:

const std::string& Arc::UserConfig::IdPName ( ) const [inline]

Get IdP name.

Gets Identity Provider name (Shibboleth) to which user belongs.

Returns:
The IdP name
See also:
IdPName(const std::string&)

Definition at line 1042 of file UserConfig.h.

{ return idPName; }

Here is the caller graph for this function:

Initialize user credentials.

The location of the user credentials will be tried located when calling this method and stored internally when found. The method searches in different locations. First the user proxy or the user key/certificate pair is tried located in the following order:

  • Proxy path specified by the environment variable X509_USER_PROXY
  • Key/certificate path specified by the environment X509_USER_KEY and X509_USER_CERT
  • Proxy path specified in either configuration file passed to the contructor or explicitly set using the setter method ProxyPath(const std::string&)
  • Key/certificate path specified in either configuration file passed to the constructor or explicitly set using the setter methods KeyPath(const std::string&) and CertificatePath(const std::string&)
  • ProxyPath with file name x509up_u concatenated with the user ID located in the OS temporary directory.

If the proxy or key/certificate pair have been explicitly specified only the specified path(s) will be tried, and if not found a ERROR is reported. If the proxy or key/certificate have not been specified and it is not located in the temporary directory a WARNING will be reported and the host key/certificate pair is tried and then the Globus key/certificate pair and a ERROR will be reported if not found in any of these locations.

Together with the proxy and key/certificate pair, the path to the directory containing CA certificates is also tried located when invoking this method. The directory will be tried located in the following order:

  • Path specified by the X509_CERT_DIR environment variable.
  • Path explicitly specified either in a parsed configuration file using the cacertficatecirectory or by using the setter method CACertificatesDirectory().
  • Path created by concatenating the output of User::Home() with '.globus' and 'certificates' separated by the directory delimeter.
  • Path created by concatenating the output of Glib::get_home_dir() with '.globus' and 'certificates' separated by the directory delimeter.
  • Path created by concatenating the output of ArcLocation::Get(), with 'etc' and 'certificates' separated by the directory delimeter.
  • Path created by concatenating the output of ArcLocation::Get(), with 'etc', 'grid-security' and 'certificates' separated by the directory delimeter.
  • Path created by concatenating the output of ArcLocation::Get(), with 'share' and 'certificates' separated by the directory delimeter.
  • Path created by concatenating 'etc', 'grid-security' and 'certificates' separated by the directory delimeter.

If the CA certificate directory have explicitly been specified and the directory does not exist a ERROR is reported. If none of the directories above does not exist a ERROR is reported.

See also:
CredentialsFound()
ProxyPath(const std::string&)
KeyPath(const std::string&)
CertificatePath(const std::string&)
CACertificatesDirectory(const std::string&)

Definition at line 247 of file UserConfig.cpp.

                                         {
    const User user;
    // Look for credentials.
    if (!GetEnv("X509_USER_PROXY").empty()) {
      if (!Glib::file_test(proxyPath = GetEnv("X509_USER_PROXY"), Glib::FILE_TEST_IS_REGULAR)) {
        logger.msg(ERROR, "Can not access proxy file: %s", proxyPath);
        proxyPath.clear();
      }
    }
    else if (!GetEnv("X509_USER_CERT").empty() &&
             !GetEnv("X509_USER_KEY").empty()) {
      if (!Glib::file_test(certificatePath = GetEnv("X509_USER_CERT"), Glib::FILE_TEST_IS_REGULAR)) {
        logger.msg(ERROR, "Can not access certificate file: %s", certificatePath);
        certificatePath.clear();
      }
      if (!Glib::file_test(keyPath = GetEnv("X509_USER_KEY"), Glib::FILE_TEST_IS_REGULAR)) {
        logger.msg(ERROR, "Can not access key file: %s", keyPath);
        keyPath.clear();
      }
    }
    else if (!proxyPath.empty()) {
      if (!Glib::file_test(proxyPath, Glib::FILE_TEST_IS_REGULAR)) {
        logger.msg(ERROR, "Can not access proxy file: %s", proxyPath);
        proxyPath.clear();
      }
    }
    else if (!certificatePath.empty() && !keyPath.empty()) {
      if (!Glib::file_test(certificatePath.c_str(), Glib::FILE_TEST_IS_REGULAR)) {
        logger.msg(ERROR, "Can not access certificate file: %s", certificatePath);
        certificatePath.clear();
      }
      if (!Glib::file_test(keyPath.c_str(), Glib::FILE_TEST_IS_REGULAR)) {
        logger.msg(ERROR, "Can not access key file: %s", keyPath);
        keyPath.clear();
      }
    }
    else if (!Glib::file_test(proxyPath = Glib::build_filename(Glib::get_tmp_dir(), std::string("x509up_u") + tostring(user.get_uid())), Glib::FILE_TEST_IS_REGULAR)) {
      logger.msg(WARNING, "Default proxy file does not exist: %s "
                          "trying default certificate and key", proxyPath);
      if (user.get_uid() == 0) {
        certificatePath = Glib::build_filename(G_DIR_SEPARATOR_S + std::string("etc"), std::string("grid-security") + G_DIR_SEPARATOR_S + std::string("hostcert.pem"));
        keyPath = Glib::build_filename(G_DIR_SEPARATOR_S + std::string("etc"), std::string("grid-security") + G_DIR_SEPARATOR_S + std::string("hostkey.pem"));
      }
      else {
        certificatePath = Glib::build_filename(user.Home(), std::string(".globus") + G_DIR_SEPARATOR_S +  std::string("usercert.pem"));
        keyPath = Glib::build_filename(user.Home(), std::string(".globus") + G_DIR_SEPARATOR_S + std::string("userkey.pem"));
      }
#ifdef WIN32
        certificatePath = Glib::build_filename(std::string(g_get_home_dir()), std::string(".globus") + G_DIR_SEPARATOR_S +  std::string("usercert.pem"));
        keyPath = Glib::build_filename(std::string(g_get_home_dir()), std::string(".globus") + G_DIR_SEPARATOR_S + std::string("userkey.pem"));
#endif

      if (!Glib::file_test(certificatePath, Glib::FILE_TEST_IS_REGULAR)) {
        logger.msg(ERROR, "Can not access certificate file: %s", certificatePath);
        certificatePath.clear();
      }
      if (!Glib::file_test(keyPath, Glib::FILE_TEST_IS_REGULAR)) {
        logger.msg(ERROR, "Can not access key file: %s", keyPath);
        keyPath.clear();
      }
    }

    if (!GetEnv("X509_CERT_DIR").empty()) {
      if (!Glib::file_test(caCertificatesDirectory = GetEnv("X509_CERT_DIR"), Glib::FILE_TEST_IS_DIR)) {
        logger.msg(ERROR, "Can not access CA certificate directory: %s", caCertificatesDirectory);
        caCertificatesDirectory.clear();
      }
    }
    else if (!caCertificatesDirectory.empty()) {
      if (!Glib::file_test(caCertificatesDirectory, Glib::FILE_TEST_IS_DIR)) {
        logger.msg(ERROR, "Can not access CA certificate directory: %s", caCertificatesDirectory);
        caCertificatesDirectory.clear();
      }
    }
    else if ((user.get_uid() == 0 || !Glib::file_test(caCertificatesDirectory = user.Home() + G_DIR_SEPARATOR_S + ".globus" + G_DIR_SEPARATOR_S + "certificates", Glib::FILE_TEST_IS_DIR)) &&
             !Glib::file_test(caCertificatesDirectory = std::string(Glib::get_home_dir()) + G_DIR_SEPARATOR_S + ".globus" + G_DIR_SEPARATOR_S + "certificates", Glib::FILE_TEST_IS_DIR) &&
             !Glib::file_test(caCertificatesDirectory = ArcLocation::Get() + G_DIR_SEPARATOR_S + "etc" + G_DIR_SEPARATOR_S + "certificates", Glib::FILE_TEST_IS_DIR) &&
             !Glib::file_test(caCertificatesDirectory = ArcLocation::Get() + G_DIR_SEPARATOR_S + "etc" + G_DIR_SEPARATOR_S + "grid-security" + G_DIR_SEPARATOR_S + "certificates", Glib::FILE_TEST_IS_DIR) &&
             !Glib::file_test(caCertificatesDirectory = ArcLocation::Get() + G_DIR_SEPARATOR_S + "share" + G_DIR_SEPARATOR_S + "certificates", Glib::FILE_TEST_IS_DIR)) {
      caCertificatesDirectory = Glib::build_filename(G_DIR_SEPARATOR_S + std::string("etc"), std::string("grid-security") + G_DIR_SEPARATOR_S + std::string("certificates"));
      if (!Glib::file_test(caCertificatesDirectory.c_str(), Glib::FILE_TEST_IS_DIR)) {
        logger.msg(ERROR, "Can not locate CA certificate directory.");
        caCertificatesDirectory.clear();
      }
    }

    if (!proxyPath.empty())
      logger.msg(INFO, "Using proxy file: %s", proxyPath);
    else if (!certificatePath.empty() && !keyPath.empty()) {
      logger.msg(INFO, "Using certificate file: %s", certificatePath);
      logger.msg(INFO, "Using key file: %s", keyPath);
    }

    if (!caCertificatesDirectory.empty())
      logger.msg(INFO, "Using CA certificate directory: %s", caCertificatesDirectory);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

bool Arc::UserConfig::JobListFile ( const std::string &  path)

Set path to job list file.

The method takes a path to a file which will be used as the job list file for storing and reading job information. If the specified path path does not exist a empty job list file will be tried created. If creating the job list file in any way fails false will be returned and a ERROR message will be reported. Otherwise true is returned. If the directory containing the file does not exist, it will be tried created. The method will also return false if the file is not a regular file.

The attribute associated with this setter method is 'joblist'.

Parameters:
paththe path to the job list file.
Returns:
If the job list file is a regular file or if it can be created true is returned, otherwise false is returned.
See also:
JobListFile() const

Definition at line 203 of file UserConfig.cpp.

                                                    {
    // Check if joblistfile exist.
    if (!Glib::file_test(path, Glib::FILE_TEST_EXISTS)) {
      // The joblistfile does not exist. Create a empty version, and if
      // this fails report an error and exit.
      const std::string joblistdir = Glib::path_get_dirname(path);

      // Check if the parent directory exist.
      if (!Glib::file_test(joblistdir, Glib::FILE_TEST_EXISTS)) {
        // Create directory.
        if (!makeDir(joblistdir)) {
          logger.msg(ERROR, "Unable to create %s directory", joblistdir);
          return false;
        }
      }
      else if (!Glib::file_test(joblistdir, Glib::FILE_TEST_IS_DIR)) {
        logger.msg(ERROR, "%s is not a directory, it is needed for the client to function correctly", joblistdir);
        return false;
      }

      NS ns;
      Config(ns).SaveToFile(path);
      logger.msg(INFO, "Created empty ARC job list file: %s", path);
    }
    else if (!Glib::file_test(path, Glib::FILE_TEST_IS_REGULAR)) {
      logger.msg(ERROR, "ARC job list file is not a regular file: %s", path);
      return false;
    }

    joblistfile = path;
    return true;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

const std::string& Arc::UserConfig::JobListFile ( ) const [inline]

Get a reference to the path of the job list file.

The job list file is used to store and fetch information about submitted computing jobs to computing services. This method will return the path to the specified job list file.

Returns:
The path to the job list file is returned.
See also:
JobListFile(const std::string&)

Definition at line 407 of file UserConfig.h.

{ return joblistfile; }

Here is the caller graph for this function:

bool Arc::UserConfig::KeyPassword ( const std::string &  newKeyPassword) [inline]

Set password for generated key.

Set password to be used to encode private key of credentials obtained from Short Lived Credentials Service.

The attribute associated with this setter method is 'keypassword'.

Parameters:
newKeyPasswordis the new password to the key.
Returns:
This method always returns true.
See also:
KeyPassword() const
KeyPath(const std::string&)
KeySize(int)

Definition at line 867 of file UserConfig.h.

{ keyPassword = newKeyPassword; return true; }

Here is the caller graph for this function:

const std::string& Arc::UserConfig::KeyPassword ( ) const [inline]

Get password for generated key.

Get password to be used to encode private key of credentials obtained from Short Lived Credentials Service.

Returns:
The key password is returned.
See also:
KeyPassword(const std::string&)
KeyPath() const
KeySize() const

Definition at line 878 of file UserConfig.h.

{ return keyPassword; }

Here is the caller graph for this function:

bool Arc::UserConfig::KeyPath ( const std::string &  newKeyPath) [inline]

Set path to key.

The path to user key will be set by this method. The path to the corresponding certificate can be set with the CertificatePath(const std::string&) method. Note that the InitializeCredentials() method will also try to set this path, by searching in different locations.

The attribute associated with this setter method is 'keypath'.

Parameters:
newKeyPathis the path to the new key.
Returns:
This method always returns true.
See also:
InitializeCredentials()
CredentialsFound() const
KeyPath() const
CertificatePath(const std::string&)
KeyPassword(const std::string&)
KeySize(int)

Definition at line 838 of file UserConfig.h.

{ keyPath = newKeyPath; return true; }

Here is the caller graph for this function:

const std::string& Arc::UserConfig::KeyPath ( ) const [inline]

Get path to key.

The path to the key is returned when invoking this method.

Returns:
The path to the user key is returned.
See also:
InitializeCredentials()
CredentialsFound() const
KeyPath(const std::string&)
CertificatePath() const
KeyPassword() const
KeySize() const

Definition at line 851 of file UserConfig.h.

{ return keyPath; }

Here is the caller graph for this function:

bool Arc::UserConfig::KeySize ( int  newKeySize) [inline]

Set key size.

Set size/strengt of private key of credentials obtained from Short Lived Credentials Service.

The attribute associated with this setter method is 'keysize'.

Parameters:
newKeySizeis the size, an an integer, of the key.
Returns:
This method always returns true.
See also:
KeySize() const
KeyPath(const std::string&)
KeyPassword(const std::string&)

Definition at line 893 of file UserConfig.h.

{ keySize = newKeySize; return true;}

Here is the caller graph for this function:

int Arc::UserConfig::KeySize ( ) const [inline]

Get key size.

Get size/strengt of private key of credentials obtained from Short Lived Credentials Service.

Returns:
The key size, as an integer, is returned.
See also:
KeySize(int)
KeyPath() const
KeyPassword() const

Definition at line 904 of file UserConfig.h.

{ return keySize; }
bool Arc::UserConfig::LoadConfigurationFile ( const std::string &  conffile,
bool  ignoreJobListFile = true 
)

Load specified configuration file.

The configuration file passed is parsed by this method by using the IniConfig class. If the parsing is unsuccessful a WARNING is reported.

The format of the configuration file should follow that of INI, and every attribute present in the file is only allowed once, if otherwise a WARNING will be reported. The file can contain at most two sections, one named common and the other name alias. If other sections exist a WARNING will be reported. Only the following attributes is allowed in the common section of the configuration file:

where the method in parentheses is the associated setter method. If other attributes exist in the common section a WARNING will be reported for each of these attributes. In the alias section aliases can be defined, and should represent a selection of services. The alias can then refered to by input to the AddServices(const std::list<std::string>&, ServiceType) and AddServices(const std::list<std::string>&, const std::list<std::string>&, ServiceType) methods. An alias can not contain any of the characters '.', ':', ' ' or '\t' and should be defined as follows:

\[ <alias\_name>=<service\_type>:<flavour>:<service\_url>|<alias\_ref> [...] \]

where <alias_name> is the name of the defined alias, <service_type> is the service type in lower case, <flavour> is the type of middleware plugin to use, <service_url> is the URL which should be used to contact the service and <alias_ref> is another defined alias. The parsed aliases will be stored internally and resolved when needed. If a alias already exist, and another alias with the same name is parsed then this other alias will overwrite the existing alias.

Parameters:
conffileis the path to the configuration file.
ignoreJobListFileis a optional boolean which indicates whether the joblistfile attribute in the configuration file should be ignored. Default is to ignored it (true).
Returns:
If loading the configuration file succeeds true is returned, otherwise false is returned.
See also:
SaveToFile()

Definition at line 344 of file UserConfig.cpp.

                                                                                          {
    if (!conffile.empty()) {
      IniConfig ini(conffile);
      if (ini) {
        logger.msg(INFO, "Loading configuration (%s)", conffile);

        if (ini["alias"]) {
          XMLNode aliasXML = ini["alias"];
          if (aliasMap) { // Merge aliases. Overwrite existing aliases
            while (aliasXML.Child()) {
              if (aliasMap[aliasXML.Child().Name()]) {
                aliasMap[aliasXML.Child().Name()].Replace(aliasXML.Child());
                logger.msg(INFO, "Overwriting already defined alias \"%s\"",  aliasXML.Child().Name());
              }
              else
                aliasMap.NewChild(aliasXML.Child());

              aliasXML.Child().Destroy();
            }
          }
          else
            aliasXML.New(aliasMap);
          aliasXML.Destroy();
        }

        if (ini["common"]) {
          XMLNode common = ini["common"];
          HANDLESTRATT("verbosity", Verbosity)
          HANDLESTRATT("joblist", JobListFile)
          if (common["timeout"]) {
            if (!stringto(common["timeout"], timeout))
              logger.msg(WARNING, "The value of the timeout attribute in the configuration file (%s) was only partially parsed", conffile);
            common["timeout"].Destroy();
            if (common["timeout"]) {
              logger.msg(WARNING, "Multiple %s attributes in configuration file (%s)", "timeout", conffile);
              while (common["timeout"]) common["timeout"].Destroy();
            }
          }
          if (common["brokername"]) {
            broker = std::make_pair<std::string, std::string>(ini["common"]["brokername"],
                                                              ini["common"]["brokerarguments"] ? ini["common"]["brokerarguments"] : "");
            common["brokername"].Destroy();
            if (common["brokername"]) {
              logger.msg(WARNING, "Multiple %s attributes in configuration file (%s)", "brokername", conffile);
              while (common["brokername"]) common["brokername"].Destroy();
            }
            if (common["brokerarguments"]) {
              common["brokerarguments"].Destroy();
              if (common["brokerarguments"]) {
                logger.msg(WARNING, "Multiple %s attributes in configuration file (%s)", "brokerarguments", conffile);
                while (common["brokerarguments"]) common["brokerarguments"].Destroy();
              }
            }
          }
          // This block must be executed after the 'brokername' block.
          if (common["brokerarguments"]) {
            logger.msg(WARNING, "The brokerarguments attribute can only be used in conjunction with the brokername attribute");
            while (common["brokerarguments"]) common["brokerarguments"].Destroy();
          }
          if (common["bartender"]) {
            std::list<std::string> bartendersStr;
            tokenize(common["bartender"], bartendersStr, " \t");
            for (std::list<std::string>::const_iterator it = bartendersStr.begin();
                 it != bartendersStr.end(); it++) {
              URL bartenderURL(*it);
              if (!bartenderURL)
                logger.msg(WARNING, "Could not convert the bartender attribute value (%s) to an URL instance in configuration file (%s)", *it, conffile);
              else
                bartenders.push_back(bartenderURL);
            }
            common["bartender"].Destroy();
            if (common["bartender"]) {
              logger.msg(WARNING, "Multiple %s attributes in configuration file (%s)", "bartender", conffile);
              while (common["bartender"]) common["bartender"].Destroy();
            }
          }
          HANDLESTRATT("vomsserverpath", VOMSServerPath)
          HANDLESTRATT("username", UserName)
          HANDLESTRATT("password", Password)
          HANDLESTRATT("proxypath", ProxyPath)
          HANDLESTRATT("certificatepath", CertificatePath)
          HANDLESTRATT("keypath", KeyPath)
          HANDLESTRATT("keypassword", KeyPassword)
          if (common["keysize"]) {
            if (!stringto(ini["common"]["keysize"], keySize))
              logger.msg(WARNING, "The value of the keysize attribute in the configuration file (%s) was only partially parsed", conffile);
            common["keysize"].Destroy();
            if (common["keysize"]) {
              logger.msg(WARNING, "Multiple %s attributes in configuration file (%s)", "keysize", conffile);
              while (common["keysize"]) common["keysize"].Destroy();
            }
          }
          HANDLESTRATT("cacertificatepath", CACertificatePath)
          HANDLESTRATT("cacertificatesdirectory", CACertificatesDirectory)
          if (common["certificatelifetime"]) {
            certificateLifeTime = Period((std::string)common["certificatelifetime"]);
            common["certificatelifetime"].Destroy();
            if (common["certificatelifetime"]) {
              logger.msg(WARNING, "Multiple %s attributes in configuration file (%s)", "certificatelifetime", conffile);
              while (common["certificatelifetime"]) common["certificatelifetime"].Destroy();
            }
          }
          if (common["slcs"]) {
            slcs = URL((std::string)common["slcs"]);
            if (!slcs) {
              logger.msg(WARNING, "Could not convert the slcs attribute value (%s) to an URL instance in configuration file (%s)", (std::string)common["slcs"], conffile);
              slcs = URL();
            }
            common["slcs"].Destroy();
            if (common["slcs"]) {
              logger.msg(WARNING, "Multiple %s attributes in configuration file (%s)", "slcs", conffile);
              while (common["slcs"]) common["slcs"].Destroy();
            }
          }
          HANDLESTRATT("storedirectory", StoreDirectory)
          HANDLESTRATT("idpname", IdPName)
          if (common["defaultservices"]) {
            if (!selectedServices.first.empty() || !selectedServices.second.empty())
              ClearSelectedServices();
            std::list<std::string> defaultServicesStr;
            tokenize(common["defaultservices"], defaultServicesStr, " \t");
            for (std::list<std::string>::const_iterator it = defaultServicesStr.begin();
                 it != defaultServicesStr.end(); it++) {
              // Aliases cannot contain '.' or ':'.

              if (it->find_first_of(":.") == std::string::npos) { // Alias
                if (!aliasMap[*it]) {
                  logger.msg(ERROR, "Could not resolve alias \"%s\" it is not defined.", *it);
                  return false;
                }

                std::list<std::string> resolvedAliases(1, *it);
                if (!ResolveAlias(selectedServices, resolvedAliases))
                  return false;
              }
              else {
                const std::size_t pos1 = it->find(":");
                const std::size_t pos2 = it->find(":", pos1+1);
                if (pos2 == std::string::npos) {
                  logger.msg(WARNING, "The defaultservices attribute value contains a wrongly formated element (%s) in configuration file (%s)", *it, conffile);
                  continue;
                }
                const std::string serviceType = it->substr(0, pos1);
                if (serviceType != "computing" && serviceType != "index") {
                  logger.msg(WARNING, "The defaultservices attribute value contains a unknown servicetype %s at %s in configuration file (%s)", serviceType, *it, conffile);
                  continue;
                }
                const URL url(it->substr(pos2+1));
                if (!url) {
                  logger.msg(WARNING, "The defaultservices attribute value contains a wrongly formated URL (%s) in configuration file (%s)", it->substr(pos2+1), conffile);
                  continue;
                }
                const std::string flavour = it->substr(pos1+1,pos2-pos1-1);
                logger.msg(VERBOSE, "Adding selected service %s:%s:%s", serviceType, flavour, url.str());
                if (serviceType == "computing")
                  selectedServices.first[flavour].push_back(url);
                else
                  selectedServices.second[flavour].push_back(url);
              }
            }
            common["defaultservices"].Destroy();
            if (common["defaultservices"]) {
              logger.msg(WARNING, "Multiple %s attributes in configuration file (%s)", "defaultservices", conffile);
              while (common["defaultservices"]) common["defaultservices"].Destroy();
            }
          }
          if (common["rejectservices"]) {
            std::list<std::string> rejectServicesStr;
            tokenize(common["rejectservices"], rejectServicesStr, " \t");
            for (std::list<std::string>::const_iterator it = rejectServicesStr.begin();
                 it != rejectServicesStr.end(); it++) {
              // Aliases cannot contain '.' or ':'.
              if (it->find_first_of(":.") == std::string::npos) { // Alias
                if (!aliasMap[*it]) {
                  logger.msg(ERROR, "Could not resolve alias \"%s\" it is not defined.", *it);
                  return false;
                }

                std::list<std::string> resolvedAliases(1, *it);
                if (!ResolveAlias(selectedServices, resolvedAliases))
                  return false;
              }
              else {
                const std::size_t pos1 = it->find(":");
                const std::size_t pos2 = it->find(":", pos1+1);
                if (pos2 == std::string::npos) {
                  logger.msg(WARNING, "The rejectservices attribute value contains a wrongly formated element (%s) in configuration file (%s)", *it, conffile);
                  continue;
                }
                const std::string serviceType = it->substr(0, pos1);
                if (serviceType != "computing" && serviceType != "index") {
                  logger.msg(WARNING, "The rejectservices attribute value contains a unknown servicetype %s at %s in configuration file (%s)", serviceType, *it, conffile);
                  continue;
                }
                const URL url(it->substr(pos2+1));
                if (!url) {
                  logger.msg(WARNING, "The rejectservices attribute value contains a wrongly formated URL (%s) in configuration file (%s)", it->substr(pos2+1), conffile);
                  continue;
                }
                const std::string flavour = it->substr(pos1+1,pos2-pos1-1);
                logger.msg(VERBOSE, "Adding rejected service %s:%s:%s", serviceType, flavour, url.str());
                if (serviceType == "computing")
                  rejectedServices.first[flavour].push_back(url);
                else
                  rejectedServices.second[flavour].push_back(url);
              }
            }
            common["rejectservices"].Destroy();
            if (common["rejectservices"]) {
              logger.msg(WARNING, "Multiple %s attributes in configuration file (%s)", "rejectservices", conffile);
              while (common["rejectservices"]) common["rejectservices"].Destroy();
            }
          }
          HANDLESTRATT("overlayfile", OverlayFile)
          if(!overlayfile.empty())
            if (!Glib::file_test(overlayfile, Glib::FILE_TEST_IS_REGULAR))
              logger.msg(WARNING, "Specified overlay file (%s) does not exist.", overlayfile);
          while (common.Child()) {
            logger.msg(WARNING, "Unknown attribute %s in common section, ignoring it", common.Child().Name());
            common.Child().Destroy();
          }

          common.Destroy();
        }

        while (ini.Child()) {
          logger.msg(INFO, "Unknown section %s, ignoring it", ini.Child().Name());
          ini.Child().Destroy();
        }

        logger.msg(INFO, "Configuration (%s) loaded", conffile);
      }
      else
        logger.msg(WARNING, "Could not load configuration (%s)", conffile);
    }

    return true;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

bool Arc::UserConfig::makeDir ( const std::string &  path) [static, private]

Definition at line 976 of file UserConfig.cpp.

                                                {
    bool dirCreated = false;
#ifdef HAVE_GIOMM
    try {
      dirCreated = Gio::File::create_for_path(path)->make_directory();
    } catch (Glib::Error e) {
      logger.msg(WARNING, "%s", (std::string)e.what());
    }
#else
    dirCreated = (mkdir(path.c_str(), 0755) == 0);
#endif

    if (dirCreated)
      logger.msg(INFO, "%s directory created", path);

    return dirCreated;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

Arc::UserConfig::operator bool ( void  ) const [inline]

Check for validity.

The validity of an object created from this class can be checked using this casting operator. An object is valid if the constructor did not encounter any errors.

See also:
operator!()

Definition at line 370 of file UserConfig.h.

{ return ok; }
bool Arc::UserConfig::operator! ( void  ) const [inline]

Check for non-validity.

See operator bool() for a description.

See also:
operator bool()

Definition at line 376 of file UserConfig.h.

{ return !ok; }
bool Arc::UserConfig::OverlayFile ( const std::string &  path) [inline]

Set path to configuration overlay file.

Content of specified file is a backdoor to configuration XML generated from information stored in this class. The content of file is passed to BaseConfig class in ApplyToConfig(BaseConfig&) then merged with internal configuration XML representation. This feature is meant for quick prototyping/testing/tuning of functionality without rewriting code. It is meant for developers and most users won't need it.

The attribute associated with this setter method is 'overlayfile'.

Parameters:
pathis the new overlay file path.
Returns:
This method always returns true.
See also:

Definition at line 1059 of file UserConfig.h.

{ overlayfile = path; return true; }
const std::string& Arc::UserConfig::OverlayFile ( ) const [inline]

Get path to configuration overlay file.

Returns:
The overlay file path
See also:
OverlayFile(const std::string&)

Definition at line 1065 of file UserConfig.h.

{ return overlayfile; }

Here is the caller graph for this function:

bool Arc::UserConfig::Password ( const std::string &  newPassword) [inline]

Set password.

Set password which is used for requesting credentials from Short Lived Credentials Service.

The attribute associated with this setter method is 'password'.

Parameters:
newPasswordis the new password to set.
Returns:
This method always returns true.
See also:
Password() const

Definition at line 754 of file UserConfig.h.

{ password = newPassword; return true; }

Here is the caller graph for this function:

const std::string& Arc::UserConfig::Password ( ) const [inline]

Get password.

Get password which is used for requesting credentials from Short Lived Credentials Service.

Returns:
The password is returned.
See also:
Password(const std::string&)

Definition at line 763 of file UserConfig.h.

{ return password; }

Here is the caller graph for this function:

bool Arc::UserConfig::ProxyPath ( const std::string &  newProxyPath) [inline]

Set path to user proxy.

This method will set the path of the user proxy. Note that the InitializeCredentials() method will also try to set this path, by searching in different locations.

The attribute associated with this setter method is 'proxypath'

Parameters:
newProxyPathis the path to a user proxy.
Returns:
This method always returns true.
See also:
InitializeCredentials()
CredentialsFound()
ProxyPath() const

Definition at line 779 of file UserConfig.h.

{ proxyPath = newProxyPath; return true;}

Here is the caller graph for this function:

const std::string& Arc::UserConfig::ProxyPath ( ) const [inline]

Get path to user proxy.

Retrieve path to user proxy.

Returns:
Returns the path to the user proxy.
See also:
ProxyPath(const std::string&)

Definition at line 787 of file UserConfig.h.

{ return proxyPath; }

Here is the caller graph for this function:

bool Arc::UserConfig::ResolveAlias ( URLListMap services,
ServiceType  st,
std::list< std::string > &  resolvedAlias 
) [private]

Definition at line 851 of file UserConfig.cpp.

                                                                     {
    std::list<std::string> valueList;
    tokenize(aliasMap[resolvedAliases.back()], valueList, " \t");

    for (std::list<std::string>::const_iterator it = valueList.begin();
         it != valueList.end(); it++) {
      const std::size_t pos1 = it->find(":");
      const std::size_t pos2 = it->find(":", pos1+1);

      if (pos1 == std::string::npos) { // Alias.
        const std::string& referedAlias = *it;
        if (std::find(resolvedAliases.begin(), resolvedAliases.end(), referedAlias) != resolvedAliases.end()) { // Loop detected.
          std::string loopstr = "";
          for (std::list<std::string>::const_iterator itloop = resolvedAliases.begin();
               itloop != resolvedAliases.end(); itloop++)
            loopstr += *itloop + " -> ";
          loopstr += referedAlias;
          logger.msg(ERROR, "Cannot resolve alias \"%s\". Loop detected: %s", resolvedAliases.front(), loopstr);
          return false;
        }

        if (!aliasMap[referedAlias]) {
          logger.msg(ERROR, "Cannot resolve alias %s, it is not defined", referedAlias);
          return false;
        }

        resolvedAliases.push_back(referedAlias);
        if (!ResolveAlias(services, st, resolvedAliases))
          return false;

        resolvedAliases.pop_back();
      }
      else if (pos2 != std::string::npos) { // serviceType:flavour:URL
        const std::string serviceType = it->substr(0, pos1);
        if (serviceType != "computing" && serviceType != "index") {
          logger.msg(WARNING, "Alias name (%s) contains a unknown servicetype %s at %s", resolvedAliases.front(), serviceType, *it);
          continue;
        }
        else if ((st == COMPUTING && serviceType != "computing") ||
                 (st == INDEX && serviceType != "index"))
          continue;

        const URL url(it->substr(pos2+1));
        if (!url) {
          logger.msg(WARNING, "Alias name (%s) contains a wrongly formated URL (%s)", resolvedAliases.front(), it->substr(pos2+1));
          continue;
        }
        const std::string flavour = it->substr(pos1+1, pos2-pos1-1);
        logger.msg(VERBOSE, "Adding service %s:%s:%s from resolved alias %s", serviceType, flavour, url.str(), resolvedAliases.back());
        services[flavour].push_back(url);
      }
      else {
        logger.msg(WARNING, "Alias (%s) contains a wrongly formated element (%s)", resolvedAliases.front(), *it);
      }
    }

    return true;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

bool Arc::UserConfig::ResolveAlias ( std::pair< URLListMap, URLListMap > &  services,
std::list< std::string > &  resolvedAlias 
) [private]

Definition at line 911 of file UserConfig.cpp.

                                                                     {
    std::list<std::string> valueList;
    tokenize(aliasMap[resolvedAliases.back()], valueList, " \t");

    for (std::list<std::string>::const_iterator it = valueList.begin();
         it != valueList.end(); it++) {
      const std::size_t pos1 = it->find(":");
      const std::size_t pos2 = it->find(":", pos1+1);

      if (pos1 == std::string::npos) { // Alias.
        const std::string& referedAlias = *it;
        if (std::find(resolvedAliases.begin(), resolvedAliases.end(), referedAlias) != resolvedAliases.end()) { // Loop detected.
          std::string loopstr = "";
          for (std::list<std::string>::const_iterator itloop = resolvedAliases.begin();
               itloop != resolvedAliases.end(); itloop++)
            loopstr += *itloop + " -> ";
          loopstr += referedAlias;
          logger.msg(ERROR, "Cannot resolve alias \"%s\". Loop detected: %s", resolvedAliases.front(), loopstr);
          return false;
        }

        if (!aliasMap[referedAlias]) {
          logger.msg(ERROR, "Cannot resolve alias %s, it is not defined", referedAlias);
          return false;
        }

        resolvedAliases.push_back(referedAlias);
        if (!ResolveAlias(services, resolvedAliases))
          return false;

        resolvedAliases.pop_back();
      }
      else if (pos2 != std::string::npos) { // serviceType:flavour:URL
        const std::string serviceType = it->substr(0, pos1);
        if (serviceType != "computing" && serviceType != "index") {
          logger.msg(WARNING, "Alias name (%s) contains a unknown servicetype %s at %s", resolvedAliases.front(), serviceType, *it);
          continue;
        }
        const URL url(it->substr(pos2+1));
        if (!url) {
          logger.msg(WARNING, "Alias name (%s) contains a wrongly formated URL (%s)", resolvedAliases.front(), it->substr(pos2+1));
          continue;
        }
        const std::string flavour = it->substr(pos1+1, pos2-pos1-1);
        logger.msg(VERBOSE, "Adding service %s:%s:%s from resolved alias %s", serviceType, flavour, url.str(), resolvedAliases.back());
        if (serviceType == "computing")
          services.first[flavour].push_back(url);
        else
          services.second[flavour].push_back(url);
      }
      else {
        logger.msg(WARNING, "Alias (%s) contains a wrongly formated element (%s)", resolvedAliases.front(), *it);
      }
    }

    return true;
  }

Here is the call graph for this function:

bool Arc::UserConfig::SaveToFile ( const std::string &  filename) const

Save to INI file.

This method will save the object data as a INI file. The saved file can be loaded with the LoadConfigurationFile method.

Parameters:
filenamethe name of the file which the data will be saved to.
Returns:
false if unable to get handle on file, otherwise true is returned.
See also:
LoadConfigurationFile()

Definition at line 583 of file UserConfig.cpp.

                                                             {
    std::ofstream file(filename.c_str(), std::ios::out);
    if (!file)
      return false;

    file << "[ common ]" << std::endl;
    if (!verbosity.empty())
      file << "verbosity = " << verbosity << std::endl;
    if (!joblistfile.empty())
      file << "joblist = " << joblistfile << std::endl;
    if (timeout > 0)
      file << "timeout = " << timeout << std::endl;
    if (!broker.first.empty()) {
      file << "brokername = " << broker.first << std::endl;
      if (!broker.second.empty())
        file << "brokerarguments = " << broker.second << std::endl;
    }
    if (!bartenders.empty()) {
      file << "bartender =";
      for (std::vector<URL>::const_iterator it = bartenders.begin();
           it != bartenders.end(); it++) {
        file << " " << it->fullstr();
      }
      file << std::endl;
    }
    if (!vomsServerPath.empty())
      file << "vomsserverpath = " << vomsServerPath << std::endl;
    if (!username.empty())
      file << "username = " << username << std::endl;
    if (!password.empty())
      file << "password = " << password << std::endl;
    if (!proxyPath.empty())
      file << "proxypath = " << proxyPath << std::endl;
    if (!certificatePath.empty())
      file << "certificatepath = " << certificatePath << std::endl;
    if (!keyPath.empty())
      file << "keypath = " << keyPath << std::endl;
    if (!keyPassword.empty())
      file << "keypassword = " << keyPassword << std::endl;
    if (keySize > 0)
      file << "keysize = " << keySize << std::endl;
    if (!caCertificatePath.empty())
      file << "cacertificatepath = " << caCertificatePath << std::endl;
    if (!caCertificatesDirectory.empty())
      file << "cacertificatesdirectory = " << caCertificatesDirectory << std::endl;
    if (certificateLifeTime > 0)
      file << "certificatelifetime = " << certificateLifeTime << std::endl;
    if (slcs)
      file << "slcs = " << slcs.fullstr() << std::endl;
    if (!storeDirectory.empty())
      file << "storedirectory = " << storeDirectory << std::endl;
    if (!idPName.empty())
      file << "idpname = " << idPName << std::endl;
    if (!selectedServices.first.empty() || !selectedServices.second.empty()) {
      file << "defaultservices =";
      for (URLListMap::const_iterator it = selectedServices.first.begin();
           it != selectedServices.first.end(); it++) {
        for (std::list<URL>::const_iterator iitt = it->second.begin();
             iitt != it->second.end(); iitt++) {
          file << " computing:" << it->first << ":" << iitt->fullstr();
        }
      }
      for (URLListMap::const_iterator it = selectedServices.second.begin();
           it != selectedServices.second.end(); it++) {
        for (std::list<URL>::const_iterator iitt = it->second.begin();
             iitt != it->second.end(); iitt++) {
          file << " index:" << it->first << ":" << iitt->fullstr();
        }
      }
      file << std::endl;
    }
    if (!rejectedServices.first.empty() || !rejectedServices.second.empty()) {
      file << "rejectedservices =";
      for (URLListMap::const_iterator it = rejectedServices.first.begin();
           it != rejectedServices.first.end(); it++) {
        for (std::list<URL>::const_iterator iitt = it->second.begin();
             iitt != it->second.end(); iitt++) {
          file << " computing:" << it->first << ":" << iitt->fullstr();
        }
      }
      for (URLListMap::const_iterator it = rejectedServices.second.begin();
           it != rejectedServices.second.end(); it++) {
        for (std::list<URL>::const_iterator iitt = it->second.begin();
             iitt != it->second.end(); iitt++) {
          file << " index:" << it->first << ":" << iitt->fullstr();
        }
      }
      file << std::endl;
    }
    if (!overlayfile.empty())
      file << "overlayfile = " << overlayfile << std::endl;

    if (aliasMap.Size() > 0) {
      int i = 0;
      file << std::endl << "[ alias ]" << std::endl;
      while (XMLNode n = const_cast<XMLNode&>(aliasMap).Child(i++)) {
        file << n.Name() << " = " << (std::string)n << std::endl;
      }
    }

    logger.msg(INFO, "UserConfiguration saved to file (%s)", filename);

    return true;
  }

Here is the call graph for this function:

void Arc::UserConfig::setDefaults ( ) [private]

Definition at line 970 of file UserConfig.cpp.

                               {
    timeout = DEFAULT_TIMEOUT;
    broker.first = DEFAULT_BROKER;
    broker.second = "";
  }

Here is the caller graph for this function:

bool Arc::UserConfig::SLCS ( const URL newSLCS) [inline]

Set the URL to the Short Lived Certificate Service (SLCS).

The attribute associated with this setter method is 'slcs'.

Parameters:
newSLCSis the URL to the SLCS
Returns:
This method always returns true.
See also:
SLCS() const

Definition at line 993 of file UserConfig.h.

{ slcs = newSLCS; return true; }

Here is the caller graph for this function:

const URL& Arc::UserConfig::SLCS ( ) const [inline]

Get the URL to the Short Lived Certificate Service (SLCS).

Returns:
The SLCS is returned.
See also:
SLCS(const URL&)

Definition at line 1000 of file UserConfig.h.

{ return slcs; }
bool Arc::UserConfig::StoreDirectory ( const std::string &  newStoreDirectory) [inline]

Set store directory.

Sets directory which will be used to store credentials obtained from Short Lived Credential Servide.

The attribute associated with this setter method is 'storedirectory'.

Parameters:
newStoreDirectoryis the path to the store directory.
Returns:
This method always returns true.
See also:

Definition at line 1013 of file UserConfig.h.

{ storeDirectory = newStoreDirectory; return true; }

Here is the caller graph for this function:

const std::string& Arc::UserConfig::StoreDirectory ( ) const [inline]

Get store diretory.

Sets directory which is used to store credentials obtained from Short Lived Credential Servide.

Returns:
The path to the store directory is returned.
See also:
StoreDirectory(const std::string&)

Definition at line 1022 of file UserConfig.h.

{ return storeDirectory; }

Here is the caller graph for this function:

bool Arc::UserConfig::Timeout ( int  newTimeout)

Set timeout.

When communicating with a service the timeout specifies how long, in seconds, the communicating instance should wait for a response. If the response have not been recieved before this period in time, the connection is typically dropped, and an error will be reported.

This method will set the timeout to the specified integer. If the passed integer is less than or equal to 0 then false is returned and the timeout will not be set, otherwise true is returned and the timeout will be set to the new value.

The attribute associated with this setter method is 'timeout'.

Parameters:
newTimeoutthe new timeout value in seconds.
Returns:
false in case newTimeout <= 0, otherwise true.
See also:
Timeout() const
DEFAULT_TIMEOUT

Definition at line 182 of file UserConfig.cpp.

                                         {
    if (timeout > 0) {
      timeout = newTimeout;
      return true;
    }

    return false;
  }
int Arc::UserConfig::Timeout ( ) const [inline]

Get timeout.

Returns the timeout in seconds.

Returns:
timeout in seconds.
See also:
Timeout(int)
DEFAULT_TIMEOUT

Definition at line 587 of file UserConfig.h.

{ return timeout; }
bool Arc::UserConfig::UserName ( const std::string &  name) [inline]

Set user-name for SLCS.

Set username which is used for requesting credentials from Short Lived Credentials Service.

The attribute associated with this setter method is 'username'.

Parameters:
nameis the name of the user.
Returns:
This method always return true.
See also:
UserName() const

Definition at line 732 of file UserConfig.h.

{ username = name; return true; }

Here is the caller graph for this function:

const std::string& Arc::UserConfig::UserName ( ) const [inline]

Get user-name.

Get username which is used for requesting credentials from Short Lived Credentials Service.

Returns:
The username is returned.
See also:
UserName(const std::string&)

Definition at line 741 of file UserConfig.h.

{ return username; }

Here is the caller graph for this function:

bool Arc::UserConfig::UtilsDirPath ( const std::string &  dir) [inline]

Set path to directory storing utility files for DataPoints.

Some DataPoints can store information on remote services in local files. This method sets the path to the directory containing these files. For example arc* tools set it to ARCUSERDIRECTORY and A-REX sets it to the control directory.

Parameters:
pathis the new utils dir path.
Returns:
This method always returns true.

Definition at line 1076 of file UserConfig.h.

{ utilsdir = dir; return true; }

Here is the caller graph for this function:

const std::string& Arc::UserConfig::UtilsDirPath ( ) const [inline]

Get path to directory storing utility files for DataPoints.

Returns:
The utils dir path
See also:
UtilsDirPath(const std::string&)

Definition at line 1082 of file UserConfig.h.

{ return utilsdir; };
bool Arc::UserConfig::Verbosity ( const std::string &  newVerbosity)

Set verbosity.

The verbosity will be set when invoking this method. If the string passed cannot be parsed into a corresponding LogLevel, using the function a WARNING is reported and false is returned, otherwise true is returned.

The attribute associated with this setter method is 'verbosity'.

Returns:
true in case the verbosity could be set to a allowed LogLevel, otherwise false.
See also:
Verbosity() const

Definition at line 191 of file UserConfig.cpp.

                                                          {
    LogLevel ll;
    if (istring_to_level(newVerbosity, ll)) {
      verbosity = newVerbosity;
      return true;
    }
    else {
      logger.msg(WARNING, "Unable to parse the specified verbosity (%s) to one of the allowed levels", newVerbosity);
      return false;
    }
  }

Here is the call graph for this function:

Here is the caller graph for this function:

const std::string& Arc::UserConfig::Verbosity ( ) const [inline]

Get the user selected level of verbosity.

The string representation of the verbosity level specified by the user is returned when calling this method. If the user have not specified the verbosity level the empty string will be referenced.

Returns:
the verbosity level, or empty if it has not been set.
See also:
Verbosity(const std::string&)

Definition at line 614 of file UserConfig.h.

{ return verbosity; }

Here is the caller graph for this function:

bool Arc::UserConfig::VOMSServerPath ( const std::string &  path) [inline]

Set path to file containing VOMS configuration.

Set path to file which contians list of VOMS services and associated configuration parameters needed to contact those services. It is used by arcproxy.

The attribute associated with this setter method is 'vomsserverpath'.

Parameters:
paththe path to VOMS configuration file
Returns:
This method always return true.
See also:
VOMSServerPath() const

Definition at line 710 of file UserConfig.h.

{ vomsServerPath = path; return true; }

Here is the caller graph for this function:

const std::string& Arc::UserConfig::VOMSServerPath ( ) const [inline]

Get path to file containing VOMS configuration.

Get path to file which contians list of VOMS services and associated configuration parameters.

Returns:
The path to VOMS configuration file is returned.
See also:
VOMSServerPath(const std::string&)

Definition at line 719 of file UserConfig.h.

{ return vomsServerPath; }

Here is the caller graph for this function:


Member Data Documentation

Definition at line 1184 of file UserConfig.h.

const std::string Arc::UserConfig::ARCUSERDIRECTORY = Glib::build_filename(User().Home(), ".arc") [static]

Path to ARC user home directory.

The ARCUSERDIRECTORY variable is the path to the ARC home directory of the current user. This path is created using the User::Home() method.

See also:
User::Home()

Definition at line 1082 of file UserConfig.h.

std::vector<URL> Arc::UserConfig::bartenders [private]

Definition at line 1157 of file UserConfig.h.

std::pair<std::string, std::string> Arc::UserConfig::broker [private]

Definition at line 1151 of file UserConfig.h.

std::string Arc::UserConfig::caCertificatePath [private]

Definition at line 1164 of file UserConfig.h.

Definition at line 1165 of file UserConfig.h.

Definition at line 1166 of file UserConfig.h.

std::string Arc::UserConfig::certificatePath [private]

Definition at line 1160 of file UserConfig.h.

const std::string Arc::UserConfig::DEFAULT_BROKER = "Random" [static]

Default broker.

The DEFAULT_BROKER specifies the name of the broker which should be used in case no broker is explicitly chosen.

See also:
Broker
Broker(const std::string&)
Broker(const std::string&, const std::string&)
Broker() const

Definition at line 1132 of file UserConfig.h.

const int Arc::UserConfig::DEFAULT_TIMEOUT = 20 [static]

Default timeout in seconds.

The DEFAULT_TIMEOUT specifies interval which will be used in case no timeout interval have been explicitly specified. For a description about timeout see Timeout(int).

See also:
Timeout(int)
Timeout() const

Definition at line 1121 of file UserConfig.h.

const std::string Arc::UserConfig::DEFAULTCONFIG = Glib::build_filename(ARCUSERDIRECTORY, "client.conf") [static]

Path to default configuration file.

The DEFAULTCONFIG variable is the path to the default configuration file used in case no configuration file have been specified. The path is created from the ARCUSERDIRECTORY object.

Definition at line 1105 of file UserConfig.h.

const std::string Arc::UserConfig::EXAMPLECONFIG = Glib::build_filename(PKGDATADIR G_DIR_SEPARATOR_S "examples", "client.conf.example") [static]

Path to example configuration.

The EXAMPLECONFIG variable is the path to the example configuration file.

Definition at line 1111 of file UserConfig.h.

std::string Arc::UserConfig::idPName [private]

Definition at line 1174 of file UserConfig.h.

std::string Arc::UserConfig::joblistfile [private]

Definition at line 1144 of file UserConfig.h.

std::string Arc::UserConfig::keyPassword [private]

Definition at line 1162 of file UserConfig.h.

std::string Arc::UserConfig::keyPath [private]

Definition at line 1161 of file UserConfig.h.

int Arc::UserConfig::keySize [private]

Definition at line 1163 of file UserConfig.h.

Logger Arc::UserConfig::logger [static, private]

Definition at line 1188 of file UserConfig.h.

bool Arc::UserConfig::ok [private]

Definition at line 1186 of file UserConfig.h.

std::string Arc::UserConfig::overlayfile [private]

Definition at line 1179 of file UserConfig.h.

std::string Arc::UserConfig::password [private]

Definition at line 1177 of file UserConfig.h.

std::string Arc::UserConfig::proxyPath [private]

Definition at line 1159 of file UserConfig.h.

Definition at line 1154 of file UserConfig.h.

Definition at line 1153 of file UserConfig.h.

Definition at line 1168 of file UserConfig.h.

std::string Arc::UserConfig::storeDirectory [private]

Definition at line 1172 of file UserConfig.h.

const std::string Arc::UserConfig::SYSCONFIG = Glib::build_filename(PKGSYSCONFDIR, "client.conf") [static]

Path to system configuration.

The SYSCONFIG variable is the path to the system configuration file.

Definition at line 1097 of file UserConfig.h.

int Arc::UserConfig::timeout [private]

Definition at line 1146 of file UserConfig.h.

std::string Arc::UserConfig::username [private]

Definition at line 1176 of file UserConfig.h.

std::string Arc::UserConfig::utilsdir [private]

Definition at line 1180 of file UserConfig.h.

std::string Arc::UserConfig::verbosity [private]

Definition at line 1148 of file UserConfig.h.

std::string Arc::UserConfig::vomsServerPath [private]

Definition at line 1170 of file UserConfig.h.


The documentation for this class was generated from the following files: