use of org.camunda.bpm.engine.authorization.Authorization in project camunda-bpm-platform by camunda.
the class AuthorizationPerformanceTestCase method grouptGrant.
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);
}
use of org.camunda.bpm.engine.authorization.Authorization in project camunda-bpm-platform by camunda.
the class LdapGroupQueryTest method createGrantAuthorization.
protected void createGrantAuthorization(Resource resource, String resourceId, String userId, Permission... permissions) {
Authorization authorization = createAuthorization(AUTH_TYPE_GRANT, resource, resourceId);
authorization.setUserId(userId);
for (Permission permission : permissions) {
authorization.addPermission(permission);
}
authorizationService.saveAuthorization(authorization);
}
use of org.camunda.bpm.engine.authorization.Authorization in project camunda-bpm-platform by camunda.
the class LdapGroupQueryTest method testPaginationWithAuthenticatedUser.
public void testPaginationWithAuthenticatedUser() {
createGrantAuthorization(GROUP, "management", "oscar", READ);
createGrantAuthorization(GROUP, "consulting", "oscar", READ);
createGrantAuthorization(GROUP, "external", "oscar", READ);
try {
processEngineConfiguration.setAuthorizationEnabled(true);
identityService.setAuthenticatedUserId("oscar");
Set<String> groupNames = new HashSet<String>();
List<Group> groups = identityService.createGroupQuery().listPage(0, 2);
assertEquals(2, groups.size());
checkPagingResults(groupNames, groups.get(0).getId(), groups.get(1).getId());
groups = identityService.createGroupQuery().listPage(2, 2);
assertEquals(1, groups.size());
assertFalse(groupNames.contains(groups.get(0).getId()));
groupNames.add(groups.get(0).getId());
groups = identityService.createGroupQuery().listPage(4, 2);
assertEquals(0, groups.size());
identityService.setAuthenticatedUserId("daniel");
groups = identityService.createGroupQuery().listPage(0, 2);
assertEquals(0, groups.size());
} finally {
processEngineConfiguration.setAuthorizationEnabled(false);
identityService.clearAuthentication();
for (Authorization authorization : authorizationService.createAuthorizationQuery().list()) {
authorizationService.deleteAuthorization(authorization.getId());
}
}
}
use of org.camunda.bpm.engine.authorization.Authorization in project camunda-bpm-platform by camunda.
the class LdapUserQueryTest method testPaginationWithAuthenticatedUser.
public void testPaginationWithAuthenticatedUser() {
createGrantAuthorization(USER, "roman", "oscar", READ);
createGrantAuthorization(USER, "daniel", "oscar", READ);
createGrantAuthorization(USER, "monster", "oscar", READ);
createGrantAuthorization(USER, "ruecker", "oscar", READ);
try {
processEngineConfiguration.setAuthorizationEnabled(true);
identityService.setAuthenticatedUserId("oscar");
Set<String> userNames = new HashSet<String>();
List<User> users = identityService.createUserQuery().listPage(0, 2);
assertEquals(2, users.size());
checkPagingResults(userNames, users.get(0).getId(), users.get(1).getId());
users = identityService.createUserQuery().listPage(2, 2);
assertEquals(2, users.size());
checkPagingResults(userNames, users.get(0).getId(), users.get(1).getId());
users = identityService.createUserQuery().listPage(4, 2);
assertEquals(1, users.size());
assertFalse(userNames.contains(users.get(0).getId()));
userNames.add(users.get(0).getId());
identityService.setAuthenticatedUserId("daniel");
users = identityService.createUserQuery().listPage(0, 2);
assertEquals(1, users.size());
assertEquals("daniel", users.get(0).getId());
users = identityService.createUserQuery().listPage(2, 2);
assertEquals(0, users.size());
} finally {
processEngineConfiguration.setAuthorizationEnabled(false);
identityService.clearAuthentication();
for (Authorization authorization : authorizationService.createAuthorizationQuery().list()) {
authorizationService.deleteAuthorization(authorization.getId());
}
}
}
use of org.camunda.bpm.engine.authorization.Authorization in project camunda-bpm-platform by camunda.
the class LdapDisableAuthorizationCheckTest method testUserQueryPaginationWithAuthenticatedUserWithAuthorizations.
public void testUserQueryPaginationWithAuthenticatedUserWithAuthorizations() {
createGrantAuthorization(USER, "roman", "oscar", READ);
createGrantAuthorization(USER, "daniel", "oscar", READ);
createGrantAuthorization(USER, "monster", "oscar", READ);
createGrantAuthorization(USER, "ruecker", "oscar", READ);
try {
processEngineConfiguration.setAuthorizationEnabled(true);
identityService.setAuthenticatedUserId("oscar");
testUserPaging(identityService);
} finally {
processEngineConfiguration.setAuthorizationEnabled(false);
identityService.clearAuthentication();
for (Authorization authorization : authorizationService.createAuthorizationQuery().list()) {
authorizationService.deleteAuthorization(authorization.getId());
}
}
}
Aggregations