Wrap handler elements
The <WrapHandler> element in security-config.xml defines complex security permissions on an entity. The wrap handler “wraps around” the permission conditions of the associated handler. The associated handler type must not be object-based, meaning that it must be one of the following:
<StaticHandler><WrapHandler>
It is not possible to create a security handler that takes an object using a <WrapHandler> element. A wrap security handler always create a new static handler.
There is no limit to the number of <WrapHandler> elements that can exist in security-config.xml. Each <WrapHandler> element can contain zero to many <SystemPermType> elements.
A <WrapHandler> element must come after the <Handler> element that defines the permission referenced by wrapPermKey. The associated handler can be another <WrapHandler>. It is possible to cascade <WrapHandler> elements.
This element has the following syntax.
<WrapHandler entity="entity" permKey="perm" wrapPermKey="wrapPerm" desc="..." noPermissionDisplayKey="key">
<SystemPermType code="code"/>
...
</WrapHandler>
You access this permission in code as perm.entity.perm. This syntax has the following meaning:
- entity – The business object or entity on which the permission acts.
- perm – The permission given for this entity.
The attributes on the various elements have the following meanings.
Element |
Attribute |
Required |
Description |
|---|---|---|---|
|
|
Yes |
The entity type on which this security handler acts. |
|
Yes |
The application permission to grant. |
|
|
Yes |
The associated permission being wrapped. You must
declare the permission referenced by the |
|
|
No |
A human-readable description of the permission. |
|
|
No |
A display key that provides the text to show if the user does not have a required permission. |
|
|
|
Yes |
A |
The following example illustrates a <StaticHandler> element with two cascading <WrapHandler> elements
following it.
// Static Handler - ViewProfiler permission
<StaticHandler entity="User" permKey="ViewProfiler" noPermissionDisplayKey="No access to ViewProfiler.">
<SystemPermType code="internaltools"/>
<SystemPermType code="toolsProfilerview"/>
</StaticHandler>
//First Wrap Handler - EditProfiler permission
<WrapHandler entity="User" permKey="EditProfiler" wrapPermKey="ViewProfiler" noPermissionDisplayKey="No access to EditProfiler.">
<SystemPermType code="internaltools"/>
<SystemPermType code="toolsProfileredit"/>
</WrapHandler>
//Second Wrap Handler - EditWebserviceProfiler permission
<WrapHandler entity="User" permKey="EditWebserviceProfiler" wrapPermKey="EditProfiler" noPermissionDisplayKey="No access to EditWebServiceProfiler.">
<SystemPermType code="toolsProfilerwebserviceedit"/>
</WrapHandler>
This sequence of handlers does the following:
- The first wrap handler verifies that the user meets the security criteria defined in the handler
specified by its
wrapPermKeyattribute (ViewProfiler). If the user has an assigned role that contains any of the system permissions specified by theViewProfilerhandler, the handler permits the user to have theEditProfilerapplication permission. If the user does not have such a role, she receives an error message. - The second wrap handler checks to see that the user meets the security criteria defined in the
handler specified by its
wrapPermKeyattribute (EditProfiler). If the user has an assigned role that contains thetoolsProfilerwebserviceeditpermission, the handler permits the user to have theEditWebserviceProfilerapplication permission. If the user does not have such a role, she receives an error message.
Wrap handlers specify AND conditions
Wrap security handlers define Boolean AND conditions. Using the example shown previously, the sequence of
security handlers evaluates the following set of conditions:
(perm.System.internaltools OR perm.System.toolsProfilerview)
AND (perm.System.internaltools OR perm.System.toolsProfilerEdit)
AND (permission.System.toolsProfilerwebserivceedit)
For this compound condition to evaluate to true, all of the following conditions must be true:
- The user must have a role that contains either the
interntoolsortoolsProfilerviewsystem permission as specified inViewProfilerstatic handler. - The user must have a role that contains either the
interntoolsortoolsProfilereditsystem permission as specified in theEditProfilerwrap handler. - The user must have a role that contains the
toolsProfilerwebserviceseditsystem permission as specified in theEditWebServiceProfilerwrap handler.
Only if the user meets all sets of security criteria does the security handler permit the user to have the specified
application permission (EditwebserviceProfiler).
See also
