org.camunda.bpm.engine.authorization.Authorization.getResourceType()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(15.2k)|赞(0)|评价(0)|浏览(130)

本文整理了Java中org.camunda.bpm.engine.authorization.Authorization.getResourceType()方法的一些代码示例,展示了Authorization.getResourceType()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Authorization.getResourceType()方法的具体详情如下:
包路径:org.camunda.bpm.engine.authorization.Authorization
类名称:Authorization
方法名:getResourceType

Authorization.getResourceType介绍

暂无

代码示例

代码示例来源:origin: camunda/camunda-bpm-platform

public static Authorization createMockGlobalAuthorization() {
 Authorization mockAuthorization = mock(Authorization.class);
 when(mockAuthorization.getId()).thenReturn(EXAMPLE_AUTHORIZATION_ID);
 when(mockAuthorization.getAuthorizationType()).thenReturn(Authorization.AUTH_TYPE_GLOBAL);
 when(mockAuthorization.getUserId()).thenReturn(Authorization.ANY);
 when(mockAuthorization.getResourceType()).thenReturn(EXAMPLE_RESOURCE_TYPE_ID);
 when(mockAuthorization.getResourceId()).thenReturn(EXAMPLE_RESOURCE_ID);
 when(mockAuthorization.getPermissions(Permissions.values())).thenReturn(EXAMPLE_GRANT_PERMISSION_VALUES);
 return mockAuthorization;
}

代码示例来源:origin: camunda/camunda-bpm-platform

public static Authorization createMockGrantAuthorization() {
 Authorization mockAuthorization = mock(Authorization.class);
 when(mockAuthorization.getId()).thenReturn(EXAMPLE_AUTHORIZATION_ID);
 when(mockAuthorization.getAuthorizationType()).thenReturn(Authorization.AUTH_TYPE_GRANT);
 when(mockAuthorization.getUserId()).thenReturn(EXAMPLE_USER_ID);
 when(mockAuthorization.getResourceType()).thenReturn(EXAMPLE_RESOURCE_TYPE_ID);
 when(mockAuthorization.getResourceId()).thenReturn(EXAMPLE_RESOURCE_ID);
 when(mockAuthorization.getPermissions(Permissions.values())).thenReturn(EXAMPLE_GRANT_PERMISSION_VALUES);
 return mockAuthorization;
}

代码示例来源:origin: camunda/camunda-bpm-platform

public static Authorization createMockRevokeAuthorization() {
 Authorization mockAuthorization = mock(Authorization.class);
 when(mockAuthorization.getId()).thenReturn(EXAMPLE_AUTHORIZATION_ID);
 when(mockAuthorization.getAuthorizationType()).thenReturn(Authorization.AUTH_TYPE_REVOKE);
 when(mockAuthorization.getUserId()).thenReturn(EXAMPLE_USER_ID);
 when(mockAuthorization.getResourceType()).thenReturn(EXAMPLE_RESOURCE_TYPE_ID);
 when(mockAuthorization.getResourceId()).thenReturn(EXAMPLE_RESOURCE_ID);
 when(mockAuthorization.getPermissions(Permissions.values())).thenReturn(EXAMPLE_REVOKE_PERMISSION_VALUES);
 return mockAuthorization;
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
  * @return the set of permission for the given authorization
  */
 public static Permission[] getPermissions(Authorization authorization)
 {
  int resourceType = authorization.getResourceType();
  if (resourceType == BATCH || resourceType == PROCESS_DEFINITION || resourceType == PROCESS_INSTANCE) {
   Permission[] permissionsForType = permissionMap.get(resourceType);
   return authorization.getPermissions(permissionsForType);
  } else {
   return authorization.getPermissions(Permissions.values());
  }
 }
}

代码示例来源:origin: camunda/camunda-bpm-platform

private static Permission[] getPermissions(Authorization dbAuthorization) {
 int givenResourceType = dbAuthorization.getResourceType();
 if (givenResourceType == Resources.BATCH.resourceType()) {
  return dbAuthorization.getPermissions(BatchPermissions.values());
 } else if (givenResourceType == Resources.PROCESS_DEFINITION.resourceType()) {
  return dbAuthorization.getPermissions(ProcessDefinitionPermissions.values());
 } else if (givenResourceType == Resources.PROCESS_INSTANCE.resourceType()) {
  return dbAuthorization.getPermissions(ProcessInstancePermissions.values());
 } else {
  return dbAuthorization.getPermissions(Permissions.values());
 }
}

代码示例来源:origin: camunda/camunda-bpm-platform

private static Permission[] getPermissions(Authorization dbAuthorization) {
 int givenResourceType = dbAuthorization.getResourceType();
 if (givenResourceType == Resources.BATCH.resourceType()) {
  return dbAuthorization.getPermissions(BatchPermissions.values());
 } else if (givenResourceType == Resources.PROCESS_DEFINITION.resourceType()) {
  return dbAuthorization.getPermissions(ProcessDefinitionPermissions.values());
 } else if (givenResourceType == Resources.PROCESS_INSTANCE.resourceType()) {
  return dbAuthorization.getPermissions(ProcessInstancePermissions.values());
 } else {
  return dbAuthorization.getPermissions(Permissions.values());
 }
}

代码示例来源:origin: camunda/camunda-bpm-platform

public static AuthorizationDto fromAuthorization(Authorization dbAuthorization) {
 AuthorizationDto authorizationDto = new AuthorizationDto();
 authorizationDto.setId(dbAuthorization.getId());
 authorizationDto.setType(dbAuthorization.getAuthorizationType());
 Permission[] dbPermissions = getPermissions(dbAuthorization);
 authorizationDto.setPermissions(PermissionConverter.getNamesForPermissions(dbAuthorization, dbPermissions));
 authorizationDto.setUserId(dbAuthorization.getUserId());
 authorizationDto.setGroupId(dbAuthorization.getGroupId());
 authorizationDto.setResourceType(dbAuthorization.getResourceType());
 authorizationDto.setResourceId(dbAuthorization.getResourceId());
 return authorizationDto;
}

代码示例来源:origin: camunda/camunda-bpm-platform

public static AuthorizationDto fromAuthorization(Authorization dbAuthorization) {
 AuthorizationDto authorizationDto = new AuthorizationDto();
 authorizationDto.setId(dbAuthorization.getId());
 authorizationDto.setType(dbAuthorization.getAuthorizationType());
 Permission[] dbPermissions = getPermissions(dbAuthorization);
 authorizationDto.setPermissions(PermissionConverter.getNamesForPermissions(dbAuthorization, dbPermissions));
 authorizationDto.setUserId(dbAuthorization.getUserId());
 authorizationDto.setGroupId(dbAuthorization.getGroupId());
 authorizationDto.setResourceType(dbAuthorization.getResourceType());
 authorizationDto.setResourceId(dbAuthorization.getResourceId());
 return authorizationDto;
}

代码示例来源:origin: camunda/camunda-bpm-platform

protected static MissingAuthorization asMissingAuthorization(Authorization authorization) {
 String permissionName = null;
 String resourceId = null;
 String resourceName = null;
 Permission[] permissions = AuthorizationTestUtil.getPermissions(authorization);
 for (Permission permission : permissions) {
  if (permission.getValue() != Permissions.NONE.getValue()) {
   permissionName = permission.getName();
   break;
  }
 }
 if (!Authorization.ANY.equals(authorization.getResourceId())) {
  // missing ANY authorizations are not explicitly represented in the error message
  resourceId = authorization.getResourceId();
 }
 Resource resource = AuthorizationTestUtil.getResourceByType(authorization.getResourceType());
 resourceName = resource.resourceName();
 return new MissingAuthorization(permissionName, resourceName, resourceId);
}

代码示例来源:origin: camunda/camunda-bpm-platform

public void testStandaloneTaskAddCandidateUserCreateNewAuthorization() {
 // given
 String taskId = "myTask";
 createTask(taskId);
 createGrantAuthorization(TASK, taskId, userId, UPDATE);
 // when
 taskService.addCandidateUser(taskId, "demo");
 // then
 disableAuthorization();
 Authorization authorization = authorizationService
   .createAuthorizationQuery()
   .userIdIn("demo")
   .singleResult();
 enableAuthorization();
 assertNotNull(authorization);
 assertEquals(TASK.resourceType(), authorization.getResourceType());
 assertEquals(taskId, authorization.getResourceId());
 assertTrue(authorization.isPermissionGranted(READ));
 assertTrue(authorization.isPermissionGranted(getDefaultTaskPermissionForUser()));
 deleteTask(taskId, true);
}

代码示例来源:origin: camunda/camunda-bpm-platform

public void testStandaloneTaskSetAssigneeCreateNewAuthorization() {
 // given
 String taskId = "myTask";
 createTask(taskId);
 createGrantAuthorization(TASK, taskId, userId, UPDATE);
 // when
 taskService.setAssignee(taskId, "demo");
 // then
 disableAuthorization();
 Authorization authorization = authorizationService
   .createAuthorizationQuery()
   .userIdIn("demo")
   .singleResult();
 enableAuthorization();
 assertNotNull(authorization);
 assertEquals(TASK.resourceType(), authorization.getResourceType());
 assertEquals(taskId, authorization.getResourceId());
 assertTrue(authorization.isPermissionGranted(READ));
 assertTrue(authorization.isPermissionGranted(getDefaultTaskPermissionForUser()));
 deleteTask(taskId, true);
}

代码示例来源:origin: camunda/camunda-bpm-platform

public void testStandaloneTaskSetOwnerCreateNewAuthorization() {
 // given
 String taskId = "myTask";
 createTask(taskId);
 createGrantAuthorization(TASK, taskId, userId, UPDATE);
 // when
 taskService.setOwner(taskId, "demo");
 // then
 disableAuthorization();
 Authorization authorization = authorizationService
   .createAuthorizationQuery()
   .userIdIn("demo")
   .singleResult();
 enableAuthorization();
 assertNotNull(authorization);
 assertEquals(TASK.resourceType(), authorization.getResourceType());
 assertEquals(taskId, authorization.getResourceId());
 assertTrue(authorization.isPermissionGranted(READ));
 assertTrue(authorization.isPermissionGranted(getDefaultTaskPermissionForUser()));
 deleteTask(taskId, true);
}

代码示例来源:origin: camunda/camunda-bpm-platform

public void testStandaloneTaskAddCandidateGroupCreateNewAuthorization() {
 // given
 String taskId = "myTask";
 createTask(taskId);
 createGrantAuthorization(TASK, taskId, userId, UPDATE);
 // when
 taskService.addCandidateGroup(taskId, "management");
 // then
 disableAuthorization();
 Authorization authorization = authorizationService
   .createAuthorizationQuery()
   .groupIdIn("management")
   .singleResult();
 enableAuthorization();
 assertNotNull(authorization);
 assertEquals(TASK.resourceType(), authorization.getResourceType());
 assertEquals(taskId, authorization.getResourceId());
 assertTrue(authorization.isPermissionGranted(READ));
 assertTrue(authorization.isPermissionGranted(getDefaultTaskPermissionForUser()));
 deleteTask(taskId, true);
}

代码示例来源:origin: camunda/camunda-bpm-platform

public void testProcessTaskSetOwnerCreateNewAuthorization() {
 // given
 startProcessInstanceByKey(PROCESS_KEY);
 String taskId = selectSingleTask().getId();
 createGrantAuthorization(TASK, taskId, userId, UPDATE);
 // when
 taskService.setOwner(taskId, "demo");
 // then
 disableAuthorization();
 Authorization authorization = authorizationService
   .createAuthorizationQuery()
   .userIdIn("demo")
   .singleResult();
 enableAuthorization();
 assertNotNull(authorization);
 assertEquals(TASK.resourceType(), authorization.getResourceType());
 assertEquals(taskId, authorization.getResourceId());
 assertTrue(authorization.isPermissionGranted(READ));
 assertTrue(authorization.isPermissionGranted(getDefaultTaskPermissionForUser()));
}

代码示例来源:origin: camunda/camunda-bpm-platform

public void testProcessTaskSetAssigneeCreateNewAuthorization() {
 // given
 startProcessInstanceByKey(PROCESS_KEY);
 String taskId = selectSingleTask().getId();
 createGrantAuthorization(TASK, taskId, userId, UPDATE);
 // when
 taskService.setAssignee(taskId, "demo");
 // then
 disableAuthorization();
 Authorization authorization = authorizationService
   .createAuthorizationQuery()
   .userIdIn("demo")
   .singleResult();
 enableAuthorization();
 assertNotNull(authorization);
 assertEquals(TASK.resourceType(), authorization.getResourceType());
 assertEquals(taskId, authorization.getResourceId());
 assertTrue(authorization.isPermissionGranted(READ));
 assertTrue(authorization.isPermissionGranted(getDefaultTaskPermissionForUser()));
}

代码示例来源:origin: camunda/camunda-bpm-platform

public void testStandaloneTaskAddCandidateUserUpdateAuthorization() {
 // given
 String taskId = "myTask";
 createTask(taskId);
 createGrantAuthorization(TASK, taskId, userId, UPDATE);
 createGrantAuthorization(TASK, taskId, "demo", DELETE);
 // when
 taskService.addCandidateUser(taskId, "demo");
 // then
 disableAuthorization();
 Authorization authorization = authorizationService
   .createAuthorizationQuery()
   .userIdIn("demo")
   .singleResult();
 enableAuthorization();
 assertNotNull(authorization);
 assertEquals(TASK.resourceType(), authorization.getResourceType());
 assertEquals(taskId, authorization.getResourceId());
 assertTrue(authorization.isPermissionGranted(READ));
 assertTrue(authorization.isPermissionGranted(getDefaultTaskPermissionForUser()));
 deleteTask(taskId, true);
}

代码示例来源:origin: camunda/camunda-bpm-platform

public void testProcessTaskAddCandidateGroupUpdateAuthorization() {
 // given
 startProcessInstanceByKey(PROCESS_KEY);
 String taskId = selectSingleTask().getId();
 createGrantAuthorization(TASK, taskId, userId, UPDATE);
 createGrantAuthorization(TASK, taskId, "demo", DELETE);
 // when
 taskService.addCandidateGroup(taskId, "management");
 // then
 disableAuthorization();
 Authorization authorization = authorizationService
   .createAuthorizationQuery()
   .groupIdIn("management")
   .singleResult();
 enableAuthorization();
 assertNotNull(authorization);
 assertEquals(TASK.resourceType(), authorization.getResourceType());
 assertEquals(taskId, authorization.getResourceId());
 assertTrue(authorization.isPermissionGranted(READ));
 assertTrue(authorization.isPermissionGranted(getDefaultTaskPermissionForUser()));
}

代码示例来源:origin: camunda/camunda-bpm-platform

public void testCreateUser() {
 // initially there are no authorizations for jonny2:
 assertEquals(0, authorizationService.createAuthorizationQuery().userIdIn("jonny2").count());
 // create new user
 identityService.saveUser(identityService.newUser("jonny2"));
 // now there is an authorization for jonny2 which grants him ALL permissions on himself
 Authorization authorization = authorizationService.createAuthorizationQuery().userIdIn("jonny2").singleResult();
 assertNotNull(authorization);
 assertEquals(AUTH_TYPE_GRANT, authorization.getAuthorizationType());
 assertEquals(USER.resourceType(), authorization.getResourceType());
 assertEquals("jonny2", authorization.getResourceId());
 assertTrue(authorization.isPermissionGranted(ALL));
 // delete the user
 identityService.deleteUser("jonny2");
 // the authorization is deleted as well:
 assertEquals(0, authorizationService.createAuthorizationQuery().userIdIn("jonny2").count());
}

代码示例来源:origin: camunda/camunda-bpm-platform

public void testProcessTaskSetOwnerUpdateAuthorization() {
 // given
 startProcessInstanceByKey(PROCESS_KEY);
 String taskId = selectSingleTask().getId();
 createGrantAuthorization(TASK, taskId, userId, UPDATE);
 createGrantAuthorization(TASK, taskId, "demo", DELETE);
 // when
 taskService.setOwner(taskId, "demo");
 // then
 disableAuthorization();
 Authorization authorization = authorizationService
   .createAuthorizationQuery()
   .userIdIn("demo")
   .singleResult();
 enableAuthorization();
 assertNotNull(authorization);
 assertEquals(TASK.resourceType(), authorization.getResourceType());
 assertEquals(taskId, authorization.getResourceId());
 assertTrue(authorization.isPermissionGranted(READ));
 assertTrue(authorization.isPermissionGranted(getDefaultTaskPermissionForUser()));
}

代码示例来源:origin: camunda/camunda-bpm-platform

public void testCreateGroup() {
 // initially there are no authorizations for group "sales":
 assertEquals(0, authorizationService.createAuthorizationQuery().groupIdIn("sales").count());
 // create new group
 identityService.saveGroup(identityService.newGroup("sales"));
 // now there is an authorization for sales which grants all members READ permissions
 Authorization authorization = authorizationService.createAuthorizationQuery().groupIdIn("sales").singleResult();
 assertNotNull(authorization);
 assertEquals(AUTH_TYPE_GRANT, authorization.getAuthorizationType());
 assertEquals(GROUP.resourceType(), authorization.getResourceType());
 assertEquals("sales", authorization.getResourceId());
 assertTrue(authorization.isPermissionGranted(READ));
 // delete the group
 identityService.deleteGroup("sales");
 // the authorization is deleted as well:
 assertEquals(0, authorizationService.createAuthorizationQuery().groupIdIn("sales").count());
}

相关文章