For developers: Decorators
Decorators are a way of sharing implementation across multiple data providers. Sitefinity CMS has a built-in decorator for OpenAccess. Unless you have a reason not to use OpenAccess, you won't have to worry about implementing the methods that are mentioned in this topic.
Information in this topic will be useful for provider implementors, as the decorator methods are usually implementing provider methods. This usually happens like this:
public
virtual
Permission CreatePermission(
string
permissionSet, Guid objectId, Guid principalId)
{
if
(
this
.providerDecorator !=
null
)
return
this
.providerDecorator.CreatePermission(permissionSet, objectId, principalId);
throw
new
MissingDecoratorException(
this
,
"CreatePermission<TPermission>(string permissionSet, Guid objectId, Guid principalId)"
);
}
CreatePermissionInheritanceAssociation
Executes permission inheritance between a parent and a child hierarchical secured objects. The algorithm is as follows:
- Check if the parent doesn't already have this child. If it is not, then add it to the child permissions of the parent.
bool
isChild =
!parent
.PermissionChildren
.Any(p => p.ObjectId == parent.Id &&
p.ChildObjectId == child.Id
);
- Copy the parent's permissions to the child. Have in mind that a child might already have a permission with the same permission set, object id and object id, so make sure you check against it.
public
virtual
void
CreatePermissionInheritanceAssociation(ISecuredObject parent, ISecuredObject child)
AddPermissionToObject
Adds a permission to a secured object, and handles inheritance throughout the tree. Implementation follows these steps:
- Retrieve the object in the context of the current transaction, add the permission and commit
- Fetch the manager in transaction again, and fetch the added permission in order to add it to the inheritors. Inheritors are got with GetPermissionsInheritors
- For every inheritor, get its manager (and in transaction if the item's provider - IDataItem.Provider - is of different type and name). Fetch the inheritor in the context of the current open transaction, and add the permission.
- Finally, commit the transaction.
public
virtual
void
AddPermissionToObject(ISecuredObject securedObject, Permission permission,
string
tranName)
public
virtual
void
AddPermissionToObject(ISecuredObject securedObject, IManager managerInstance, Permission permission,
string
tranName)
GetSecurityRoot
Get or create the security root. If security root is to be created, one can specify labeling information and/or supported permission sets.
public
SecurityRoot GetSecurityRoot()
public
SecurityRoot GetSecurityRoot(
bool
create)
public
SecurityRoot GetSecurityRoot(
bool
create, IDictionary<
string
,
string
> permissionsetObjectTitleResKeys,
params
string
[] permissionSets)
ConvertVoaClassToClrType
Every permission contains information about inheritance. Part of that information is the permission's child object type. If one wanted to shorten that name so that less information is stored in database, this would be the method that returns a CLR type from the shortened CLR type name string.
public
Type ConvertVoaClassToClrType(
string
voaClassName)
ConvertClrTypeVoaClass
Every permission contains information about inheritance. Part of that information is the permission's child object type. If one wanted to shorten that name so that less information is stored in database, this would be the method that creates a shortened type name using a CLR type.
public
string
ConvertClrTypeVoaClass(Type ClrType)