org.flowable.engine.IdentityService Java Examples

The following examples show how to use org.flowable.engine.IdentityService. 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: CreateUserAndMembershipTestDelegate.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
public void execute(DelegateExecution execution) {

    ManagementService managementService = Context.getProcessEngineConfiguration().getManagementService();
    managementService.executeCommand(new Command<Void>() {
        @Override
        public Void execute(CommandContext commandContext) {
            return null;
        }
    });

    IdentityService identityService = Context.getProcessEngineConfiguration().getIdentityService();

    String username = "Kermit";
    User user = identityService.newUser(username);
    user.setPassword("123");
    user.setFirstName("Manually");
    user.setLastName("created");
    identityService.saveUser(user);

    // Add admin group
    Group group = identityService.newGroup("admin");
    identityService.saveGroup(group);

    identityService.createMembership(username, "admin");
}
 
Example #2
Source File: Application.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Bean
InitializingBean usersAndGroupsInitializer(final IdentityService identityService) {

    return new InitializingBean() {
        @Override
        public void afterPropertiesSet() throws Exception {

            // install groups & users
            Group group = identityService.newGroup("user");
            group.setName("users");
            group.setType("security-role");
            identityService.saveGroup(group);

            User josh = identityService.newUser("jlong");
            josh.setFirstName("Josh");
            josh.setLastName("Long");
            josh.setPassword("password");
            identityService.saveUser(josh);

            identityService.createMembership("jlong", "user");
        }
    };
}
 
Example #3
Source File: FlowableComponent.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void setCamelContext(CamelContext context) {
    super.setCamelContext(context);
    identityService = getByType(context, IdentityService.class);
    runtimeService = getByType(context, RuntimeService.class);
    repositoryService = getByType(context, RepositoryService.class);
    managementService = getByType(context, ManagementService.class);
}
 
Example #4
Source File: IdmTransactionsTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void notify(DelegateTask delegateTask) {
    IdentityService identityService = Context.getProcessEngineConfiguration().getIdentityService();
    User user = identityService.newUser("Kermit");
    user.setFirstName("Mr");
    user.setLastName("Kermit");
    identityService.saveUser(user);
}
 
Example #5
Source File: Sample15RestApplication.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Bean
public CommandLineRunner usersAndGroupsInitializer(final IdentityService identityService) {
    return args -> {
        // install groups & users
        Group group = identityService.newGroup("user");
        group.setName("users");
        group.setType("security-role");
        identityService.saveGroup(group);

        User joram = identityService.newUser("jbarrez");
        joram.setFirstName("Joram");
        joram.setLastName("Barrez");
        joram.setPassword("password");
        identityService.saveUser(joram);

        User filip = identityService.newUser("filiphr");
        filip.setFirstName("Filip");
        filip.setLastName("Hrisafov");
        filip.setPassword("password");
        identityService.saveUser(filip);

        User josh = identityService.newUser("jlong");
        josh.setFirstName("Josh");
        josh.setLastName("Long");
        josh.setPassword("password");
        identityService.saveUser(josh);

        identityService.createMembership("jbarrez", "user");
        identityService.createMembership("filiphr", "user");
        identityService.createMembership("jlong", "user");
    };
}
 
Example #6
Source File: BaseSpringRestTestCase.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected void dropUsers() {
    IdentityService identityService = processEngine.getIdentityService();

    identityService.deleteUser("kermit");
    identityService.deleteGroup("admin");
    identityService.deleteMembership("kermit", "admin");
    
    identityService.deleteUser("aSalesUser");
    identityService.deleteGroup("sales");
    identityService.deleteMembership("aSalesUser", "sales");
}
 
Example #7
Source File: SerializableVariablesDiabledTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Before
public void setupServer() {
    if (serverUrlPrefix == null) {
        TestServer testServer = TestServerUtil.createAndStartServer(ObjectVariableSerializationDisabledApplicationConfiguration.class);
        serverUrlPrefix = testServer.getServerUrlPrefix();

        this.repositoryService = testServer.getApplicationContext().getBean(RepositoryService.class);
        this.runtimeService = testServer.getApplicationContext().getBean(RuntimeService.class);
        this.identityService = testServer.getApplicationContext().getBean(IdentityService.class);
        this.taskService = testServer.getApplicationContext().getBean(TaskService.class);

        User user = identityService.newUser("kermit");
        user.setFirstName("Kermit");
        user.setLastName("the Frog");
        user.setPassword("kermit");
        identityService.saveUser(user);

        Group group = identityService.newGroup("admin");
        group.setName("Administrators");
        identityService.saveGroup(group);

        identityService.createMembership(user.getId(), group.getId());

        this.testUserId = user.getId();
        this.testGroupId = group.getId();
    }
}
 
Example #8
Source File: GetPotentialStarterGroupsCmd.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public List<Group> execute(CommandContext commandContext) {
    ProcessDefinitionEntity processDefinition = CommandContextUtil.getProcessDefinitionEntityManager(commandContext).findById(processDefinitionId);

    if (processDefinition == null) {
        throw new FlowableObjectNotFoundException("Cannot find process definition with id " + processDefinitionId, ProcessDefinition.class);
    }

    IdentityService identityService = CommandContextUtil.getProcessEngineConfiguration(commandContext).getIdentityService();

    List<String> groupIds = new ArrayList<>();
    List<IdentityLink> identityLinks = (List) processDefinition.getIdentityLinks();
    for (IdentityLink identityLink : identityLinks) {
        if (identityLink.getGroupId() != null && identityLink.getGroupId().length() > 0) {

            if (!groupIds.contains(identityLink.getGroupId())) {
                groupIds.add(identityLink.getGroupId());
            }
        }
    }

    if (groupIds.size() > 0) {
        return identityService.createGroupQuery().groupIds(groupIds).list();

    } else {
        return new ArrayList<>();
    }
}
 
Example #9
Source File: SpringIdmTransactionsTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void notify(DelegateTask delegateTask) {
    IdentityService identityService = Context.getProcessEngineConfiguration().getIdentityService();
    User user = identityService.newUser("Kermit");
    user.setFirstName("Mr");
    user.setLastName("Kermit");
    identityService.saveUser(user);
}
 
Example #10
Source File: SpringIdmTransactionsTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(DelegateExecution execution) {

    ManagementService managementService = Context.getProcessEngineConfiguration().getManagementService();
    managementService.executeCommand(new Command<Void>() {

        @Override
        public Void execute(CommandContext commandContext) {
            return null;
        }
    });

    IdentityService identityService = Context.getProcessEngineConfiguration().getIdentityService();

    String username = "Kermit";
    User user = identityService.newUser(username);
    user.setPassword("123");
    user.setFirstName("Manually");
    user.setLastName("created");
    identityService.saveUser(user);

    // Add admin group
    Group group = identityService.newGroup("admin");
    identityService.saveGroup(group);

    identityService.createMembership(username, "admin");
}
 
Example #11
Source File: GetPotentialStarterUsersCmd.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public List<User> execute(CommandContext commandContext) {
    ProcessDefinitionEntity processDefinition = CommandContextUtil.getProcessDefinitionEntityManager(commandContext).findById(processDefinitionId);

    if (processDefinition == null) {
        throw new FlowableObjectNotFoundException("Cannot find process definition with id " + processDefinitionId, ProcessDefinition.class);
    }

    IdentityService identityService = CommandContextUtil.getProcessEngineConfiguration(commandContext).getIdentityService();

    List<String> userIds = new ArrayList<>();
    List<IdentityLink> identityLinks = (List) processDefinition.getIdentityLinks();
    for (IdentityLink identityLink : identityLinks) {
        if (identityLink.getUserId() != null && identityLink.getUserId().length() > 0) {

            if (!userIds.contains(identityLink.getUserId())) {
                userIds.add(identityLink.getUserId());
            }
        }
    }

    if (userIds.size() > 0) {
        return identityService.createUserQuery().userIds(userIds).list();

    } else {
        return new ArrayList<>();
    }
}
 
Example #12
Source File: EngineConfiguration.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Bean
public IdentityService identityService(ProcessEngine processEngine) {
    return processEngine.getIdentityService();
}
 
Example #13
Source File: DomainProcessEngine.java    From syncope with Apache License 2.0 4 votes vote down vote up
@Override
public IdentityService getIdentityService() {
    return engines.get(AuthContextUtils.getDomain()).getIdentityService();
}
 
Example #14
Source File: FlowableServices.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Produces
@Named
@ApplicationScoped
public IdentityService identityService() {
    return processEngine().getIdentityService();
}
 
Example #15
Source File: FlowableRule.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public void setIdentityService(IdentityService identityService) {
    this.identityService = identityService;
}
 
Example #16
Source File: FlowableRule.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public IdentityService getIdentityService() {
    return identityService;
}
 
Example #17
Source File: ProcessEngineImpl.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public IdentityService getIdentityService() {
    return identityService;
}
 
Example #18
Source File: RestResponseFactory.java    From plumdo-work with Apache License 2.0 4 votes vote down vote up
@Autowired
public RestResponseFactory(ObjectMapper objectMapper, IdentityService identityService) {
    initializeVariableConverters();
    this.objectMapper = objectMapper;
    this.identityService = identityService;
}
 
Example #19
Source File: JPAFlowableEngineConfiguration.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Bean
public IdentityService identityService(ProcessEngine processEngine) {
    return processEngine.getIdentityService();
}
 
Example #20
Source File: ProcessEngineServicesAutoConfiguration.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public IdentityService identityServiceBean(ProcessEngine processEngine) {
    return processEngine.getIdentityService();
}
 
Example #21
Source File: ActivitiRule.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public void setIdentityService(IdentityService identityService) {
    this.identityService = identityService;
}
 
Example #22
Source File: ActivitiRule.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public IdentityService getIdentityService() {
    return identityService;
}
 
Example #23
Source File: FlowableEndpoint.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public void setIdentityService(IdentityService identityService) {
    this.identityService = identityService;
}
 
Example #24
Source File: FlowableProducer.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public void setIdentityService(IdentityService identityService) {
    this.identityService = identityService;
}