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

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

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

Authorization.setUserId介绍

[英]set the id of the user this authorization is created for
[中]

代码示例

代码示例来源: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

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

protected static Authorization createAuthorization(AuthorizationService authorizationService, Permission permission, Resources resource, String userId) {
  Authorization auth = authorizationService.createNewAuthorization(AUTH_TYPE_GRANT);
  auth.addPermission(permission);
  auth.setResource(resource);
  auth.setResourceId(Authorization.ANY);
  auth.setUserId(userId);
  return auth;
 }
}

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

protected void userGrant(String userId, 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.setUserId(userId);
 authorizationService.saveAuthorization(groupGrant);
}

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

protected void createGrantAuthorization(Resource resource, String resourceId, Permission permission, String userId) {
 Authorization authorization = createGrantAuthorization(resource, resourceId);
 authorization.setUserId(userId);
 authorization.addPermission(permission);
 saveAuthorization(authorization);
}

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

protected void createRevokeAuthorization(Resource resource, String resourceId, String userId, Permission... permissions) {
 Authorization authorization = createRevokeAuthorization(resource, resourceId);
 authorization.setUserId(userId);
 for (Permission permission : permissions) {
  authorization.removePermission(permission);
 }
 saveAuthorization(authorization);
}

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

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

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

public Authorization instantiate(AuthorizationService authorizationService, Map<String, String> replacements) {
 Authorization authorization = authorizationService.createNewAuthorization(type);
 // TODO: group id is missing
 authorization.setResource(resource);
 if (replacements.containsKey(resourceId)) {
  authorization.setResourceId(replacements.get(resourceId));
 }
 else {
  authorization.setResourceId(resourceId);
 }
 authorization.setUserId(userId);
 authorization.setPermissions(permissions);
 return authorization;
}

代码示例来源: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

protected Authorization createAuthorization(Permission permission, String resourceId) {
 Authorization authorization = authorizationService.createNewAuthorization(Authorization.AUTH_TYPE_GRANT);
 authorization.setUserId(testUser.getId());
 authorization.setResource(Resources.FILTER);
 authorization.addPermission(permission);
 if (resourceId != null) {
  authorization.setResourceId(resourceId);
 }
 return authorization;
}

代码示例来源: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

protected void grantAuthorization(String userId, Resource resource, String resourceId, Permission permission) {
  Authorization authorization = engineRule.getAuthorizationService().createNewAuthorization(Authorization.AUTH_TYPE_GRANT);
  authorization.setResource(resource);
  authorization.setResourceId(resourceId);
  authorization.addPermission(permission);
  authorization.setUserId(userId);
  engineRule.getAuthorizationService().saveAuthorization(authorization);
  authorizations.add(authorization);
 }
}

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

public void createGrantAuthorization(Resource resource, String resourceId, String userId, Permission... permissions) {
 Authorization authorization = createAuthorization(Authorization.AUTH_TYPE_GRANT, resource, resourceId);
 authorization.setUserId(userId);
 for (Permission permission : permissions) {
  authorization.addPermission(permission);
 }
 engineRule.getAuthorizationService().saveAuthorization(authorization);
 manageAuthorization(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

public void testDashboardResourceAuthorization() {
 MyResourceAuthorizationProvider.clearProperties();
 Authorization authorization = authorizationService.createNewAuthorization(AUTH_TYPE_GRANT);
 authorization.setUserId(userId);
 authorization.addPermission(ALL);
 authorization.setResource(DASHBOARD);
 authorization.setResourceId(ANY);
 authorizationService.saveAuthorization(authorization);
 processEngineConfiguration.setAuthorizationEnabled(true);
 assertEquals(true, authorizationService.isUserAuthorized(userId, Arrays.asList(groupId), ALL, DASHBOARD));
 processEngineConfiguration.setAuthorizationEnabled(false);
}

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

public void testReportResourceAuthorization() {
 MyResourceAuthorizationProvider.clearProperties();
 Authorization authorization = authorizationService.createNewAuthorization(AUTH_TYPE_GRANT);
 authorization.setUserId(userId);
 authorization.addPermission(ALL);
 authorization.setResource(REPORT);
 authorization.setResourceId(ANY);
 authorizationService.saveAuthorization(authorization);
 processEngineConfiguration.setAuthorizationEnabled(true);
 assertEquals(true, authorizationService.isUserAuthorized(userId, Arrays.asList(groupId), ALL, REPORT));
 processEngineConfiguration.setAuthorizationEnabled(false);
}

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

public void testIsUserAuthorizedWithValidResourceImpl() {
 // given
 ResourceImpl resource = new ResourceImpl("authorization", 0);
 Authorization authorization = authorizationService.createNewAuthorization(AUTH_TYPE_GRANT);
 String userId = "userId";
 authorization.setUserId(userId);
 authorization.addPermission(Permissions.ACCESS);
 authorization.setResource(Resources.APPLICATION);
 authorization.setResourceId(ANY);
 authorizationService.saveAuthorization(authorization);
 processEngineConfiguration.setAuthorizationEnabled(true);
 // then
 assertEquals(true, authorizationService.isUserAuthorized(userId, null, Permissions.ACCESS, resource));
}

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

public void testDeleteProcessInstanceByModifyingWithoutDeleteInstancePermissionOnProcessDefinition() {
 // given
 String processInstanceId = startProcessInstanceByKey(MESSAGE_BOUNDARY_PROCESS_KEY).getId();
 Authorization authorization = createGrantAuthorization(PROCESS_DEFINITION, MESSAGE_BOUNDARY_PROCESS_KEY);
 authorization.setUserId(userId);
 authorization.addPermission(UPDATE_INSTANCE);
 authorization.addPermission(DELETE_INSTANCE);
 saveAuthorization(authorization);
 // when
 runtimeService.createProcessInstanceModification(processInstanceId)
  .cancelAllForActivity("task")
  .execute();
 // then
 assertProcessEnded(processInstanceId);
}

相关文章