Matrix Science Mascot Parser toolkit
 
Loading...
Searching...
No Matches
ms_security_task Class Reference

Each group has permission to do one or more tasks. This class defines an individual task. More...

#include <ms_security_task.hpp>

Public Types

enum  paramType {
  TYPE_BOOL = 0x0000 ,
  TYPE_EQ_LONG = 0x0001 ,
  TYPE_LTE_LONG = 0x0002 ,
  TYPE_GTE_LONG = 0x0003 ,
  TYPE_LONG_ARRAY = 0x0004 ,
  TYPE_EQ_DOUBLE = 0x0005 ,
  TYPE_LTE_DOUBLE = 0x0006 ,
  TYPE_GTE_DOUBLE = 0x0007 ,
  TYPE_DOUBLE_ARRAY = 0x0008 ,
  TYPE_EQ_STRING = 0x0009 ,
  TYPE_STRING_ARRAY = 0x000A ,
  TYPE_USERS_ARRAY = 0x000B ,
  TYPE_ALL_USERS_ARRAY = 0x000C
}
 Definitions for parameter type. More...
 

Public Member Functions

 ms_security_task ()
 Create a new empty object - not particularly useful.
 
 ~ms_security_task ()
 Destructor of the class.
 
bool addDoubleParam (const double value)
 Add a floating point parameter to the task.
 
bool addLongParam (const long value)
 Add a long parameter to the task.
 
bool addStringParam (const std::string value)
 Add a string parameter to the task.
 
void clearParams ()
 Clears all parameters.
 
std::string getAllParamsAsString () const
 Return all the parameters as a comma separated string.
 
std::string getConstantName () const
 Returns the 'constant definition name' for the task.
 
std::string getDescription () const
 Returns a single line description for the task.
 
std::vector< double > getDoubleParams () const
 Get the list of long parameters for the task.
 
int getID () const
 Returns the unique ID for the task.
 
std::vector< long > getLongParams () const
 Get the list of long parameters for the task.
 
std::string getNotes () const
 Returns any notes applied to the task.
 
std::vector< std::string > getStringParams () const
 Get the list of string parameters for the task.
 
paramType getType () const
 Returns the 'type' of the parameter for a task.
 
bool isPermitted () const
 See if the task is permitted.
 
bool isPermitted_double (const double value) const
 See if the value is in the floating point parameter list.
 
bool isPermitted_long (const long value) const
 See if the value is in the long integer parameter list.
 
bool isPermitted_string (const std::string value) const
 See if the value is in the string parameter list.
 
void setParams (const std::string value)
 Set all parameters, regardless of type.
 

Detailed Description

Each group has permission to do one or more tasks. This class defines an individual task.

There is currently no programmatic interface for saving task information, since this should normally only be done by developers.

Tasks are loaded from the file config/security_tasks.xml.

Parameters, for example, the maximum number of queries for a group, or the databases that can be used by a group are not saved in config/security_tasks.xml, but are saved as part of the group information. However, the type of the parameter is saved in config/security_tasks.xml.

Member Enumeration Documentation

◆ paramType

enum paramType

Definitions for parameter type.

See Using enumerated values and static const ints in Perl, Java, Python and C#.

Each task has one or more parameters associated with it. For example, "Access to administration pages" would have a boolean value. Other tasks such as "Maximum execution time" need a single number to determine the limit.

Enumerator
TYPE_BOOL 

The default - A single boolean parameter that is always 'true'.

TYPE_EQ_LONG 

Single extra long integer parameter. The 'test' value must equal the stored value for this task to be permitted.

TYPE_LTE_LONG 

Single extra long integer parameter. The 'test' value must be less than or equal to the stored value for this task to be permitted.

TYPE_GTE_LONG 

Single extra long integer parameter. The 'test' value must be greater than or equal to the stored value for this task to be permitted.

TYPE_LONG_ARRAY 

Array of extra long integer parameters. The test value must equal one of these values for the task to be permitted.

TYPE_EQ_DOUBLE 

Single extra floating point parameter. The 'test' value must equal the stored value for this task to be permitted.

TYPE_LTE_DOUBLE 

Single extra floating point parameter. The 'test' value must be less than or equal to the stored value for this task to be permitted.

TYPE_GTE_DOUBLE 

Single extra floating point parameter. The 'test' value must be greater than or equal to the stored value for this task to be permitted.

TYPE_DOUBLE_ARRAY 

Array of extra floating point parameters. The test value must equal one of these values for the task to be permitted.

TYPE_EQ_STRING 

Single extra string parameter. The 'test' value must equal the stored value for this task to be permitted.

TYPE_STRING_ARRAY 

Array of extra string parameters. The test value must equal one of these values for the task to be permitted.

TYPE_USERS_ARRAY 

Array of user IDs, similar to TYPE_LONG_ARRAY. When this type of task is assigned to a group, it is automatically filled with all user IDs in the group.

TYPE_ALL_USERS_ARRAY 

Array of user IDs, similar to TYPE_LONG_ARRAY. When this type of task is assigned to a group, it is automatically filled with the user IDs of all users that are in any group that the user belongs to.

Constructor & Destructor Documentation

◆ ms_security_task()

Create a new empty object - not particularly useful.

Default constructor does nothing. Need to call loadFromFile() or addTask() to assign tasks to the list.

◆ ~ms_security_task()

Destructor of the class.

The destructor is never called directly.

Member Function Documentation

◆ addDoubleParam()

bool addDoubleParam ( const double  value)

Add a floating point parameter to the task.

This function will generally only be called by Administration utilities.

See also addLongParam() for an example.

Parameters
value
Returns
true for any of the valid types above, otherwise return false because the expected parameter type is not correct.

◆ addLongParam()

bool addLongParam ( const long  value)

Add a long parameter to the task.

This function will generally only be called by Administration utilities. For example, this could be the maximum number of spectra permitted for a search.

See also isPermitted_long() which might be called by other applications to determine if a user has rights to run, for example, a search with 1000 spectra.

Parameters
value
Returns
true for any of the valid types above, otherwise return false because the expected parameter type is not correct.

◆ addStringParam()

bool addStringParam ( const std::string  value)

Add a string parameter to the task.

This function will generally only be called by Administration utilities. For example, this could be a list of databases that may be searched.

See also isPermitted_string() which might be called by other applications to determine if a user has rights to run, for example, a search agains EST_others.

Parameters
value
Returns
true for any of the valid types above, otherwise return false because the expected parameter type is not correct.

◆ clearParams()

void clearParams ( )

Clears all parameters.

These parameters are not saved in the tasks file, but in the individual groups files.

◆ getAllParamsAsString()

std::string getAllParamsAsString ( ) const

Return all the parameters as a comma separated string.

This function is mostly useful for debugging, or possibly for an administration application.

Returns
A comma separated string of values.

◆ getConstantName()

std::string getConstantName ( ) const

Returns the 'constant definition name' for the task.

Each task that has been predefined by Matrix Science will have a definition that can be used by applications calling Mascot Parser instead of just using the number (available from getID()). Any additional tasks added by end users will have a constant name, but this cannot be used in the calling code because it will not be embedded into the library.

Returns
constant name of the task

◆ getDescription()

std::string getDescription ( ) const

Returns a single line description for the task.

This should describe the task sufficiently well for an administrator.

Returns
description of the task

◆ getDoubleParams()

std::vector< double > getDoubleParams ( ) const

Get the list of long parameters for the task.

If the task type is one of the following, then the function will return a single long value in the array:

If the task type is ms_security_task::TYPE_DOUBLE_ARRAY then the function will return an array of long values.

For all other task types, the return value will be an empty array.

See Using STL vector classes vectori, vectord and VectorString in Perl, Java, Python and C#.

Returns
vector of double param values, can be empty

◆ getID()

int getID ( ) const

Returns the unique ID for the task.

IDs up to 1000 are reserved for use by Matrix Science. Values above 1000 may be used by other applications.

Returns
id of the task

◆ getLongParams()

std::vector< long > getLongParams ( ) const

Get the list of long parameters for the task.

If the task type is one of the following, then the function will return a single long value in the array:

If the task type is ms_security_task::TYPE_LONG_ARRAY or TYPE_USERS_ARRAY or TYPE_ALL_USERS_ARRAY then the function will return an array of long values.

For all other task types, the return value will be an empty array.

See Using STL vector classes vectori, vectord and VectorString in Perl, Java, Python and C#.

Returns
vector of long param values, can be empty

◆ getNotes()

std::string getNotes ( ) const

Returns any notes applied to the task.

Optional notes to describe the values. Could be displayed by an administration utility for providing further help.

Returns
notes of the task

◆ getStringParams()

std::vector< std::string > getStringParams ( ) const

Get the list of string parameters for the task.

If the task type is one of the following, then the function will return a single long value in the array:

If the task type is ms_security_task::TYPE_STRING_ARRAY then the function will return an array of long values.

For all other task types, the return value will be an empty array.

See Using STL vector classes vectori, vectord and VectorString in Perl, Java, Python and C#.

Returns
vector of string param values, can be empty

◆ isPermitted()

bool isPermitted ( ) const

See if the task is permitted.

For example, this could called by an application to determine if a user has rights to access administration screens.

This function should only be called if the parameter type is ms_security_task::TYPE_BOOL in which case it will return true.

Returns
true if the parameter type is ms_security_task::TYPE_BOOL, otherwise it will return false.

◆ isPermitted_double()

bool isPermitted_double ( const double  value) const

See if the value is in the floating point parameter list.

For example, this could called by an application to determine if a user has rights to run a search with 1000 spectra (except this would use LONG rather than DOUBLE).

Parameters
value
Returns
true if one of the conditions above is met, otherwise it will return false.

◆ isPermitted_long()

bool isPermitted_long ( const long  value) const

See if the value is in the long integer parameter list.

For example, this could called by an application to determine if a user has rights to run a search with 1000 spectra.

Parameters
value
Returns
true if one of the conditions above is met, otherwise it will return false.

◆ isPermitted_string()

bool isPermitted_string ( const std::string  value) const

See if the value is in the string parameter list.

For example, this function could be called by an application to determine if a user has rights to run, for example, a search against EST_others.

Parameters
value
Returns
true if one of the conditions above is met, otherwise it will return false.

◆ setParams()

void setParams ( const std::string  value)

Set all parameters, regardless of type.

This function will generally only be called by Administration utilities. It is useful when setting parameters from a general edit box. The text is parsed and if a list is expected, this will be split at commas or spaces.

Parameters
valueparameter value to set, can be a comma or space separated list

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