Constructor
new module:ct-services /testing /Permission Service Stub()
Constructs a PermissionServiceStub
.
- Implements:
Methods
add Attribute Listener(attribute Name, listener)
Registers a listener that subscribes to current and future values of a single user attribute. After calling this method, the registered listener will be notified of the value of the user attribute.
This is the value assigned to the logged in user. To be notified of the value assigned to the user they are trading on behalf of,
call module:ct-security/permissioning/PermissionService#addToboUserAttributeListener
instead.
The listener that you register must implement
module:ct-services/security/PermissionServiceListener#onAttributeChanged
, which is called when the listener is first
registered and also when the value of the attribute changes.
Parameters:
Name | Type | Description |
---|---|---|
attributeName |
string | The name of the user attribute that you want to subscribe to. |
listener |
module:ct-services |
The listener object that will receive the subscription updates. |
add Global Permission Listener(product, action, listener) → {int}
Registers a listener that subscribes to current and future permissions for an action on a single product in the global (default) namespace. After calling this method, the registered listener will be notified of the permission that the user has for the requested action on the specified product.
The listener that you register must implement
module:ct-services/security/PermissionServiceListener#onSinglePermissionChanged
, which is called when the listener is first
registered and also when the product permission changes.
Note: If you want to specify a different namespace, then use module:ct-security/permissioning/PermissionService#addPermissionListener
instead.
Parameters:
Name | Type | Description |
---|---|---|
product |
string | The name of the product that the subscription is for (for example '/FX/EURUSD'). |
action |
string | The action that the subscription is for (for example 'TRADE'). |
listener |
module:ct-services |
The listener object that will receive the subscription updates. |
- Implements:
- See:
-
- module:ct-security/permissioning/PermissionService#canUserPerformGlobalAction
- module:ct-security/permissioning/PermissionService#removeListener
Returns:
A unique indentifier that allows the listener to be removed from the listener register (see module:ct-security/permissioning/PermissionService#removeListener
).
- Type
- int
add Permission Listener(product, namespace, action, listener) → {int}
Registers a listener that subscribes to current and future permissions for an action on a single product in a given namespace. After calling this method, the registered listener will be notified of the permission that the user has for the requested action on the specified product.
The listener that you register must implement
module:ct-services/security/PermissionServiceListener#onSinglePermissionChanged
, which is called when the listener is first
registered and also when the product permission changes.
Note: If you want to specify the global (default) namespace, then use module:ct-security/permissioning/PermissionService#addGlobalPermissionListener
instead.
Parameters:
Name | Type | Description |
---|---|---|
product |
string | The name of the product that the subscription is for (for example '/FX/EURUSD'). |
namespace |
string | The namespace in which the product permission resides (for example 'tenors'). |
action |
string | The action that the subscription is for (for example 'TRADE'). |
listener |
module:ct-services |
The listener object that will receive the subscription updates. |
- Implements:
- See:
-
- module:ct-security/permissioning/PermissionService#canUserPerformAction
- module:ct-security/permissioning/PermissionService#removeListener
Returns:
A unique identifier that allows the listener to be removed from the listener register (see module:ct-security/permissioning/PermissionService#removeListener
).
- Type
- int
add Permission Set Listener(product, namespaceopt, type, listener) → {int}
Registers a listener that subscribes to a set of current and future permissions on a single product in a given namespace. You can
subscribe to module:ct-security/permissioning/PermissionService#ALL
permissions, module:ct-security/permissioning/PermissionService#ALLOW
permissions, or module:ct-security/permissioning/PermissionService#DENY
permissions.
After calling this method, the registered listener will be notified of the set of actions in the given namespace for which the user has the requested permission. A typical use would be to subscribe to the set of permitted tenors on a product.
The listener that you register must implement
module:ct-services/security/PermissionServiceListener#onPermissionsChanged
, which is called when the listener is first
registered and also when a product permission changes.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
product |
string | The name of the product that the subscription is for (for example '/FX/EURUSD'). |
|
namespace |
string |
<optional> |
The namespace in which the product permission resides (for example 'tenors'). If |
type |
string | The type of permission that the subscription is for ( |
|
listener |
module:ct-services |
The listener object that will receive the subscription updates. |
- Implements:
- See:
-
- module:ct-security/permissioning/PermissionService#getAllowPermissions
- module:ct-security/permissioning/PermissionService#getAllPermissions
- module:ct-security/permissioning/PermissionService#getDenyPermissions
- module:ct-security/permissioning/PermissionService#removeListener
Returns:
A unique identifier that allows the listener to be removed from the listener register (see module:ct-security/permissioning/PermissionService#removeListener
).
- Type
- int
add Product Permissions Listener(products, namespaceopt, action, is Authorized, listener) → {int}
Registers a listener that subscribes to current and future permissions on a set of products. You can subscribe to products for which an action is either alllowed or denied.
After calling this method, the registered listener will be notified of the subset of products for which the user has the requested permission for the requested action.
The listener that you register must implement
module:ct-services/security/PermissionServiceListener#onPermissionsChanged
, which is called when the listener is first
registered and also when a permission changes for any product in the given set of products.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
products |
Array |
An array of strings representing the set of products that the subscription is for. |
|
namespace |
string |
<optional> |
The namespace in which the product permission resides (for example 'tenors'). If |
action |
string | The action that the subscription is for (for example 'TRADE'). |
|
isAuthorized |
boolean | The type of permission that the subscription is for ( |
|
listener |
module:ct-services |
The listener object that will receive the subscription updates. |
- Implements:
- See:
-
- module:ct-security/permissioning/PermissionService#getPermissionedProducts
- module:ct-security/permissioning/PermissionService#getUnpermissionedProducts
- module:ct-security/permissioning/PermissionService#removeListener
Returns:
A unique identifier that allows the listener to be removed from the listener register (see module:ct-security/permissioning/PermissionService#removeListener
).
- Type
- int
add Registration Listener(callback)
Allows the user to register a callback method that will be caled every time addPermissionListener() is called this enable a workbench tool to update its GUI.
Parameters:
Name | Type | Description |
---|---|---|
callback |
function | Method to be called any time addPermissionListener is called |
allow()
Notifies the appropiate listeners that a permission defined by namespace, product and action is allowed
can User Perform Action(product, namespace, action) → {boolean}
Determines whether an action on a product is allowed or denied in a given permissioning namespace.
Note: If you want to specify the global (default) namespace, then use module:ct-security/permissioning/PermissionService#canUserPerformGlobalAction
instead.
Parameters:
Name | Type | Description |
---|---|---|
product |
string | The name of the product (for example '/FX/EURUSD'). |
namespace |
string | The namespace in which the product permission resides (for example 'tenors'). |
action |
string | The action on which the permission may be granted (for example 'TRADE'). |
Returns:
true
if the action is allowed, false
if the action is denied.
- Type
- boolean
can User Perform Global Action(product, action) → {boolean}
Determines whether an action on a product is allowed or denied in the global (default) namespace.
Note: If you want to specify a different namespace, then use module:ct-security/permissioning/PermissionService#canUserPerformAction
instead.
Parameters:
Name | Type | Description |
---|---|---|
product |
string | The name of the product (for example '/FX/EURUSD'). |
action |
string | The action on which the permission may be granted (for example 'TRADE'). |
Returns:
true
if the action is allowed, false
if the action is denied.
- Type
- boolean
deny()
Notifies the appropiate listeners that a permission defined by namespace, product and action is denied
dispose()
Disposes of any listeners and resources that were used by the service.
get Allow Permissions(product, namespaceopt, sort Functionopt) → {Array.< string>}
Returns the set of actions that are allowed on a product within a given namespace. A typical use would be to retrieve the set of allowed tenors on a product.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
product |
string | The name of the product (for example '/FX/EURUSD'). |
|
namespace |
string |
<optional> |
The namespace in which the product permissions reside (for example 'tenors'). If |
sortFunction |
function |
<optional> |
An optional function used to sort the list of permissions returned from the PermissionEngine, if not passed in, the permissions will be returned unsorted. |
- Implements:
- See:
-
- module:ct-security/permissioning/PermissionService#getAllPermissions
- module:ct-security/permissioning/PermissionService#getDenyPermissions
- module:ct-security/permissioning/PermissionService#addPermissionSetListener
Returns:
An array of strings representing actions that are allowed on the product.
- Type
-
Array
.<string>
get All Permissions(product, namespaceopt) → {Array.< string>}
Returns the entire set of permissioned actions on a product within a given namespace. The entire set includes the actions that are allowed and the actions that are denied.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
product |
string | The name of the product (for example '/FX/EURUSD'). |
|
namespace |
string |
<optional> |
The namespace in which the product permissions reside (for example 'tenors'). If |
- Implements:
- See:
-
- module:ct-security/permissioning/PermissionService#getAllowPermissions
- module:ct-security/permissioning/PermissionService#getDenyPermissions
- module:ct-security/permissioning/PermissionService#addPermissionSetListener
Returns:
An array of strings representing all permissioned actions on the product (allowed and denied).
- Type
-
Array
.<string>
get Deny Permissions(product, namespaceopt) → {Array.< string>}
Returns the set of actions that are denied on a product within a given namespace. A typical use would be to retrieve the set of denied tenors on a product.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
product |
string | The name of the product (for example '/FX/EURUSD'). |
|
namespace |
string |
<optional> |
The namespace in which the product permissions reside (for example 'tenors'). If |
- Implements:
- See:
-
- module:ct-security/permissioning/PermissionService#getAllPermissions
- module:ct-security/permissioning/PermissionService#getAllowPermissions
- module:ct-security/permissioning/PermissionService#addPermissionSetListener
Returns:
An array of strings representing actions that are denied on the product.
- Type
-
Array
.<string>
get User Allowed Products(namespaceopt, action) → {Array.< string>}
Returns the products that have 'Allow' permission for a given namespace and action.
The allowed products are always for the logged in user only, even if they are trading on behalf of another user.
To get allowed products for the user they are trading on behalf of, call module:ct-security/permissioning/PermissionService#getToboAllowedProducts
instead.
A typical use would be to get the users (as an array of products) that the logged in user can trade on behalf of (TOBO). By convention, the namespace of such products is 'TradeOnBehalfOf' and the action is 'ChangeTradeOnBehalfOfUser'. For further information about TOBO, refer to the document Caplin Platform: Permissioning Overview And Concepts.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
namespace |
string |
<optional> |
The namespace in which the product permissions reside (for example 'tenors'
or 'TradeOnBehalfOf'). If omitted or set to |
action |
string | The action that is allowed (for example '1-Week' or 'ChangeTradeOnBehalfOfUser'). |
Returns:
An array of strings representing the allowed products. Each string in the array could be a JavaScript regular expression that matches more than one product.
- Type
-
Array
.<string>
get User Attribute(attribute Name) → {string}
Gets the current value of a user attribute.
This is the value assigned to the logged in user. To get the value assigned to a user they are trading
on behalf of, call module:ct-security/permissioning/PermissionService#getToboUserAttribute
instead.
Parameters:
Name | Type | Description |
---|---|---|
attributeName |
string | The name of the user attribute that you want the value of. |
Returns:
The value of the user attribute.
- Type
- string
get User Denied Products(namespaceopt, action) → {Array.< string>}
Returns the products that have 'Deny' permission for a given namespace and action.
The denied products are always for the logged in user only, even if they are trading on behalf of another user.
To get denied products for the user they are trading on behalf of, call module:ct-security/permissioning/PermissionService#getToboDeniedProducts
instead.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
namespace |
string |
<optional> |
The namespace in which the product permissions reside (for example 'tenors').
If omitted or set to |
action |
string | The action that is denied (for example '1-week'). |
Returns:
An array of strings representing the denied products. Each string in the array could be a JavaScript regular expression that matches more than one product.
- Type
-
Array
.<string>
remove Listener(listener Id)
Removes a listener from the listener register. The removed listener will no longer be notified of current or future product permissions.
Parameters:
Name | Type | Description |
---|---|---|
listenerId |
int | The unique identifier that was returned when the listener was registered. |
- Implements:
- See:
-
- module:ct-security/permissioning/PermissionService#addPermissionListener
- module:ct-security/permissioning/PermissionService#addGlobalPermissionListener
- module:ct-security/permissioning/PermissionService#addProductPermissionsListener
- module:ct-security/permissioning/PermissionService#addPermissionSetListener
set All Permissions For Product Sets(m _permissioned Products)
This method allows you to override the existing list of product sets. Product set listeners will be notified about product sets changes.
Parameters:
Name | Type | Description |
---|---|---|
m_permissionedProducts |
Object | Product set map. Each key will represent a namespace and its value will be an array of products. |
set Product Sets Permissions(namespace, products)
Allows to set product sets permissions. It will callback on the product sets listeners registered for the given namespace.
Parameters:
Name | Type | Description |
---|---|---|
namespace |
String | Namespace identifying the product set. |
products |
Array | Array of products for the given namespace. |