Java Code Examples for org.camunda.bpm.engine.identity.Group#setType()
The following examples show how to use
org.camunda.bpm.engine.identity.Group#setType() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CreateAdminUserConfiguration.java From camunda-bpm-spring-boot-starter with Apache License 2.0 | 5 votes |
@Override public void postProcessEngineBuild(final ProcessEngine processEngine) { requireNonNull(adminUser); final IdentityService identityService = processEngine.getIdentityService(); final AuthorizationService authorizationService = processEngine.getAuthorizationService(); if (userAlreadyExists(identityService, adminUser)) { return; } createUser(identityService, adminUser); // create group if (identityService.createGroupQuery().groupId(CAMUNDA_ADMIN).count() == 0) { Group camundaAdminGroup = identityService.newGroup(CAMUNDA_ADMIN); camundaAdminGroup.setName("camunda BPM Administrators"); camundaAdminGroup.setType(Groups.GROUP_TYPE_SYSTEM); identityService.saveGroup(camundaAdminGroup); } // create ADMIN authorizations on all built-in resources for (Resource resource : Resources.values()) { if (authorizationService.createAuthorizationQuery().groupIdIn(CAMUNDA_ADMIN).resourceType(resource).resourceId(ANY).count() == 0) { AuthorizationEntity userAdminAuth = new AuthorizationEntity(AUTH_TYPE_GRANT); userAdminAuth.setGroupId(CAMUNDA_ADMIN); userAdminAuth.setResource(resource); userAdminAuth.setResourceId(ANY); userAdminAuth.addPermission(ALL); authorizationService.saveAuthorization(userAdminAuth); } } identityService.createMembership(adminUser.getId(), CAMUNDA_ADMIN); LOG.creatingInitialAdminUser(adminUser); }
Example 2
Source File: DemoDataGenerator.java From camunda-bpm-elasticsearch with Apache License 2.0 | 5 votes |
public void afterPropertiesSet() throws Exception { System.out.println("Generating demo data"); scheduleInstanceStart(); // ensure admin user exists IdentityService identityService = processEngine.getIdentityService(); User user = identityService.createUserQuery().userId("demo").singleResult(); if(user == null) { User newUser = identityService.newUser("demo"); newUser.setPassword("demo"); identityService.saveUser(newUser); System.out.println("Created used 'demo', password 'demo'"); AuthorizationService authorizationService = processEngine.getAuthorizationService(); // create group if(identityService.createGroupQuery().groupId(Groups.CAMUNDA_ADMIN).count() == 0) { Group camundaAdminGroup = identityService.newGroup(Groups.CAMUNDA_ADMIN); camundaAdminGroup.setName("camunda BPM Administrators"); camundaAdminGroup.setType(Groups.GROUP_TYPE_SYSTEM); identityService.saveGroup(camundaAdminGroup); } // create ADMIN authorizations on all built-in resources for (Resource resource : Resources.values()) { if(authorizationService.createAuthorizationQuery().groupIdIn(Groups.CAMUNDA_ADMIN).resourceType(resource).resourceId(ANY).count() == 0) { AuthorizationEntity userAdminAuth = new AuthorizationEntity(AUTH_TYPE_GRANT); userAdminAuth.setGroupId(Groups.CAMUNDA_ADMIN); userAdminAuth.setResource(resource); userAdminAuth.setResourceId(ANY); userAdminAuth.addPermission(ALL); authorizationService.saveAuthorization(userAdminAuth); } } processEngine.getIdentityService() .createMembership("demo", Groups.CAMUNDA_ADMIN); } }
Example 3
Source File: CreateAdminUserConfiguration.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Override public void postProcessEngineBuild(final ProcessEngine processEngine) { requireNonNull(adminUser); final IdentityService identityService = processEngine.getIdentityService(); final AuthorizationService authorizationService = processEngine.getAuthorizationService(); if (userAlreadyExists(identityService, adminUser)) { return; } createUser(identityService, adminUser); // create group if (identityService.createGroupQuery().groupId(CAMUNDA_ADMIN).count() == 0) { Group camundaAdminGroup = identityService.newGroup(CAMUNDA_ADMIN); camundaAdminGroup.setName("camunda BPM Administrators"); camundaAdminGroup.setType(Groups.GROUP_TYPE_SYSTEM); identityService.saveGroup(camundaAdminGroup); } // create ADMIN authorizations on all built-in resources for (Resource resource : Resources.values()) { if (authorizationService.createAuthorizationQuery().groupIdIn(CAMUNDA_ADMIN).resourceType(resource).resourceId(ANY).count() == 0) { AuthorizationEntity userAdminAuth = new AuthorizationEntity(AUTH_TYPE_GRANT); userAdminAuth.setGroupId(CAMUNDA_ADMIN); userAdminAuth.setResource(resource); userAdminAuth.setResourceId(ANY); userAdminAuth.addPermission(ALL); authorizationService.saveAuthorization(userAdminAuth); } } identityService.createMembership(adminUser.getId(), CAMUNDA_ADMIN); LOG.creatingInitialAdminUser(adminUser); }
Example 4
Source File: GroupQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
private Group createGroup(String id, String name, String type) { Group group = identityService.newGroup(id); group.setName(name); group.setType(type); identityService.saveGroup(group); return group; }
Example 5
Source File: Application.java From camunda-spring-boot-amqp-microservice-cloud-example with Apache License 2.0 | 4 votes |
public static void createDefaultUser(ProcessEngine engine) { // and add default user to Camunda to be ready-to-go if (engine.getIdentityService().createUserQuery().userId("demo").count() == 0) { User user = engine.getIdentityService().newUser("demo"); user.setFirstName("Demo"); user.setLastName("Demo"); user.setPassword("demo"); user.setEmail("[email protected]"); engine.getIdentityService().saveUser(user); Group group = engine.getIdentityService().newGroup(Groups.CAMUNDA_ADMIN); group.setName("Administrators"); group.setType(Groups.GROUP_TYPE_SYSTEM); engine.getIdentityService().saveGroup(group); for (Resource resource : Resources.values()) { Authorization auth = engine.getAuthorizationService().createNewAuthorization(AUTH_TYPE_GRANT); auth.setGroupId(Groups.CAMUNDA_ADMIN); auth.addPermission(ALL); auth.setResourceId(ANY); auth.setResource(resource); engine.getAuthorizationService().saveAuthorization(auth); } engine.getIdentityService().createMembership("demo", Groups.CAMUNDA_ADMIN); } // create default "all tasks" filter if (engine.getFilterService().createFilterQuery().filterName("Alle").count() == 0) { Map<String, Object> filterProperties = new HashMap<String, Object>(); filterProperties.put("description", "Alle Aufgaben"); filterProperties.put("priority", 10); Filter filter = engine.getFilterService().newTaskFilter() // .setName("Alle") // .setProperties(filterProperties)// .setOwner("demo")// .setQuery(engine.getTaskService().createTaskQuery()); engine.getFilterService().saveFilter(filter); // and authorize demo user for it if (engine.getAuthorizationService().createAuthorizationQuery().resourceType(FILTER).resourceId(filter.getId()) // .userIdIn("demo").count() == 0) { Authorization managementGroupFilterRead = engine.getAuthorizationService().createNewAuthorization(Authorization.AUTH_TYPE_GRANT); managementGroupFilterRead.setResource(FILTER); managementGroupFilterRead.setResourceId(filter.getId()); managementGroupFilterRead.addPermission(ALL); managementGroupFilterRead.setUserId("demo"); engine.getAuthorizationService().saveAuthorization(managementGroupFilterRead); } } }
Example 6
Source File: IdentityServiceTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Test public void testFindGroupsByUserAndType() { Group sales = identityService.newGroup("sales"); sales.setType("hierarchy"); identityService.saveGroup(sales); Group development = identityService.newGroup("development"); development.setType("hierarchy"); identityService.saveGroup(development); Group admin = identityService.newGroup("admin"); admin.setType("security-role"); identityService.saveGroup(admin); Group user = identityService.newGroup("user"); user.setType("security-role"); identityService.saveGroup(user); User johndoe = identityService.newUser("johndoe"); identityService.saveUser(johndoe); User joesmoe = identityService.newUser("joesmoe"); identityService.saveUser(joesmoe); User jackblack = identityService.newUser("jackblack"); identityService.saveUser(jackblack); identityService.createMembership("johndoe", "sales"); identityService.createMembership("johndoe", "user"); identityService.createMembership("johndoe", "admin"); identityService.createMembership("joesmoe", "user"); List<Group> groups = identityService.createGroupQuery().groupMember("johndoe").groupType("security-role").list(); Set<String> groupIds = getGroupIds(groups); Set<String> expectedGroupIds = new HashSet<String>(); expectedGroupIds.add("user"); expectedGroupIds.add("admin"); assertEquals(expectedGroupIds, groupIds); groups = identityService.createGroupQuery().groupMember("joesmoe").groupType("security-role").list(); groupIds = getGroupIds(groups); expectedGroupIds = new HashSet<String>(); expectedGroupIds.add("user"); assertEquals(expectedGroupIds, groupIds); groups = identityService.createGroupQuery().groupMember("jackblack").groupType("security-role").list(); assertTrue(groups.isEmpty()); identityService.deleteGroup("sales"); identityService.deleteGroup("development"); identityService.deleteGroup("admin"); identityService.deleteGroup("user"); identityService.deleteUser("johndoe"); identityService.deleteUser("joesmoe"); identityService.deleteUser("jackblack"); }
Example 7
Source File: GroupDto.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public void update(Group dbGroup) { dbGroup.setId(id); dbGroup.setName(name); dbGroup.setType(type); }