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

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

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

Authorization.setGroupId介绍

[英]set the id of the group this authorization is created for
[中]设置为其创建授权的组的id

代码示例

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

public void testRevokeAuthorizationType() {
 Authorization revokeAuthorization = authorizationService.createNewAuthorization(AUTH_TYPE_REVOKE);
 // I can set userId = null
 revokeAuthorization.setUserId(null);
 // I can set userId = ANY
 revokeAuthorization.setUserId(ANY);
 // I can set anything else:
 revokeAuthorization.setUserId("something");
 // I can set groupId = null
 revokeAuthorization.setGroupId(null);
 // I can set anything else:
 revokeAuthorization.setGroupId("something");
}

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

public void testGrantAuthorizationType() {
 Authorization grantAuthorization = authorizationService.createNewAuthorization(AUTH_TYPE_GRANT);
 // I can set userId = null
 grantAuthorization.setUserId(null);
 // I can set userId = ANY
 grantAuthorization.setUserId(ANY);
 // I can set anything else:
 grantAuthorization.setUserId("something");
 // I can set groupId = null
 grantAuthorization.setGroupId(null);
 // I can set anything else:
 grantAuthorization.setGroupId("something");
}

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

protected void grouptGrant(String groupId, Resource resource, Permission... perms) {
 AuthorizationService authorizationService = engine.getAuthorizationService();
 Authorization groupGrant = authorizationService.createNewAuthorization(AUTH_TYPE_GRANT);
 groupGrant.setResource(resource);
 groupGrant.setResourceId(ANY);
 for (Permission permission : perms) {
  groupGrant.addPermission(permission);
 }
 groupGrant.setGroupId(groupId);
 authorizationService.saveAuthorization(groupGrant);
}

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

protected void createGroupGrantAuthorization(Resource resource, String resourceId, String groupId, Permission... permissions) {
 Authorization authorization = createGrantAuthorization(resource, resourceId);
 authorization.setGroupId(groupId);
 for (Permission permission : permissions) {
  authorization.addPermission(permission);
 }
 saveAuthorization(authorization);
}

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

protected void createGrantAuthorizationGroup(Resource resource, String resourceId, String groupId, Permission... permissions) {
 Authorization authorization = createGrantAuthorization(resource, resourceId);
 authorization.setGroupId(groupId);
 for (Permission permission : permissions) {
  authorization.addPermission(permission);
 }
 saveAuthorization(authorization);
}

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

public void testGlobalAuthorizationType() {
 Authorization globalAuthorization = authorizationService.createNewAuthorization(AUTH_TYPE_GLOBAL);
 // I can set userId = null
 globalAuthorization.setUserId(null);
 // I can set userId = ANY
 globalAuthorization.setUserId(ANY);
 try {
  // I cannot set anything else:
  globalAuthorization.setUserId("something");
  fail("exception expected");
 } catch (Exception e) {
  assertTextPresent("ENGINE-03028 Illegal value 'something' for userId for GLOBAL authorization. Must be '*'", e.getMessage());
 }
 // I can set groupId = null
 globalAuthorization.setGroupId(null);
 try {
  // I cannot set anything else:
  globalAuthorization.setGroupId("something");
  fail("exception expected");
 } catch (Exception e) {
  assertTextPresent("ENGINE-03027 Cannot use 'groupId' for GLOBAL authorization", e.getMessage());
 }
}

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

public static void update(AuthorizationCreateDto dto, Authorization dbAuthorization) {
 
 dbAuthorization.setGroupId(dto.getGroupId());
 dbAuthorization.setUserId(dto.getUserId());
 dbAuthorization.setResourceType(dto.getResourceType());
 dbAuthorization.setResourceId(dto.getResourceId());
 dbAuthorization.setPermissions(PermissionConverter.getPermissionsForNames(dto.getPermissions(), dto.getResourceType()));
 
}

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

public static void update(AuthorizationCreateDto dto, Authorization dbAuthorization) {
 
 dbAuthorization.setGroupId(dto.getGroupId());
 dbAuthorization.setUserId(dto.getUserId());
 dbAuthorization.setResourceType(dto.getResourceType());
 dbAuthorization.setResourceId(dto.getResourceId());
 dbAuthorization.setPermissions(PermissionConverter.getPermissionsForNames(dto.getPermissions(), dto.getResourceType()));
 
}

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

@Test
public void testUpdateAuthorization() {
 Authorization authorization = MockProvider.createMockGlobalAuthorization();
 AuthorizationQuery authorizationQuery = mock(AuthorizationQuery.class);
 when(authorizationServiceMock.createAuthorizationQuery()).thenReturn(authorizationQuery);
 when(authorizationQuery.authorizationId(MockProvider.EXAMPLE_AUTHORIZATION_ID)).thenReturn(authorizationQuery);
 when(authorizationQuery.singleResult()).thenReturn(authorization);
 AuthorizationDto dto = AuthorizationDto.fromAuthorization(authorization);
 given()
   .pathParam("id", MockProvider.EXAMPLE_AUTHORIZATION_ID)
   .body(dto).contentType(ContentType.JSON)
 .then().expect()
   .statusCode(Status.NO_CONTENT.getStatusCode())
 .when()
   .put(AUTH_RESOURCE_PATH);
 verify(authorizationQuery).authorizationId(MockProvider.EXAMPLE_AUTHORIZATION_ID);
 verify(authorization).setGroupId(dto.getGroupId());
 verify(authorization).setUserId(dto.getUserId());
 verify(authorization).setResourceId(dto.getResourceId());
 verify(authorization).setResourceType(dto.getResourceType());
 verify(authorizationServiceMock).saveAuthorization(authorization);
}

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

public static void update(AuthorizationDto dto, Authorization dbAuthorization) {
 dbAuthorization.setGroupId(dto.getGroupId());
 dbAuthorization.setUserId(dto.getUserId());
 dbAuthorization.setResourceId(dto.getResourceId());
 // update optional fields
 if(dto.getResourceType() != null) {
  dbAuthorization.setResourceType(dto.getResourceType());
 }
 if(dto.getPermissions() != null) {
  dbAuthorization.setPermissions(PermissionConverter.getPermissionsForNames(dto.getPermissions(), dto.getResourceType()));
 }
}

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

public static void update(AuthorizationDto dto, Authorization dbAuthorization) {
 dbAuthorization.setGroupId(dto.getGroupId());
 dbAuthorization.setUserId(dto.getUserId());
 dbAuthorization.setResourceId(dto.getResourceId());
 // update optional fields
 if(dto.getResourceType() != null) {
  dbAuthorization.setResourceType(dto.getResourceType());
 }
 if(dto.getPermissions() != null) {
  dbAuthorization.setPermissions(PermissionConverter.getPermissionsForNames(dto.getPermissions(), dto.getResourceType()));
 }
}

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

protected void createAuthorization(String userId, String groupId, Resource resourceType, String resourceId, Permission... permissions) {
 Authorization authorization = authorizationService.createNewAuthorization(Authorization.AUTH_TYPE_GRANT);
 authorization.setUserId(userId);
 authorization.setGroupId(groupId);
 authorization.setResource(resourceType);
 authorization.setResourceId(resourceId);
 for (Permission permission : permissions) {
  authorization.addPermission(permission);
 }
 authorizationService.saveAuthorization(authorization);
}

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

authorization1.setGroupId("someGroup");
authorization2.setGroupId("someGroup");
authorization3.setGroupId("someGroup");
authorization4.setGroupId("someGroup");

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

public void testQueryWithGroupAuthorizationRevokedReadPermission() {
 // given
 // given user gets all permissions on any process definition
 Authorization authorization = createGrantAuthorization(PROCESS_DEFINITION, ANY);
 authorization.setGroupId(groupId);
 authorization.addPermission(ALL);
 saveAuthorization(authorization);
 authorization = createRevokeAuthorization(PROCESS_DEFINITION, ONE_TASK_PROCESS_KEY);
 authorization.setGroupId(groupId);
 authorization.removePermission(READ);
 saveAuthorization(authorization);
 // when
 ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery();
 // then
 verifyQueryResults(query, 1);
 ProcessDefinition definition = query.singleResult();
 assertNotNull(definition);
 assertEquals(TWO_TASKS_PROCESS_KEY, definition.getKey());
}

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

public void testCreateAuthorizationWithGroupId() {
 Resource resource1 = TestResource.RESOURCE1;
 // initially, no authorization exists:
 assertEquals(0, authorizationService.createAuthorizationQuery().count());
 // simple create / delete with userId
 Authorization authorization = authorizationService.createNewAuthorization(AUTH_TYPE_GRANT);
 authorization.setGroupId("aGroupId");
 authorization.setResource(resource1);
 // save the authorization
 authorizationService.saveAuthorization(authorization);
 // authorization exists
 assertEquals(1, authorizationService.createAuthorizationQuery().count());
 // delete the authorization
 authorizationService.deleteAuthorization(authorization.getId());
 // it's gone
 assertEquals(0, authorizationService.createAuthorizationQuery().count());
}

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

authorization.setGroupId("someId");
authorization.setUserId("someOtherId");
authorization.setResource(resource1);

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

accAuth.setGroupId("accounting");
accAuth.setResource(GROUP);
accAuth.setResourceId("accounting");
salesAuth.setGroupId("sales");
salesAuth.setResource(GROUP);
salesAuth.setResourceId("sales");
manAuth.setGroupId("management");
manAuth.setResource(GROUP);
manAuth.setResourceId("management");
salesDemoAuth.setGroupId("sales");
salesDemoAuth.setResource(USER);
salesDemoAuth.setResourceId("demo");
salesJohnAuth.setGroupId("sales");
salesJohnAuth.setResource(USER);
salesJohnAuth.setResourceId("john");
manDemoAuth.setGroupId("management");
manDemoAuth.setResource(USER);
manDemoAuth.setResourceId("demo");
manPeterAuth.setGroupId("management");
manPeterAuth.setResource(USER);
manPeterAuth.setResourceId("peter");
accDemoAuth.setGroupId("accounting");

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

groupRevoke.setGroupId("sales");
groupRevoke.setResource(resource1);
groupRevoke.setResourceId(ANY);

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

groupRevoke.setGroupId("sales");
groupRevoke.setResource(resource1);
groupRevoke.setResourceId(ANY);

代码示例来源:origin: org.camunda.bpm/camunda-engine

protected void createGroupGrantAuthorization(Resource resource, String resourceId, String groupId, Permission... permissions) {
 Authorization authorization = createGrantAuthorization(resource, resourceId);
 authorization.setGroupId(groupId);
 for (Permission permission : permissions) {
  authorization.addPermission(permission);
 }
 saveAuthorization(authorization);
}

相关文章