public interface IlrSessionController extends IlrSessionCallback
IlrSessionController is the base interface for all
classes that define security settings and interactive behavior for Decision Center.
To keep the default behavior for customized session controller,
subclass IlrDefaultSessionController, then enhance only the
features you want to change, each method in your customized session
controller class must call its super method first.
Code examples
This section contains two code examples. The first example shows how to customize Decision Center security; the second shows how to trace user activity to a log file.
Note: The custom classes implement
IlrDefaultSessionController, and not
IlrSessionController directly. This makes sure that the default
behavior of Decision Center in all other domains is retained.
You register these classes with Decision Center by adding the following line
to the preferences.properties file:
The following code example shows a custom session controller implementation
that will be used by Decision Center to check if the current user has the
rights to update an element:
The following code example shows a custom session controller implementation
that will be used by Decision Center to log actions by the current user:
teamserver.controller.class=ilog.rules.rts.samples.permissiontuning.WorkflowSessionController
Customizing Decision Center Security
public class WorkflowSessionController extends IlrDefaultSessionController {
// Constants for role definition
public static final String ADMINISTRATOR_ROLE = "rtsAdministrator";
// This method is called in the GUI to find out whether or not a property should be grayed and,
// before committing a change, to check the permissions.
public void checkUpdate(IlrElementHandle element, IlrElementDetails details, org.eclipse.emf.ecore.EStructuralFeature feature)
throws IlrPermissionException, IlrObjectNotFoundException {
IlrSession session = element.getSession();
IlrElementDetails elementDetails = session.getElementDetails(element);
// If we are checking a Business Rule...
if (elementDetails!=null && elementDetails.isInstanceOf("BusinessRule")) {
// Get the status of the rule
String status = (String)elementDetails.getPropertyValue("status");
// If the status is 'deployable', forbid any change
if (status.equals("deployable") &&! session.isUserInRole(ADMINISTRATOR_ROLE))
throw new IlrPermissionException("Unable to change a deployable rule");
}
}
}
Logging Decision Center User Activity
public class LogController extends IlrDefaultSessionController {
private BufferedWriter outfile = null;
public LogController() throws IOException{
Date myDate = new Date();
String outputFile = "RTSLog" + myDate.getTime();
outfile = new BufferedWriter(new FileWriter(outputFile, true));
}
public void elementDeleted(IlrElementHandle handle)
throws IlrObjectNotFoundException {
// Always call the super method
super.elementDeleted(handle);
try{
log((IlrModelElement) handle, "DELETE");
} catch(IOException e){;}
}
public void elementCommitted(IlrCommitableObject cobject,
IlrElementHandle newHandle) throws IlrObjectNotFoundException {
// Always call the super method
super.elementCommitted(cobject, newHandle);
Object detail = session.getElementDetails(newHandle);
if (!(detail instanceof IlrModelElement))
return;
try {
log( (IlrModelElement) detail, "COMMITTED");
}catch(IOException e){;}
}
public void log(IlrModelElement element, String action) throws IOException
{
String logComment = action + " " + element.getName();
logComment += " uuid " + element.getUuid();
logComment += " changed on " + element.getLastChangedOn();
logComment += " by " + element.getLastChangedBy();
logComment += " committed by " + session.getUserName();
outfile.write( logComment);
outfile.flush();
}
}
CHANGE_ACTIVITY_CONTROLLER_CALLBACK, CONTROLLER_CALLBACK, ISUSERINROLE_CALLBACK, RELEASE_CONTROLLER_CALLBACK, VALIDATION_ACTIVITY_CONTROLLER_CALLBACK| Modifier and Type | Method and Description |
|---|---|
void |
checkCreate(IlrBaseline baseline,
org.eclipse.emf.ecore.EClass eclass)
Checks whether the current user has the right to create elements of the
given class.
|
void |
checkDelete(IlrBranch branch,
IlrElementHandle element)
Checks whether the current user has the right to delete the given element in the given branch.
|
void |
checkDelete(IlrElementHandle element)
Checks whether the current user has the right to delete the given element.
|
void |
checkUpdate(IlrBaseline baseline,
IlrElementHandle element,
IlrElementDetails details,
org.eclipse.emf.ecore.EStructuralFeature feature)
Checks whether the current user has the right to update the given element in given branch.
|
void |
checkUpdate(IlrElementHandle element,
IlrElementDetails details,
org.eclipse.emf.ecore.EStructuralFeature feature)
Deprecated.
replaced by checkUpdate(IlrBaseline baseline, IlrElementHandle element, IlrElementDetails details, EStructuralFeature feature).
|
void |
elementAddedToBaseline(IlrElementHandle element,
IlrBaseline baseline)
Implements a custom session controller that changes the way in which Decision
Center reacts to an action.
|
void |
elementCommitted(IlrBranch branch,
IlrCommitableObject cobject,
IlrElementHandle newHandle)
This method is called just after an element has been committed.
|
void |
elementCommitted(IlrCommitableObject cobject,
IlrElementHandle newHandle)
Deprecated.
use elementCommitted(IlrBranch, IlrCommitableObject, IlrElementHandle).
|
void |
elementDeleted(IlrBaseline baseline)
This method is called just after a baseline has been deleted.
|
void |
elementDeleted(IlrBranch branch,
IlrElementHandle element)
This method is called just after an element has been deleted.
|
void |
elementDeleted(IlrElementHandle element)
Deprecated.
use elementDeleted(IlrBranch, IlrElementHandle)
|
void |
elementDeleted(IlrProjectInfo prjInfo)
This method is called just after a project info has been deleted.
|
void |
elementRemovedFromBaseline(IlrElementHandle element,
IlrBaseline baseline)
Implements a custom session controller that changes the way in which Decision
Center reacts to an action.
|
java.lang.Object |
getInitialValue(IlrElementDetails element,
org.eclipse.emf.ecore.EStructuralFeature feature)
Gets the initial value for the given feature.
|
IlrBusinessVersion |
getNextVersion(boolean isNew,
boolean isNewInBranch,
IlrBusinessVersion previousVersion)
Called By RTS when creating or updating an element to get the new version details.
|
java.util.List |
getPossibleValues(IlrElementHandle element,
org.eclipse.emf.ecore.EStructuralFeature feature)
Gets the possible values for the given feature.
|
boolean |
isEditable(IlrElementHandle element,
java.lang.String feature)
Tests whether the given feature for a specific element is editable.
|
boolean |
isHidden(IlrElementHandle element,
java.lang.String feature)
Tests whether the given feature for a specific element must be hidden.
|
boolean |
isServerVisible(IlrServer server,
IlrRuleApp ruleApp)
Called when the list of servers to deploy on is displayed.
|
boolean |
isServerVisible(IlrServer server,
IlrScenarioSuite suite)
This method is called when the list of servers that can be set on the test suite is displayed.
|
java.lang.String |
isValid(IlrElementHandle element,
java.lang.String feature,
java.lang.Object value)
Tests whether the given value for a specific feature and element is valid.
|
void |
onAddElementToBaseline(IlrElementHandle element,
IlrBaseline baseline)
Implements a custom session controller that changes the way in which Decision
Center reacts to an action.
|
void |
onCheckRulesetArchive(ilog.rules.archive.IlrRulesetArchive rulesetArchive,
IlrBaseline baseline,
IlrSearchCriteria ruleArtifactquery,
ilog.rules.commonbrm.extractor.IlrExtractorValidator extractorValidator,
java.util.List generationErrors)
Called when a generated ruleset archive is being checked.
|
void |
onCommitElement(IlrBranch branch,
IlrCommitableObject cobject)
This method is called when entering the
IlrSession.commit
method, just before effectively committing an element. |
void |
onCommitElement(IlrCommitableObject cobject)
Deprecated.
This method is called when entering the
IlrSession.commit
method, just before effectively committing an element.
Implements a custom session controller to change the way in which Decision Center reacts to this action. This method assume the commit operation is applied on the working branch. The new method onCommitElement(IlrBranch, IlrCommitableObject) should be used instead of this one in order to specify the branch in which the commit operation is executed. |
void |
onDeleteElement(IlrBranch branch,
IlrElementHandle element)
This method is called when entering the
IlrSession.delete
method, just before deleting an element. |
void |
onDeleteElement(IlrElementHandle element)
Deprecated.
use onDeleteElement(IlrBranch, IlrElementHandle) ;
|
void |
onGenerateRulesetArchive(ilog.rules.engine.IlrRulesetArchiveBuilder rulesetArchiveBuilder,
IlrBaseline baseline,
IlrSearchCriteria ruleArtifactquery,
ilog.rules.commonbrm.extractor.IlrExtractorValidator extractorValidator)
Called at the end of the generation of a ruleset archive.
|
void |
onRemoveElementFromBaseline(IlrElementHandle element,
IlrBaseline baseline)
Implements a custom session controller that changes the way in which Decision
Center reacts to an action.
|
IlrSearchCriteria |
redefineSearch(IlrSearchCriteria searchCriteria)
Called each time a search is performed using search criteria.
|
void |
securityProfileCommitted(java.lang.String role,
IlrSecurityProfileData profile)
Called when new permissions for a given
role have been committed. |
void |
securityProfileDeleted(java.lang.String role)
Called when permissions for a given
role have been deleted. |
setSessionvoid checkDelete(IlrElementHandle element) throws IlrPermissionException, IlrObjectNotFoundException
This method is called by the
IlrSession.deleteElement(IlrElementHandle) method, just before
element is finally deleted. For Decision Center GUI front
ends, this method might also be called to check if the
"Delete" button is grayed out for element.
IlrPermissionException - if the current user does not have the
right to delete element.IlrObjectNotFoundException - if element is not found in
the Decision Center database.element - The handle of the element to be deleted.void checkDelete(IlrBranch branch, IlrElementHandle element) throws IlrPermissionException, IlrObjectNotFoundException
This method is called by the
IlrSession.deleteElement(IlrElementHandle) method, just before
element is finally deleted. For Decision Center GUI front
ends, this method might also be called to check if the
"Delete" button is grayed out for element.
IlrPermissionException - if the current user does not have the
right to delete element.IlrObjectNotFoundException - if element is not found in
the Decision Center database.branch - The branch in which the permission should be checked.element - The handle of the element to be deleted.void checkCreate(IlrBaseline baseline, org.eclipse.emf.ecore.EClass eclass) throws IlrPermissionException, IlrObjectNotFoundException
For Decision Center GUI front ends, this method is called to check if a "New" button can be grayed out, or to compute the list of available types.
IlrPermissionException - if the current user does not have the
right to create eclass.IlrObjectNotFoundException - If element cannot be found
in the Decision Center database.baseline - The branch on which the check should be done. If this argument is null, the working baseline is checked.eclass - The element class.void checkUpdate(IlrElementHandle element, IlrElementDetails details, org.eclipse.emf.ecore.EStructuralFeature feature) throws IlrPermissionException, IlrObjectNotFoundException
Decision Center calls this method in several places. It is called by the Decision Center GUI front end to check if:
commit method to check if
the details of an edited object can be committed.IlrPermissionException - if the current user does not have the
rights to change element.IlrObjectNotFoundException - if feature is not found in
the Decision Center database.element - The element handle. This parameter may be set to
null.details - The object that will be committed if this method does not
throw any exceptions. This parameter may be set to null.feature - The feature to modify. If set to null,
you should consider whether the entire object can be modified in your
custom session controller.void checkUpdate(IlrBaseline baseline, IlrElementHandle element, IlrElementDetails details, org.eclipse.emf.ecore.EStructuralFeature feature) throws IlrPermissionException, IlrObjectNotFoundException
Decision Center calls this method in several places. It is called by the Decision Center GUI front end to check if:
commit method to check if
the details of an edited object can be committed.IlrPermissionException - if the current user does not have the
rights to change element.IlrObjectNotFoundException - if feature is not found in
the Decision Center database.element - The element handle. This parameter may be set to
null.details - The object that will be committed if this method does not
throw any exceptions. This parameter may be set to null.feature - The feature to modify. If set to null,
you should consider whether the entire object can be modified in your
custom session controller.java.util.List getPossibleValues(IlrElementHandle element, org.eclipse.emf.ecore.EStructuralFeature feature) throws IlrObjectNotFoundException
Optionally, the element for which the framework wants the possible values can be given. This allows implementors to dynamically compute the possible values according to the current state of the element.
IlrObjectNotFoundException - if feature is not found in
the Decision Center database.element - The element handle. This parameter may be set to
null.feature - The feature whose possible values you want to retrieve.
This must be an attribute whose type is enumerated (EEnum).null. Set your custom implementation to return
List.EMPTY_LIST if there are no possible values to return.java.lang.Object getInitialValue(IlrElementDetails element, org.eclipse.emf.ecore.EStructuralFeature feature) throws IlrObjectNotFoundException
IlrObjectNotFoundException - if feature is not found in
the Decision Center database.element - The element handle. This parameter may be set to null.feature - The feature whose initial value is to be returned.null.void elementCommitted(IlrCommitableObject cobject, IlrElementHandle newHandle) throws IlrApplicationException
Implements a custom session controller to change the way in which Decision Center reacts to this action.
IlrObjectNotFoundException - if object is not found in the database.IlrApplicationExceptioncobject - The committed object.newHandle - The new handle.IlrSession.commit(IlrCommitableObject),
Overviewvoid elementCommitted(IlrBranch branch, IlrCommitableObject cobject, IlrElementHandle newHandle) throws IlrApplicationException
Implements a custom session controller to change the way in which Decision Center reacts to this action.
IlrObjectNotFoundException - if object is not found in the database.IlrApplicationExceptioncobject - The committed object.newHandle - IlrSession.commit(IlrCommitableObject),
Overviewvoid elementDeleted(IlrElementHandle element) throws IlrObjectNotFoundException
Implements a custom session controller to change the way in which Decision Center reacts to this action.
IlrObjectNotFoundException - if element is not found in
the database.element - The deleted object.IlrSession.deleteElement(IlrElementHandle),
Overviewvoid elementDeleted(IlrBranch branch, IlrElementHandle element) throws IlrObjectNotFoundException
Implements a custom session controller to change the way in which Decision Center reacts to this action.
IlrObjectNotFoundException - if element is not found in
the database.element - The deleted object.IlrSession.deleteElement(IlrElementHandle),
Overviewvoid elementDeleted(IlrBaseline baseline) throws IlrObjectNotFoundException
Implements a custom session controller to change the way in which Decision Center reacts to this action.
IlrObjectNotFoundException - if baseline is not found
in the database.baseline - The deleted baseline.IlrSession.deleteElement(IlrElementHandle),
Overviewvoid elementDeleted(IlrProjectInfo prjInfo) throws IlrObjectNotFoundException
Implements a custom session controller to change the way in which Decision Center reacts to this action.
IlrObjectNotFoundException - if prjInfo is not found
in the database.prjInfo - The deleted project info.IlrSession.deleteElement(IlrElementHandle),
Overviewvoid elementAddedToBaseline(IlrElementHandle element, IlrBaseline baseline) throws IlrApplicationException
IlrApplicationException - if element cannot be added to
baseline.element - The element to add.baseline - The baseline to update.IlrBaselineManagementFacility.addToBaseline(IlrElementHandle, IlrBaseline),
Overviewvoid elementRemovedFromBaseline(IlrElementHandle element, IlrBaseline baseline) throws IlrApplicationException
IlrApplicationException - if element cannot be removed from
baseline.element - The element that has been removed.baseline - The baseline to update.IlrBaselineManagementFacility.addToBaseline(IlrElementHandle, IlrBaseline),
Overviewvoid onCommitElement(IlrCommitableObject cobject) throws IlrApplicationException
IlrSession.commit
method, just before effectively committing an element.
Implements a custom session controller to change the way in which Decision Center reacts to this action. This method assume the commit operation is applied on the working branch. The new method onCommitElement(IlrBranch, IlrCommitableObject) should be used instead of this one in order to specify the branch in which the commit operation is executed.
IlrObjectNotFoundException - if cobject is not found in
the database.IlrPermissionException - if the current user does not have the
rights to commit cobject.IlrInvalidElementException - if cobject is invalid.
For example, if the name of a project element is null.IlrActivityObjectLockedExceptionIlrApplicationException - if an operation throws one.cobject - The object to be committed.IlrSession.commit(IlrCommitableObject),
Overviewvoid onCommitElement(IlrBranch branch, IlrCommitableObject cobject) throws IlrApplicationException
IlrSession.commit
method, just before effectively committing an element.
Implements a custom session controller to change the way in which Decision Center reacts to this action.
IlrObjectNotFoundException - if cobject is not found in
the database.IlrPermissionException - if the current user does not have the
rights to commit cobject.IlrInvalidElementException - if cobject is invalid.
For example, if the name of a project element is null.IlrActivityObjectLockedExceptionIlrApplicationException - if an operation throws one.branch - The branch in which the element should get committed.cobject - The object to be committed.IlrSession.commit(IlrCommitableObject),
Overviewvoid onDeleteElement(IlrElementHandle element) throws IlrApplicationException
IlrSession.delete
method, just before deleting an element.
Implements a custom session controller to change the way in which Decision Center reacts to this action.
IlrApplicationExceptionelement - The object to be deleted.IlrSession.deleteElement(IlrElementHandle),
Overviewvoid onDeleteElement(IlrBranch branch, IlrElementHandle element) throws IlrApplicationException
IlrSession.delete
method, just before deleting an element.
Implements a custom session controller to change the way in which Decision Center reacts to this action.
IlrApplicationExceptionelement - The object to be deleted.IlrSession.deleteElement(IlrElementHandle),
Overviewvoid onAddElementToBaseline(IlrElementHandle element, IlrBaseline baseline) throws IlrApplicationException
IlrSession.addToBaseline
method, just before the element is added to a baseline.IlrApplicationException - if element cannot be added to
baseline.element - The element to be added.baseline - The baseline to be updated.IlrBaselineManagementFacility.addToBaseline(IlrElementHandle, IlrBaseline),
Overviewvoid onRemoveElementFromBaseline(IlrElementHandle element, IlrBaseline baseline) throws IlrApplicationException
IlrSession.removeFromBaseline
method, just before the element is removed from a baseline.IlrApplicationException - if element cannot be removed from
baseline.element - The element to be removed.baseline - The baseline to be updated.IlrBaselineManagementFacility.addToBaseline(IlrElementHandle, IlrBaseline),
Overviewboolean isHidden(IlrElementHandle element, java.lang.String feature) throws IlrObjectNotFoundException
This method is used in the UI to test if the current user has
the rights to see the feature.
IlrObjectNotFoundException - If element is not found in
the database.element - The element handle.feature - The feature to test.True if feature is hidden.boolean isEditable(IlrElementHandle element, java.lang.String feature) throws IlrObjectNotFoundException
This method is used in the UI to check if feature
may be edited by the current user.
IlrObjectNotFoundException - If an object is not found in the database.element - The element handle.feature - The feature to test.True if feature is editable.java.lang.String isValid(IlrElementHandle element, java.lang.String feature, java.lang.Object value) throws IlrObjectNotFoundException
This method is used in the UI to check if value
can be entered by the current user.
IlrObjectNotFoundException - If an object is not found in the database.element - The element handle.feature - The feature to test.null otherwise.void onGenerateRulesetArchive(ilog.rules.engine.IlrRulesetArchiveBuilder rulesetArchiveBuilder,
IlrBaseline baseline,
IlrSearchCriteria ruleArtifactquery,
ilog.rules.commonbrm.extractor.IlrExtractorValidator extractorValidator)
Implement this method in your custom session controller to manipulate
the content of an archive using the IlrRulesetArchiveBuilder
class. This method is called just before the archive is generated.
See IlrRulesetArchiveBuilderBase.generate() for
more information.
rulesetArchiveBuilder - The ruleset archive builder, ready to generate
a ruleset archive. It contains the execution artifacts resulting from the
extraction of the ruleset being generated.baseline - The baseline from which the execution artifacts were
extracted.ruleArtifactquery - The query used to get the rule artifacts to be
extracted. This parameter can be set to null.extractorValidator - The extractor validator used to filter out the
artifacts to be extracted.IlrDeploymentFacility.generateRulesetArchive(IlrSearchCriteria, String, String),
Overviewvoid onCheckRulesetArchive(ilog.rules.archive.IlrRulesetArchive rulesetArchive,
IlrBaseline baseline,
IlrSearchCriteria ruleArtifactquery,
ilog.rules.commonbrm.extractor.IlrExtractorValidator extractorValidator,
java.util.List generationErrors)
Implements a custom session controller to change the way in which Decision
Center reacts to this action. For example, perform a custom check on
rulesetArchive and add errors to
generationErrors.
rulesetArchive - The ruleset archive that has been generated.baseline - The baseline from which the execution artifacts were
extracted.ruleArtifactquery - The query used to get the rule artifacts to be
extracted. This parameter can be set to null.extractorValidator - The extractor validator used to filter out the
artifacts to be extracted.generationErrors - A list of IlrElementError objects.IlrElementError,
IlrDeploymentFacility.generateRulesetArchive(IlrSearchCriteria, String, String),
OverviewIlrSearchCriteria redefineSearch(IlrSearchCriteria searchCriteria)
A typical use is to modify the search according to the role of the user. For example, you could redefine a search such that the current user can only view the rules with the status 'new'. In this case, you will return a new search criterion that will add (status, 'new') to the list of features and values of the input search criteria.
Note: Do not modify and return searchCriteria.
You must do one of the following:
searchCriteria unchangedIlrSearchCriteria instance with extra
criteria
searchCriteria - The search criteria passed when one of the
IlrSession.findElements methods is called.IlrSearchCriteria instance with
overridden criteria, or searchCriteria.boolean isServerVisible(IlrServer server, IlrRuleApp ruleApp)
Implements a custom session controller to filter the displayed servers.
server - The server to manage.ruleApp - The RuleApp to deploy.boolean isServerVisible(IlrServer server, IlrScenarioSuite suite)
Implements a custom session controller to filter the displayed servers.
server - The server to manage.suite - The test suite.void securityProfileCommitted(java.lang.String role,
IlrSecurityProfileData profile)
role have been committed.role - The role on which the permissions have changed.profile - The permissions that have been committed.void securityProfileDeleted(java.lang.String role)
role have been deleted.role - The role on which the permissions have been deleted.IlrBusinessVersion getNextVersion(boolean isNew, boolean isNewInBranch, IlrBusinessVersion previousVersion)
isNew - true if this is a new element to createisNewInBranch - true if the element is updated for the first time in working branchpreviousVersion - latest element version in working branch hierarchy, null if this is a new element© Copyright IBM Corp. 1987, 2017