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. | |
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
.
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.
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.
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.
value |
|
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.
value |
|
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.
value |
|
void clearParams | ( | ) |
Clears all parameters.
These parameters are not saved in the tasks file, but in the individual groups files.
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.
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.
std::string getDescription | ( | ) | const |
Returns a single line description for the task.
This should describe the task sufficiently well for an administrator.
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#.
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.
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#.
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.
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#.
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.
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).
value |
|
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.
value |
|
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.
value |
|
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.
value | parameter value to set, can be a comma or space separated list |