本文整理了Java中org.camunda.bpm.engine.authorization.Authorization.getUserId()
方法的一些代码示例,展示了Authorization.getUserId()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Authorization.getUserId()
方法的具体详情如下:
包路径:org.camunda.bpm.engine.authorization.Authorization
类名称:Authorization
方法名:getUserId
暂无
代码示例来源: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 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: camunda/camunda-bpm-platform
@Test
public void testGetAuthorizationById() {
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);
given()
.pathParam("id", MockProvider.EXAMPLE_AUTHORIZATION_ID)
.then().expect()
.statusCode(Status.OK.getStatusCode()).contentType(ContentType.JSON)
.body("id", equalTo(authorization.getId()))
.body("type", equalTo(authorization.getAuthorizationType()))
.body("permissions[0]", equalTo(Permissions.READ.getName()))
.body("permissions[1]", equalTo(Permissions.UPDATE.getName()))
.body("userId", equalTo(authorization.getUserId()))
.body("groupId", equalTo(authorization.getGroupId()))
.body("resourceType", equalTo(authorization.getResourceType()))
.body("resourceId", equalTo(authorization.getResourceId()))
.when()
.get(AUTH_RESOURCE_PATH);
}
代码示例来源: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
Assert.assertTrue(assertionFailureMessage, message.contains(missingAuthorization.getUserId()));
Assert.assertEquals(missingAuthorization.getUserId(), e.getUserId());
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void testSimpleAuthorizationQuery() {
List<Authorization> mockAuthorizations = MockProvider.createMockGlobalAuthorizations();
AuthorizationQuery mockQuery = setUpMockQuery(mockAuthorizations);
Response response = given().queryParam("type", Authorization.AUTH_TYPE_GLOBAL)
.then().expect().statusCode(Status.OK.getStatusCode())
.when().get(SERVICE_PATH);
InOrder inOrder = inOrder(mockQuery);
inOrder.verify(mockQuery).authorizationType(Authorization.AUTH_TYPE_GLOBAL);
inOrder.verify(mockQuery).list();
String content = response.asString();
List<String> instances = from(content).getList("");
Assert.assertEquals("There should be one authorization returned.", 1, instances.size());
Assert.assertNotNull("The returned authorization should not be null.", instances.get(0));
Authorization mockAuthorization = mockAuthorizations.get(0);
Assert.assertEquals(mockAuthorization.getId(), from(content).getString("[0].id"));
Assert.assertEquals(mockAuthorization.getAuthorizationType(), from(content).getInt("[0].type"));
Assert.assertEquals(Permissions.READ.getName(), from(content).getString("[0].permissions[0]"));
Assert.assertEquals(Permissions.UPDATE.getName(), from(content).getString("[0].permissions[1]"));
Assert.assertEquals(mockAuthorization.getUserId(), from(content).getString("[0].userId"));
Assert.assertEquals(mockAuthorization.getGroupId(), from(content).getString("[0].groupId"));
Assert.assertEquals(mockAuthorization.getResourceType(), from(content).getInt("[0].resourceType"));
Assert.assertEquals(mockAuthorization.getResourceId(), from(content).getString("[0].resourceId"));
}
代码示例来源:origin: camunda/camunda-bpm-platform
public void testUpdateNewAuthorization() {
Resource resource1 = TestResource.RESOURCE1;
Resource resource2 = TestResource.RESOURCE2;
Authorization authorization = authorizationService.createNewAuthorization(AUTH_TYPE_GRANT);
authorization.setUserId("aUserId");
authorization.setResource(resource1);
authorization.setResourceId("aResourceId");
authorization.addPermission(TestPermissions.ACCESS);
// save the authorization
authorizationService.saveAuthorization(authorization);
// validate authorization
Authorization savedAuthorization = authorizationService.createAuthorizationQuery().singleResult();
assertEquals("aUserId", savedAuthorization.getUserId());
assertEquals(resource1.resourceType(), savedAuthorization.getResourceType());
assertEquals("aResourceId", savedAuthorization.getResourceId());
assertTrue(savedAuthorization.isPermissionGranted(TestPermissions.ACCESS));
// update authorization
authorization.setUserId("anotherUserId");
authorization.setResource(resource2);
authorization.setResourceId("anotherResourceId");
authorization.addPermission(TestPermissions.DELETE);
authorizationService.saveAuthorization(authorization);
// validate authorization updated
savedAuthorization = authorizationService.createAuthorizationQuery().singleResult();
assertEquals("anotherUserId", savedAuthorization.getUserId());
assertEquals(resource2.resourceType(), savedAuthorization.getResourceType());
assertEquals("anotherResourceId", savedAuthorization.getResourceId());
assertTrue(savedAuthorization.isPermissionGranted(TestPermissions.ACCESS));
assertTrue(savedAuthorization.isPermissionGranted(TestPermissions.DELETE));
}
代码示例来源:origin: camunda/camunda-bpm-platform
public void testUpdatePersistentAuthorization() {
Resource resource1 = TestResource.RESOURCE1;
Resource resource2 = TestResource.RESOURCE2;
Authorization authorization = authorizationService.createNewAuthorization(AUTH_TYPE_GRANT);
authorization.setUserId("aUserId");
authorization.setResource(resource1);
authorization.setResourceId("aResourceId");
authorization.addPermission(TestPermissions.ACCESS);
// save the authorization
authorizationService.saveAuthorization(authorization);
// validate authorization
Authorization savedAuthorization = authorizationService.createAuthorizationQuery().singleResult();
assertEquals("aUserId", savedAuthorization.getUserId());
assertEquals(resource1.resourceType(), savedAuthorization.getResourceType());
assertEquals("aResourceId", savedAuthorization.getResourceId());
assertTrue(savedAuthorization.isPermissionGranted(TestPermissions.ACCESS));
// update authorization
savedAuthorization.setUserId("anotherUserId");
savedAuthorization.setResource(resource2);
savedAuthorization.setResourceId("anotherResourceId");
savedAuthorization.addPermission(TestPermissions.DELETE);
authorizationService.saveAuthorization(savedAuthorization);
// validate authorization updated
savedAuthorization = authorizationService.createAuthorizationQuery().singleResult();
assertEquals("anotherUserId", savedAuthorization.getUserId());
assertEquals(resource2.resourceType(), savedAuthorization.getResourceType());
assertEquals("anotherResourceId", savedAuthorization.getResourceId());
assertTrue(savedAuthorization.isPermissionGranted(TestPermissions.ACCESS));
assertTrue(savedAuthorization.isPermissionGranted(TestPermissions.DELETE));
}
代码示例来源:origin: org.camunda.bpm/camunda-engine
Assert.assertTrue(assertionFailureMessage, message.contains(missingAuthorization.getUserId()));
Assert.assertEquals(missingAuthorization.getUserId(), e.getUserId());
代码示例来源: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
public void testUpdateNewAuthorization() {
TestResource resource1 = new TestResource("resource1",100);
TestResource resource2 = new TestResource("resource1",101);
Authorization authorization = authorizationService.createNewAuthorization(AUTH_TYPE_GRANT);
authorization.setUserId("aUserId");
authorization.setResource(resource1);
authorization.setResourceId("aResourceId");
authorization.addPermission(ACCESS);
// save the authorization
authorizationService.saveAuthorization(authorization);
// validate authorization
Authorization savedAuthorization = authorizationService.createAuthorizationQuery().singleResult();
assertEquals("aUserId", savedAuthorization.getUserId());
assertEquals(resource1.resourceType(), savedAuthorization.getResourceType());
assertEquals("aResourceId", savedAuthorization.getResourceId());
assertTrue(savedAuthorization.isPermissionGranted(ACCESS));
// update authorization
authorization.setUserId("anotherUserId");
authorization.setResource(resource2);
authorization.setResourceId("anotherResourceId");
authorization.addPermission(DELETE);
authorizationService.saveAuthorization(authorization);
// validate authorization updated
savedAuthorization = authorizationService.createAuthorizationQuery().singleResult();
assertEquals("anotherUserId", savedAuthorization.getUserId());
assertEquals(resource2.resourceType(), savedAuthorization.getResourceType());
assertEquals("anotherResourceId", savedAuthorization.getResourceId());
assertTrue(savedAuthorization.isPermissionGranted(ACCESS));
assertTrue(savedAuthorization.isPermissionGranted(DELETE));
}
代码示例来源:origin: org.camunda.bpm/camunda-engine
public void testUpdatePersistentAuthorization() {
TestResource resource1 = new TestResource("resource1",100);
TestResource resource2 = new TestResource("resource1",101);
Authorization authorization = authorizationService.createNewAuthorization(AUTH_TYPE_GRANT);
authorization.setUserId("aUserId");
authorization.setResource(resource1);
authorization.setResourceId("aResourceId");
authorization.addPermission(ACCESS);
// save the authorization
authorizationService.saveAuthorization(authorization);
// validate authorization
Authorization savedAuthorization = authorizationService.createAuthorizationQuery().singleResult();
assertEquals("aUserId", savedAuthorization.getUserId());
assertEquals(resource1.resourceType(), savedAuthorization.getResourceType());
assertEquals("aResourceId", savedAuthorization.getResourceId());
assertTrue(savedAuthorization.isPermissionGranted(ACCESS));
// update authorization
savedAuthorization.setUserId("anotherUserId");
savedAuthorization.setResource(resource2);
savedAuthorization.setResourceId("anotherResourceId");
savedAuthorization.addPermission(DELETE);
authorizationService.saveAuthorization(savedAuthorization);
// validate authorization updated
savedAuthorization = authorizationService.createAuthorizationQuery().singleResult();
assertEquals("anotherUserId", savedAuthorization.getUserId());
assertEquals(resource2.resourceType(), savedAuthorization.getResourceType());
assertEquals("anotherResourceId", savedAuthorization.getResourceId());
assertTrue(savedAuthorization.isPermissionGranted(ACCESS));
assertTrue(savedAuthorization.isPermissionGranted(DELETE));
}
内容来源于网络,如有侵权,请联系作者删除!