本文整理了Java中org.camunda.bpm.engine.authorization.Authorization.setResourceId()
方法的一些代码示例,展示了Authorization.setResourceId()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Authorization.setResourceId()
方法的具体详情如下:
包路径:org.camunda.bpm.engine.authorization.Authorization
类名称:Authorization
方法名:setResourceId
[英]set the id of the resource
[中]设置资源的id
代码示例来源:origin: camunda/camunda-bpm-platform
protected void grantFilterPermission(Authorization authorization, String filterId) {
if (filterId != null) {
authorization.setResourceId(filterId);
}
authorizationService.saveAuthorization(authorization);
}
代码示例来源: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
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
protected Authorization createAuthorization(int type, Resource resource, String resourceId) {
Authorization authorization = authorizationService.createNewAuthorization(type);
authorization.setResource(resource);
if (resourceId != null) {
authorization.setResourceId(resourceId);
}
return authorization;
}
代码示例来源:origin: camunda/camunda-bpm-platform
protected Authorization createAuthorization(int type, Resource resource, String resourceId) {
Authorization authorization = authorizationService.createNewAuthorization(type);
authorization.setResource(resource);
if (resourceId != null) {
authorization.setResourceId(resourceId);
}
return authorization;
}
代码示例来源: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 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 Authorization createAuthorization(int type, Resource resource, String resourceId) {
Authorization authorization = engineRule.getAuthorizationService().createNewAuthorization(type);
authorization.setResource(resource);
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 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 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 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 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 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
@Test
public void testQuerySingleCorrectPermission() throws Exception {
// given
Authorization authorization = authorizationService.createNewAuthorization(AUTH_TYPE_GRANT);
authorization.setUserId("userId");
authorization.setResource(Resources.PROCESS_DEFINITION);
authorization.addPermission(Permissions.READ);
authorization.setResourceId(ANY);
authorizationService.saveAuthorization(authorization);
processEngineConfiguration.setAuthorizationEnabled(true);
// assume
Authorization authResult = authorizationService.createAuthorizationQuery().userIdIn("userId").resourceType(Resources.PROCESS_DEFINITION).singleResult();
assertNotNull(authResult);
// then
assertEquals(1, authorizationService.createAuthorizationQuery().hasPermission(Permissions.READ).count());
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void testQuerySingleIncorrectPermission() throws Exception {
// given
Authorization authorization = authorizationService.createNewAuthorization(AUTH_TYPE_GRANT);
authorization.setUserId("userId");
authorization.setResource(Resources.BATCH);
authorization.addPermission(BatchPermissions.CREATE_BATCH_DELETE_RUNNING_PROCESS_INSTANCES);
authorization.setResourceId(ANY);
authorizationService.saveAuthorization(authorization);
processEngineConfiguration.setAuthorizationEnabled(true);
// assume
Authorization authResult = authorizationService.createAuthorizationQuery().userIdIn("userId").resourceType(Resources.BATCH).singleResult();
assertNotNull(authResult);
// then
assertEquals(0, authorizationService.createAuthorizationQuery().hasPermission(Permissions.CREATE_INSTANCE).count());
}
内容来源于网络,如有侵权,请联系作者删除!