Authorization Example

This topic discusses the authorization example provided in the product under templates/security using,, and authz6_0.dtd.
Note: Disclaimer: The security samples serve only as example implementations. The implementation and its source code is provided on an “as-is�? basis, without warranties or conditions of any kind, either express or implied. You can modify these samples to suit your specific requirements and security providers. VMware takes no responsibility and accepts no liability for any damage to computer equipment, companies or personnel that might arise from the use of these samples.

XmlAuthorization provides authorization for each region at the operation level by using the permissions specified in an XML file. The sample implementation also shows the post-authorization implementation for the function execution operation. For pre-operation, all the required values are available.

You can configure authorization for all server region operations on a per-region and per-operation basis by using a role-based mechanism. A role can be provided with permissions to execute operations for each region. Each principal name can be associated with a set of roles.

Information such as the region reference, arguments, the operation being invoked, and a reference to the cache instance can be made available to the XmlAuthorization callback. If an authenticated client is not authorized to perform an operation, the operation fails with a NotAuthorizedException.

Server Settings

These are the file (or file if you are creating a special restricted access file for security configuration) settings for each server:
security-authz-xml-uri=<URI of XML file> 

XML File Sample Settings

The XmlAuthorization sample is configured through an XML file, which is described in the authz6_0.dtd in the security templates directory. See the dtd for documentation about the elements and attributes you use to configure XmlAuthorization. To run the example, create an XML file following the dtd specifications.

The user names you use should be the strings returned by the Principal.getName method of the Authenticator configured on the server

This topic lists an example XML file for the dtd. The example defines five roles:
  1. reader
  2. writer
  3. cacheOps
  4. queryRegions
  5. onRegionFunctionExecutor
The listing below is a sample XML file:
  • The permissions for each of the roles are described in the permission tags.
  • The reader, writer, and cacheOps roles have no regions mentioned, so they apply to all regions.
  • The queryRegions role has permissions on Portfolios and Positions regions.
  • The role of onRegionFunctionExecutor can only operate on regions secureRegion and Positions, and only with functions with ids SecureFunction or OptimizationFunction. On the functions, optimizeForWrite must be false and keySet must be KEY-0 and KEY-1.
"-//GemStone Systems, Inc.//GemFire XML Authorization 1.0//EN"
<role name="reader">
<role name="writer">
<role name="cacheOps">
<role name="queryRegions">
<role name="onRegionFunctionExecutor">
<permission role="cacheOps">
<permission role="reader">
<permission role="writer">
<permission role="queryRegions" regions="/Portfolios,Positions">
<permission role="onRegionFunctionExecutor" regions="secureRegion,Positions">
  <operation functionIds="SecureFunction,OptimizationFunction" 
    optimizeForWrite="false" keySet="KEY-0,KEY-1">EXECUTE_FUNCTION</operation>