* in-case for the entity and resource is the right available
*/
public boolean isRightPermitted(BaseRight right, IPermissionEntity entity, IPermisibleResource resource) {
validateNullEntries(permissionStore);
IPermisibleResource parentResource = resource;
IPermissionEntity parentEntity = entity;
List<Permission> rights = permissionStore.getRights(parentEntity, parentResource);
while (parentResource != null) {
if (isRightPresent(rights, right)) {// means this entity is assigned
// the right
return isRightAllowedByPriority(right, rights);
} else {
while (parentEntity != null) {
if (isRightPresent(rights, right)) {
// means this entity is assigned the right
return isRightAllowedByPriority(right, rights);
}
// increase the parent entity
parentEntity = parentEntity.getParent();
rights = permissionStore.getRights(parentEntity, parentResource);
}
}
/*
* if parent is present and the parent type is not as sane as
* currentResourceType then just ignore the parent
*/
if (parentResource.getParent() != null &&
parentResource.getResourceTypeID() != parentResource.getParent().getResourceTypeID()) {
break;
}
parentResource = parentResource.getParent();
rights = permissionStore.getRights(parentEntity, parentResource);
}
// when nothing is found this is simple can be taken up
return right.getDefaultIsAllowed();
}