本文整理了Java中org.camunda.bpm.engine.authorization.Authorization.getResourceId()
方法的一些代码示例,展示了Authorization.getResourceId()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Authorization.getResourceId()
方法的具体详情如下:
包路径:org.camunda.bpm.engine.authorization.Authorization
类名称:Authorization
方法名:getResourceId
暂无
代码示例来源: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
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 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
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 testProcessTaskSetAssigneeUpdateAuthorization() {
// given
startProcessInstanceByKey(PROCESS_KEY);
String taskId = selectSingleTask().getId();
createGrantAuthorization(TASK, taskId, userId, UPDATE);
createGrantAuthorization(TASK, taskId, "demo", DELETE);
// 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 testStandaloneTaskSetOwnerOutsideCommandContextSave() {
// given
String taskId = "myTask";
createTask(taskId);
createGrantAuthorization(TASK, taskId, userId, UPDATE);
Task task = selectSingleTask();
task.setOwner("demo");
// when
taskService.saveTask(task);
// 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 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());
}
代码示例来源:origin: camunda/camunda-bpm-platform
public void testStandaloneTaskSetAssigneeOutsideCommandContextInsert() {
// given
String taskId = "myTask";
createGrantAuthorization(TASK, ANY, userId, CREATE);
createGrantAuthorization(TASK, taskId, userId, UPDATE);
Task task = taskService.newTask(taskId);
task.setAssignee("demo");
// when
taskService.saveTask(task);
// 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);
}
内容来源于网络,如有侵权,请联系作者删除!