Access control in the BOD command framework

As in previous versions of WebSphere Commerce, access control checks in the BOD command framework are performed just before the business logic is executed. This framework continues to use the WebSphere Commerce PolicyManager as its default access control engine. Access control policies are still required to grant users access to commands and resources. However, the action and resource naming convention is different for the BOD command framework.

Resources that the BOD commands act upon are nouns are represented by generated Java objects. These generated Java objects do not implement the Protectable interface required by the PolicyManager. To address this requirement, a wrapper object must be implemented for each noun to extract the information required by the PolicyManager to perform authorization checks. This mapping is defined in the wc-component.xml file. For SOI name-value pair commands, before they run, a command level and a resource level authorization is performed. In the BOD command framework, only resource level access control checks are performed, except for Get requests, where Get performs an access control check on whether the request is allowed to use the specified access profile. The access profile indicates the view of the data and certain views can be limited to certain types of users. This is sufficient to check whether a user can run the command against a particular resource.

There are two assets that need to be implemented for access control for a BOD command:


Protectable proxy class

When the PolicyManager invokes the methods on the Protectable wrapper object, the Protectable object uses the noun to retrieve information to return the appropriate response. Although some information might be available in the noun, such as owner, the command cannot assume this information is correct. This assumption allows the access control check to pass even though it could be invalid. It is the Protectable wrapper object that understands the noun and how the information correlates to the authorization check.

This proxy class should extend from AbstractProtectableProxy class and implement the Protectable interface. The naming convention of the protectable wrapper object is as follows:

When the protectable proxy is instantiated, the noun and the associated command context is set. The noun can be retrieved by the getObject() method and the command context can be retrieved via the getCommandContext() method. There are two methods that must be implemented for each proxy class – fulfills(Long member, String relationship) and getOwner().

The fulfills() method is used to check if a given member has the specified relationship with the resource. For example, the creator of an order. If fulfills() is not explicitly implemented, it returns "false", as of 7.0.0.1. The getOwner() method is used to return the member owner of the resource. For example, the organization that owns the order. The owner should be retrieved from the database, or wherever it is stored. Most of the resources in WebSphere Commerce are owned by a store, and in this case, the value that is returned in this method is the organization that owns the store. If the getOwner() method is not explicitly implemented, the store owner organization is returned.

Note: The storeId should not be retrieved from the command context, because it can be changed by the client. The storeId is retrieved from the persistence layer, using the identifier of the noun. That is, since the owner of an object is typically the owner of the store that the object is in, it is not safe to take the store from the context and return the stores owner. The identifier of the object should be used to look up its owner from the database.

The protectable proxy object is registered as follows in the wc-component.xml file:


Access control policies for Get services

There are two types of access control for Get services:


Access control policies for Change and Sync services

The access control policies for Change and Sync services determine whether the current user under the current context can perform the change actions on the specified noun. The action is the actionCode in the action expression to perform. The resource is the protectable proxy object of the noun being operated on.


Access control policies for Process services

The access control policies for Process services determine whether the current user has permission to execute the action on the noun. The action is the action code found in the Process verb in the BOD. The resource is the protectable proxy object of the noun being operated on.