Java Code Examples for org.camunda.bpm.engine.AuthorizationService#saveAuthorization()
The following examples show how to use
org.camunda.bpm.engine.AuthorizationService#saveAuthorization() .
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: PurgeDatabaseTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
private void createAuthenticationData() { IdentityService identityService = engineRule.getIdentityService(); Group group = identityService.newGroup("group"); identityService.saveGroup(group); User user = identityService.newUser("user"); User user2 = identityService.newUser("user2"); identityService.saveUser(user); identityService.saveUser(user2); Tenant tenant = identityService.newTenant("tenant"); identityService.saveTenant(tenant); Tenant tenant2 = identityService.newTenant("tenant2"); identityService.saveTenant(tenant2); identityService.createMembership("user", "group"); identityService.createTenantUserMembership("tenant", "user"); identityService.createTenantUserMembership("tenant2", "user2"); Resource resource1 = TestResource.RESOURCE1; // create global authorization which grants all permissions to all users (on resource1): AuthorizationService authorizationService = engineRule.getAuthorizationService(); Authorization globalAuth = authorizationService.createNewAuthorization(AUTH_TYPE_GLOBAL); globalAuth.setResource(resource1); globalAuth.setResourceId(ANY); globalAuth.addPermission(TestPermissions.ALL); authorizationService.saveAuthorization(globalAuth); //grant user read auth on resource2 Resource resource2 = TestResource.RESOURCE2; Authorization userGrant = authorizationService.createNewAuthorization(AUTH_TYPE_GRANT); userGrant.setUserId("user"); userGrant.setResource(resource2); userGrant.setResourceId(ANY); userGrant.addPermission(TestPermissions.READ); authorizationService.saveAuthorization(userGrant); identityService.setAuthenticatedUserId("user"); }
Example 5
Source File: AuthorizationPerformanceTestCase.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
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); }
Example 6
Source File: AuthorizationPerformanceTestCase.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
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); }
Example 7
Source File: AuthorizationRestServiceImpl.java From camunda-bpm-platform with Apache License 2.0 | 3 votes |
public AuthorizationDto createAuthorization(UriInfo context, AuthorizationCreateDto dto) { final AuthorizationService authorizationService = processEngine.getAuthorizationService(); Authorization newAuthorization = authorizationService.createNewAuthorization(dto.getType()); AuthorizationCreateDto.update(dto, newAuthorization, processEngine.getProcessEngineConfiguration()); newAuthorization = authorizationService.saveAuthorization(newAuthorization); return getAuthorization(newAuthorization.getId()).getAuthorization(context); }