本文整理了Java中org.camunda.bpm.engine.authorization.Authorization.getPermissions()
方法的一些代码示例,展示了Authorization.getPermissions()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Authorization.getPermissions()
方法的具体详情如下:
包路径:org.camunda.bpm.engine.authorization.Authorization
类名称:Authorization
方法名:getPermissions
[英]Allows checking whether this authorization grants / revokes a set of permissions. Usually the set of built-in permissions is used: Permissions#values()The return value of this method depends on the type of the authorization:
代码示例来源: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
/**
* @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
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
@Test
public void testCreateGlobalAuthorization() {
Authorization authorization = MockProvider.createMockGlobalAuthorization();
when(authorizationServiceMock.createNewAuthorization(Authorization.AUTH_TYPE_GLOBAL)).thenReturn(authorization);
when(authorizationServiceMock.saveAuthorization(authorization)).thenReturn(authorization);
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()
.body(dto).contentType(ContentType.JSON)
.then().expect()
.statusCode(Status.OK.getStatusCode())
.when()
.post(AUTH_CREATE_PATH);
verify(authorizationServiceMock).createNewAuthorization(Authorization.AUTH_TYPE_GLOBAL);
verify(authorization).setUserId(Authorization.ANY);
verify(authorization, times(4)).setResourceType(authorization.getAuthorizationType());
verify(authorization, times(2)).setResourceId(authorization.getResourceId());
verify(authorization, times(2)).setPermissions(authorization.getPermissions(Permissions.values()));
verify(authorizationServiceMock).saveAuthorization(authorization);
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void testCreateGrantAuthorization() {
Authorization authorization = MockProvider.createMockGrantAuthorization();
when(authorizationServiceMock.createNewAuthorization(Authorization.AUTH_TYPE_GRANT)).thenReturn(authorization);
when(authorizationServiceMock.saveAuthorization(authorization)).thenReturn(authorization);
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()
.body(dto).contentType(ContentType.JSON)
.then().expect()
.statusCode(Status.OK.getStatusCode())
.when()
.post(AUTH_CREATE_PATH);
verify(authorizationServiceMock).createNewAuthorization(Authorization.AUTH_TYPE_GRANT);
verify(authorization, times(2)).setUserId(authorization.getUserId());
verify(authorization, times(4)).setResourceType(authorization.getAuthorizationType());
verify(authorization, times(2)).setResourceId(authorization.getResourceId());
verify(authorization, times(2)).setPermissions(authorization.getPermissions(Permissions.values()));
verify(authorizationServiceMock).saveAuthorization(authorization);
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void testCreateRevokeAuthorization() {
Authorization authorization = MockProvider.createMockRevokeAuthorization();
when(authorizationServiceMock.createNewAuthorization(Authorization.AUTH_TYPE_REVOKE)).thenReturn(authorization);
when(authorizationServiceMock.saveAuthorization(authorization)).thenReturn(authorization);
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()
.body(dto).contentType(ContentType.JSON)
.then().expect()
.statusCode(Status.OK.getStatusCode())
.when()
.post(AUTH_CREATE_PATH);
verify(authorizationServiceMock).createNewAuthorization(Authorization.AUTH_TYPE_REVOKE);
verify(authorization, times(2)).setUserId(authorization.getUserId());
verify(authorization, times(4)).setResourceType(authorization.getAuthorizationType());
verify(authorization, times(2)).setResourceId(authorization.getResourceId());
verify(authorization, times(2)).setPermissions(authorization.getPermissions(Permissions.values()));
verify(authorizationServiceMock).saveAuthorization(authorization);
}
代码示例来源:origin: org.camunda.bpm/camunda-engine
protected static MissingAuthorization asMissingAuthorization(Authorization authorization) {
String permissionName = null;
String resourceId = null;
String resourceName = null;
for (Permission permission : authorization.getPermissions(Permissions.values())) {
if (permission != Permissions.NONE) {
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: org.camunda.bpm/camunda-engine-rest-jaxrs2
public static AuthorizationDto fromAuthorization(Authorization dbAuthorization) {
AuthorizationDto authorizationDto = new AuthorizationDto();
authorizationDto.setId(dbAuthorization.getId());
authorizationDto.setType(dbAuthorization.getAuthorizationType());
Permission[] dbPermissions = dbAuthorization.getPermissions(Permissions.values());
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: org.camunda.bpm/camunda-engine
Assert.assertEquals(missingAuthorization.getUserId(), e.getUserId());
for (Permission permission : missingAuthorization.getPermissions(Permissions.values())) {
if (permission != Permissions.NONE) {
Assert.assertTrue(assertionFailureMessage, message.contains(permission.getName()));
代码示例来源:origin: camunda/camunda-bpm-platform
authorization.setResource(Resources.USER);
assertEquals(1, authorization.getPermissions(Permissions.values()).length);
代码示例来源:origin: org.camunda.bpm/camunda-engine
assertEquals(1, authorization.getPermissions(Permissions.values()).length);
内容来源于网络,如有侵权,请联系作者删除!