Class DefaultAuthorizationProvider
- java.lang.Object
-
- org.camunda.bpm.engine.impl.cfg.auth.DefaultAuthorizationProvider
-
- All Implemented Interfaces:
ResourceAuthorizationProvider
public class DefaultAuthorizationProvider extends java.lang.Object implements ResourceAuthorizationProvider
Provides the default authorizations for Camunda Platform.
- Author:
- Daniel Meyer
-
-
Constructor Summary
Constructors Constructor Description DefaultAuthorizationProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddPermissions(AuthorizationEntity authorization, Permission... permissions)protected booleanareIdsEqual(java.lang.String firstId, java.lang.String secondId)protected AuthorizationEntitycreateAuthorization(java.lang.String userId, java.lang.String groupId, Resource resource, java.lang.String resourceId, Permission... permissions)protected AuthorizationEntitycreateGrantAuthorization(java.lang.String userId, java.lang.String groupId, Resource resource, java.lang.String resourceId, Permission... permissions)protected AuthorizationEntitycreateOrUpdateAuthorization(Task task, java.lang.String userId, java.lang.String groupId, Resource resource, boolean isHistoric, Permission... permissions)protected AuthorizationEntity[]createOrUpdateAuthorizations(Task task, java.lang.String groupId, java.lang.String userId)(1) Fetch existing runtime & history authorizations (2) Update authorizations: (2a) fetched authorization == null -> create a new runtime authorization (with READ, (UPDATE/TASK_WORK) permission, and READ_VARIABLE if enabled) -> create a new history authorization (with READ on HISTORIC_TASK) (2b) fetched authorization != null -> Add READ, (UPDATE/TASK_WORK) permission, and READ_VARIABLE if enabled UPDATE or TASK_WORK permission is configurable in camunda.cfg.xml and by default, UPDATE permission is provided -> Add READ on HISTORIC_TASKprotected AuthorizationEntity[]createOrUpdateAuthorizationsByGroupId(Task task, java.lang.String groupId)protected AuthorizationEntity[]createOrUpdateAuthorizationsByUserId(Task task, java.lang.String userId)AuthorizationEntity[]deleteTaskGroupIdentityLink(Task task, java.lang.String groupId, java.lang.String type)Invoked whenever a group identity link of a task has been deleted.AuthorizationEntity[]deleteTaskUserIdentityLink(Task task, java.lang.String userId, java.lang.String type)Invoked whenever a user identity link of a task has been deleted.protected HistoryEventfindHistoricProcessInstance(java.lang.String rootProcessInstanceId)protected AuthorizationManagergetAuthorizationManager()protected PermissiongetDefaultUserPermissionForTask()protected AuthorizationEntitygetGrantAuthorization(java.lang.String taskId, java.lang.String userId, java.lang.String groupId, Resource resource)protected AuthorizationEntitygetGrantAuthorizationByGroupId(java.lang.String groupId, Resource resource, java.lang.String resourceId)protected AuthorizationEntitygetGrantAuthorizationByUserId(java.lang.String userId, Resource resource, java.lang.String resourceId)protected Permission[]getHistoricPermissions(boolean enforceSpecificVariablePermission)protected java.lang.StringgetHistoryRemovalTimeStrategy()protected java.lang.StringgetRootProcessInstanceId(Task task)protected Permission[]getRuntimePermissions(boolean enforceSpecificVariablePermission)AuthorizationEntity[]groupMembershipCreated(java.lang.String groupId, java.lang.String userId)Invoked whenever a user is added to a groupprotected booleanhasEntitySameAuthorizationRights(AuthorizationEntity authEntity, java.lang.String userId, java.lang.String groupId, Resource resource, java.lang.String resourceId)protected booleanisEnforceSpecificVariablePermission()protected booleanisHistoricInstancePermissionsEnabled()protected booleanisHistoryRemovalTimeStrategyStart()AuthorizationEntity[]newDecisionDefinition(DecisionDefinition decisionDefinition)Invoked whenever a new decision definition is created.AuthorizationEntity[]newDecisionRequirementsDefinition(DecisionRequirementsDefinition decisionRequirementsDefinition)Invoked whenever a new decision requirements definition is created.AuthorizationEntity[]newDeployment(Deployment deployment)Invoked whenever a new deployment is createdAuthorizationEntity[]newFilter(Filter filter)Invoked whenever a new filter is createdAuthorizationEntity[]newGroup(Group group)Invoked whenever a new group is createdAuthorizationEntity[]newProcessDefinition(ProcessDefinition processDefinition)Invoked whenever a new process definition is createdAuthorizationEntity[]newProcessInstance(ProcessInstance processInstance)Invoked whenever a new process instance is startedAuthorizationEntity[]newTask(Task task)Invoked whenever a new task is createdAuthorizationEntity[]newTaskAssignee(Task task, java.lang.String oldAssignee, java.lang.String newAssignee)Invoked whenever an user has been assigned to a task.AuthorizationEntity[]newTaskGroupIdentityLink(Task task, java.lang.String groupId, java.lang.String type)Invoked whenever a new group identity link has been added to a task.AuthorizationEntity[]newTaskOwner(Task task, java.lang.String oldOwner, java.lang.String newOwner)Invoked whenever an user has been set as the owner of a task.AuthorizationEntity[]newTaskUserIdentityLink(Task task, java.lang.String userId, java.lang.String type)Invoked whenever a new user identity link has been added to a task.AuthorizationEntity[]newTenant(Tenant tenant)Invoked whenever a new tenant is createdAuthorizationEntity[]newUser(User user)Invoked whenever a new user is createdprotected voidprovideRemovalTime(AuthorizationEntity authorization, Task task)AuthorizationEntity[]tenantMembershipCreated(Tenant tenant, Group group)Invoked whenever a group is added to a tenant.AuthorizationEntity[]tenantMembershipCreated(Tenant tenant, User user)Invoked whenever an user is added to a tenant.protected voidupdateAuthorizationBasedOnCacheEntries(AuthorizationEntity authorization, java.lang.String userId, java.lang.String groupId, Resource resource, java.lang.String resourceId)Searches through the cache, if there is already an authorization with same rights.
-
-
-
Method Detail
-
newUser
public AuthorizationEntity[] newUser(User user)
Description copied from interface:ResourceAuthorizationProviderInvoked whenever a new user is created
- Specified by:
newUserin interfaceResourceAuthorizationProvider- Parameters:
user- a newly created user- Returns:
- a list of authorizations to be automatically added when a new user is created.
-
newGroup
public AuthorizationEntity[] newGroup(Group group)
Description copied from interface:ResourceAuthorizationProviderInvoked whenever a new group is created
- Specified by:
newGroupin interfaceResourceAuthorizationProvider- Parameters:
group- a newly createdGroup- Returns:
- a list of authorizations to be automatically added when a new
Groupis created.
-
newTenant
public AuthorizationEntity[] newTenant(Tenant tenant)
Description copied from interface:ResourceAuthorizationProviderInvoked whenever a new tenant is created
- Specified by:
newTenantin interfaceResourceAuthorizationProvider- Parameters:
tenant- a newly createdTenant- Returns:
- a list of authorizations to be automatically added when a new
Tenantis created.
-
groupMembershipCreated
public AuthorizationEntity[] groupMembershipCreated(java.lang.String groupId, java.lang.String userId)
Description copied from interface:ResourceAuthorizationProviderInvoked whenever a user is added to a group
- Specified by:
groupMembershipCreatedin interfaceResourceAuthorizationProvider- Parameters:
groupId- the id of the group to which the user is addeduserId- the id of the user who is added to a group a newly createdUser- Returns:
- a list of authorizations to be automatically added when a new
Useris created.
-
tenantMembershipCreated
public AuthorizationEntity[] tenantMembershipCreated(Tenant tenant, User user)
Description copied from interface:ResourceAuthorizationProviderInvoked whenever an user is added to a tenant.
- Specified by:
tenantMembershipCreatedin interfaceResourceAuthorizationProvider- Parameters:
tenant- the id of the tenant- Returns:
- a list of authorizations to be automatically added when a new membership is created.
-
tenantMembershipCreated
public AuthorizationEntity[] tenantMembershipCreated(Tenant tenant, Group group)
Description copied from interface:ResourceAuthorizationProviderInvoked whenever a group is added to a tenant.
- Specified by:
tenantMembershipCreatedin interfaceResourceAuthorizationProvider- Parameters:
tenant- the id of the tenant- Returns:
- a list of authorizations to be automatically added when a new membership is created.
-
newFilter
public AuthorizationEntity[] newFilter(Filter filter)
Description copied from interface:ResourceAuthorizationProviderInvoked whenever a new filter is created
- Specified by:
newFilterin interfaceResourceAuthorizationProvider- Parameters:
filter- the newly created filter- Returns:
- a list of authorizations to be automatically added when a new
Filteris created.
-
newDeployment
public AuthorizationEntity[] newDeployment(Deployment deployment)
Description copied from interface:ResourceAuthorizationProviderInvoked whenever a new deployment is created
- Specified by:
newDeploymentin interfaceResourceAuthorizationProvider- Parameters:
deployment- the newly created deployment- Returns:
- a list of authorizations to be automatically added when a new
Deploymentis created.
-
newProcessDefinition
public AuthorizationEntity[] newProcessDefinition(ProcessDefinition processDefinition)
Description copied from interface:ResourceAuthorizationProviderInvoked whenever a new process definition is created
- Specified by:
newProcessDefinitionin interfaceResourceAuthorizationProvider- Parameters:
processDefinition- the newly created process definition- Returns:
- a list of authorizations to be automatically added when a new
ProcessDefinitionis created.
-
newProcessInstance
public AuthorizationEntity[] newProcessInstance(ProcessInstance processInstance)
Description copied from interface:ResourceAuthorizationProviderInvoked whenever a new process instance is started
- Specified by:
newProcessInstancein interfaceResourceAuthorizationProvider- Parameters:
processInstance- the newly started process instance- Returns:
- a list of authorizations to be automatically added when a new
ProcessInstanceis started.
-
newTask
public AuthorizationEntity[] newTask(Task task)
Description copied from interface:ResourceAuthorizationProviderInvoked whenever a new task is created
- Specified by:
newTaskin interfaceResourceAuthorizationProvider- Parameters:
task- the newly created task- Returns:
- a list of authorizations to be automatically added when a new
Taskis created.
-
newTaskAssignee
public AuthorizationEntity[] newTaskAssignee(Task task, java.lang.String oldAssignee, java.lang.String newAssignee)
Description copied from interface:ResourceAuthorizationProviderInvoked whenever an user has been assigned to a task.
- Specified by:
newTaskAssigneein interfaceResourceAuthorizationProvider- Parameters:
task- the task on which the assignee has been changedoldAssignee- the old assignee of the tasknewAssignee- the new assignee of the task- Returns:
- a list of authorizations to be automatically added when an assignee of a task changes.
-
newTaskOwner
public AuthorizationEntity[] newTaskOwner(Task task, java.lang.String oldOwner, java.lang.String newOwner)
Description copied from interface:ResourceAuthorizationProviderInvoked whenever an user has been set as the owner of a task.
- Specified by:
newTaskOwnerin interfaceResourceAuthorizationProvider- Parameters:
task- the task on which the owner has been changedoldOwner- the old owner of the tasknewOwner- the new owner of the task- Returns:
- a list of authorizations to be automatically added when the owner of a task changes.
-
newTaskUserIdentityLink
public AuthorizationEntity[] newTaskUserIdentityLink(Task task, java.lang.String userId, java.lang.String type)
Description copied from interface:ResourceAuthorizationProviderInvoked whenever a new user identity link has been added to a task.
- Specified by:
newTaskUserIdentityLinkin interfaceResourceAuthorizationProvider- Parameters:
task- the task on which a new identity link has been addeduserId- the user for which the identity link has been createdtype- the type of the identity link (e.g.IdentityLinkType.CANDIDATE)- Returns:
- a list of authorizations to be automatically added when a new user identity link has been added.
-
newTaskGroupIdentityLink
public AuthorizationEntity[] newTaskGroupIdentityLink(Task task, java.lang.String groupId, java.lang.String type)
Description copied from interface:ResourceAuthorizationProviderInvoked whenever a new group identity link has been added to a task.
- Specified by:
newTaskGroupIdentityLinkin interfaceResourceAuthorizationProvider- Parameters:
task- the task on which a new identity link has been addedgroupId- the group for which the identity link has been createdtype- the type of the identity link (e.g.IdentityLinkType.CANDIDATE)- Returns:
- a list of authorizations to be automatically added when a new group identity link has been added.
-
deleteTaskUserIdentityLink
public AuthorizationEntity[] deleteTaskUserIdentityLink(Task task, java.lang.String userId, java.lang.String type)
Description copied from interface:ResourceAuthorizationProviderInvoked whenever a user identity link of a task has been deleted.
- Specified by:
deleteTaskUserIdentityLinkin interfaceResourceAuthorizationProvider- Parameters:
task- the task on which the identity link has been deleteduserId- the user for which the identity link has been deletedtype- the type of the identity link (e.g.IdentityLinkType.CANDIDATE)- Returns:
- a list of authorizations to be automatically deleted when a user identity link has been deleted.
-
deleteTaskGroupIdentityLink
public AuthorizationEntity[] deleteTaskGroupIdentityLink(Task task, java.lang.String groupId, java.lang.String type)
Description copied from interface:ResourceAuthorizationProviderInvoked whenever a group identity link of a task has been deleted.
- Specified by:
deleteTaskGroupIdentityLinkin interfaceResourceAuthorizationProvider- Parameters:
task- the task on which the identity link has been deletedgroupId- the group for which the identity link has been deletedtype- the type of the identity link (e.g.IdentityLinkType.CANDIDATE)- Returns:
- a list of authorizations to be automatically deleted when a group identity link has been deleted.
-
newDecisionDefinition
public AuthorizationEntity[] newDecisionDefinition(DecisionDefinition decisionDefinition)
Description copied from interface:ResourceAuthorizationProviderInvoked whenever a new decision definition is created.
- Specified by:
newDecisionDefinitionin interfaceResourceAuthorizationProvider- Parameters:
decisionDefinition- the newly created decision definition- Returns:
- a list of authorizations to be automatically added when a new
DecisionDefinitionis created.
-
newDecisionRequirementsDefinition
public AuthorizationEntity[] newDecisionRequirementsDefinition(DecisionRequirementsDefinition decisionRequirementsDefinition)
Description copied from interface:ResourceAuthorizationProviderInvoked whenever a new decision requirements definition is created.
- Specified by:
newDecisionRequirementsDefinitionin interfaceResourceAuthorizationProvider- Parameters:
decisionRequirementsDefinition- the newly created decision requirements definition- Returns:
- a list of authorizations to be automatically added when a new
DecisionRequirementsDefinitionis created.
-
createOrUpdateAuthorizationsByGroupId
protected AuthorizationEntity[] createOrUpdateAuthorizationsByGroupId(Task task, java.lang.String groupId)
-
createOrUpdateAuthorizationsByUserId
protected AuthorizationEntity[] createOrUpdateAuthorizationsByUserId(Task task, java.lang.String userId)
-
createOrUpdateAuthorizations
protected AuthorizationEntity[] createOrUpdateAuthorizations(Task task, java.lang.String groupId, java.lang.String userId)
(1) Fetch existing runtime & history authorizations (2) Update authorizations: (2a) fetched authorization == null -> create a new runtime authorization (with READ, (UPDATE/TASK_WORK) permission, and READ_VARIABLE if enabled) -> create a new history authorization (with READ on HISTORIC_TASK) (2b) fetched authorization != null -> Add READ, (UPDATE/TASK_WORK) permission, and READ_VARIABLE if enabled UPDATE or TASK_WORK permission is configurable in camunda.cfg.xml and by default, UPDATE permission is provided -> Add READ on HISTORIC_TASK
-
createOrUpdateAuthorization
protected AuthorizationEntity createOrUpdateAuthorization(Task task, java.lang.String userId, java.lang.String groupId, Resource resource, boolean isHistoric, Permission... permissions)
-
provideRemovalTime
protected void provideRemovalTime(AuthorizationEntity authorization, Task task)
-
getRootProcessInstanceId
protected java.lang.String getRootProcessInstanceId(Task task)
-
isHistoryRemovalTimeStrategyStart
protected boolean isHistoryRemovalTimeStrategyStart()
-
getHistoryRemovalTimeStrategy
protected java.lang.String getHistoryRemovalTimeStrategy()
-
findHistoricProcessInstance
protected HistoryEvent findHistoricProcessInstance(java.lang.String rootProcessInstanceId)
-
getHistoricPermissions
protected Permission[] getHistoricPermissions(boolean enforceSpecificVariablePermission)
-
getRuntimePermissions
protected Permission[] getRuntimePermissions(boolean enforceSpecificVariablePermission)
-
isHistoricInstancePermissionsEnabled
protected boolean isHistoricInstancePermissionsEnabled()
-
getAuthorizationManager
protected AuthorizationManager getAuthorizationManager()
-
getGrantAuthorization
protected AuthorizationEntity getGrantAuthorization(java.lang.String taskId, java.lang.String userId, java.lang.String groupId, Resource resource)
-
getGrantAuthorizationByUserId
protected AuthorizationEntity getGrantAuthorizationByUserId(java.lang.String userId, Resource resource, java.lang.String resourceId)
-
getGrantAuthorizationByGroupId
protected AuthorizationEntity getGrantAuthorizationByGroupId(java.lang.String groupId, Resource resource, java.lang.String resourceId)
-
createAuthorization
protected AuthorizationEntity createAuthorization(java.lang.String userId, java.lang.String groupId, Resource resource, java.lang.String resourceId, Permission... permissions)
-
addPermissions
protected void addPermissions(AuthorizationEntity authorization, Permission... permissions)
-
createGrantAuthorization
protected AuthorizationEntity createGrantAuthorization(java.lang.String userId, java.lang.String groupId, Resource resource, java.lang.String resourceId, Permission... permissions)
-
getDefaultUserPermissionForTask
protected Permission getDefaultUserPermissionForTask()
-
isEnforceSpecificVariablePermission
protected boolean isEnforceSpecificVariablePermission()
-
updateAuthorizationBasedOnCacheEntries
protected void updateAuthorizationBasedOnCacheEntries(AuthorizationEntity authorization, java.lang.String userId, java.lang.String groupId, Resource resource, java.lang.String resourceId)
Searches through the cache, if there is already an authorization with same rights. If that's the case update the given authorization with the permissions and remove the old one from the cache.
-
hasEntitySameAuthorizationRights
protected boolean hasEntitySameAuthorizationRights(AuthorizationEntity authEntity, java.lang.String userId, java.lang.String groupId, Resource resource, java.lang.String resourceId)
-
areIdsEqual
protected boolean areIdsEqual(java.lang.String firstId, java.lang.String secondId)
-
-