In JasperReports Server 6.0, we added support for hierarchical attributes, which extend attribute functionality. For security files, we added a new service, attributesService, that supports hierarchical attributes and usually has better performance. This section describes how to update your security file to use attributesService.
With hierarchical attributes, a user can inherit attributes from their organization or the server in addition to any attributes assigned to the user directly. When providing an attribute, you can either specify the category (user, organization, or server) in which the server should look for its value, or allow the server to locate the value hierarchically.
To update an existing Domain security file:
• | Update principal expressions to use attributesService. However, attributesService does not support information that is stored in the Spring principal object, such as user roles. |
• | To retrieve information from the principal object, as in the case of roles, use a getter instead of accessing the attribute directly. For example, use authentication.getPrincipal.getRoles, not authentication.principal.roles. |
You must update any security file that uses the deprecated authentication.principal.attributes syntax. This syntax no longer works. |
Updating to attributesService:
For example, suppose you have the following resource access grant, which does not support hierarchical attributes:
authentication.principal.attributes.any{ it.attrName in ['AccessLevel'] ? it.attrValue.equals('Manager') : false } testProfileAttribute(region11.sales_city,'Cities')[/code] |
You can update the principal expression as shown below:
attributesService.getAttribute('AccessLevel', null)?.getAttrValue().equals('Manager') testProfileAttribute(region11.sales_city,'Cities')[/code] |
As part of the changes, the function testProfileAttribute was updated to work with hierarchical attributes by default. If you wish to compare an attribute's value that is defined specifically at the user level, you can specify the level as follows:
testProfileAttribute(region11.sales_city,'Cities','USER')[/code] |
For more information, see The testProfileAttribute Function.
Recommended Comments
There are no comments to display.