Protecting controller commands

All controller commands require a role-based access control policy in order to be executed. A controller or task command also requires a resource-level policy if the command is doing resource-level checking.

About this task

For more information see Protecting resources. The following example displays a role-based policy for controller commands:


<Policy Name="SellersExecuteSellersCmdResourceGroup"
        OwnerID="RootOrganization"
        UserGroup="Sellers"
        ActionGroupName="ExecuteCommandActionGroup"
        ResourceGroupName="SellersCmdResourceGroup"
        PolicyType="groupableStandard">
</Policy>

The ActionGroupName, ExecuteCommandActionGroup, indicates that this is a role-based policy for controller commands. The policy states that users in the Sellers access group can execute the commands in the SellersCmdResourceGroup, resource group.

The following is an example of the SellersCmdResourceGroup resource group definition:


<ResourceGroup Name="SellersCmdResourceGroup"
OwnerID="RootOrganization">
        <ResourceGroupResource
Name="com.ibm.contract.commands.ContractCancelCmdResourceCategory"/>
        <ResourceGroupResource
Name="com.ibm.contract.commands.ContractCloseCmdResourceCategory"/>
        <ResourceGroupResource
Name="com.ibm.contract.commands.ContractCreateCmdResourceCategory"/>
</ResourceGroup>

The preceding example shows the following three resources in the resource group, that each correspond to a controller command:

  • com.ibm.contract.commands.ContractCancelCmdResourceCategory
  • com.ibm.contract.commands.ContractCloseCmdResourceCategory
  • com.ibm.contract.commands.ContractCreateCmdResourceCategory

The following is a sample definition of a resource:


<ResourceCategory
Name="com.ibm.commerce.contract.commands.ContractCloseCmdResourceCategory"

       
ResourceBeanClass="com.ibm.commerce.contract.commands.ContractCloseCmd">

        <ResourceAction Name="ExecuteCommand"/>
</ResourceCategory>

The Name attribute, com.ibm.commerce.contract.commands.ContractCloseCmdResourceCategory, is used as a tag to refer to the resource in the XML file. The ResourceAction Name, ExecuteCommand, is used to specify the actions that can operate on the resource. This information is used in the Administration console when using access control policies to populate the Action selection box that corresponds to a particular resource. In this case, the action Execute is specified. The Execute action is defined in the following:


<Action Name="ExcecuteCommand CommandName="Execute">
</Action>
Note: The interface name of the controller command must match the ResourceBeanClass in the resource definition. The value of the ResourceBeanClass is stored in the RESCLASSNAME column of the ACRESCGRY table. These commands can be used as resources because they extend the ControllerCommand interface, which extends the AccCommand interface, which in turn extends the Protectable interface.