org.flowable.idm.spring.SpringIdmEngineConfiguration Java Examples

The following examples show how to use org.flowable.idm.spring.SpringIdmEngineConfiguration. 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: DomainProcessEngineFactoryBean.java    From syncope with Apache License 2.0 6 votes vote down vote up
private ProcessEngine build(final String domain, final DataSource datasource) {
    PlatformTransactionManager transactionManager = ctx.getBean(
            domain + "TransactionManager", PlatformTransactionManager.class);
    Object entityManagerFactory = ctx.getBean(domain + "EntityManagerFactory");

    DomainProcessEngineConfiguration conf = ctx.getBean(DomainProcessEngineConfiguration.class);
    conf.setDataSource(datasource);
    conf.setTransactionManager(transactionManager);
    conf.setTransactionsExternallyManaged(true);
    conf.setJpaEntityManagerFactory(entityManagerFactory);
    if (conf.getBeans() == null) {
        conf.setBeans(new SpringBeanFactoryProxyMap(ctx));
    }
    if (conf.getExpressionManager() == null) {
        conf.setExpressionManager(new SpringExpressionManager(ctx, conf.getBeans()));
    }
    if (EngineServiceUtil.getIdmEngineConfiguration(conf) == null) {
        conf.addEngineConfiguration(
                EngineConfigurationConstants.KEY_IDM_ENGINE_CONFIG,
                ctx.getBean(SpringIdmEngineConfiguration.class));
    }
    conf.setEnableSafeBpmnXml(true);
    conf.setCustomFormTypes(List.of(new DropdownFormType(null)));

    return conf.buildProcessEngine();
}
 
Example #2
Source File: IdmEngineAutoConfigurationTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Test
public void standaloneIdmEngineWithBasicDataSource() {
    contextRunner.run(context -> {
        assertThat(context)
            .doesNotHaveBean(AppEngine.class)
            .doesNotHaveBean(ProcessEngine.class)
            .doesNotHaveBean("idmProcessEngineConfigurationConfigurer")
            .doesNotHaveBean("idmAppEngineConfigurationConfigurer");
        IdmEngine idmEngine = context.getBean(IdmEngine.class);
        assertThat(idmEngine).as("Idm engine").isNotNull();
        assertAllServicesPresent(context, idmEngine);

        assertThat(context).hasSingleBean(CustomUserEngineConfigurerConfiguration.class)
            .hasSingleBean(PasswordEncoder.class)
            .getBean(CustomUserEngineConfigurerConfiguration.class)
            .satisfies(configuration -> {
                assertThat(configuration.getInvokedConfigurations())
                    .containsExactly(
                        SpringIdmEngineConfiguration.class
                    );
            });

        org.flowable.idm.api.PasswordEncoder flowablePasswordEncoder = idmEngine.getIdmEngineConfiguration().getPasswordEncoder();
        PasswordEncoder passwordEncoder = context.getBean(PasswordEncoder.class);
        assertThat(flowablePasswordEncoder)
            .isInstanceOfSatisfying(SpringEncoder.class, springEncoder -> {
                assertThat(springEncoder.getSpringEncodingProvider()).isEqualTo(passwordEncoder);
            });
        assertThat(passwordEncoder).isInstanceOf(NoOpPasswordEncoder.class);
    });
}
 
Example #3
Source File: WorkflowFlowableContext.java    From syncope with Apache License 2.0 5 votes vote down vote up
@ConditionalOnMissingBean
@Bean
public SpringIdmEngineConfiguration syncopeIdmEngineConfiguration() {
    SpringIdmEngineConfiguration conf = new SpringIdmEngineConfiguration();
    conf.setIdmIdentityService(syncopeIdmIdentityService());
    return conf;
}
 
Example #4
Source File: EngineConfiguration.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Bean(name = "idmEngineConfiguration")
public IdmEngineConfiguration idmEngineConfiguration(DataSource dataSource, PlatformTransactionManager transactionManager) {
    SpringIdmEngineConfiguration configuration = new SpringIdmEngineConfiguration();
    configuration.setDataSource(dataSource);
    configuration.setDatabaseSchemaUpdate(EventRegistryEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
    configuration.setTransactionManager(transactionManager);
    return configuration;
}
 
Example #5
Source File: AppEngineAutoConfigurationTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Test
public void standaloneAppEngineWithBasicDatasourceAndCustomAutoDeploymentStrategies() {
    contextRunner
        .withUserConfiguration(CustomAutoDeploymentStrategyConfiguration.class)
        .run(context -> {
            AppEngine appEngine = context.getBean(AppEngine.class);
            assertThat(appEngine).as("App engine").isNotNull();

            assertAllServicesPresent(context, appEngine);
            assertAutoDeployment(context);

            SpringAppEngineConfiguration engineConfiguration = (SpringAppEngineConfiguration) appEngine.getAppEngineConfiguration();
            Collection<AutoDeploymentStrategy<AppEngine>> deploymentStrategies = engineConfiguration.getDeploymentStrategies();

            assertThat(deploymentStrategies).element(0)
                .isInstanceOf(TestAppEngineAutoDeploymentStrategy.class);

            assertThat(deploymentStrategies).element(1)
                .isInstanceOfSatisfying(DefaultAutoDeploymentStrategy.class, strategy -> {
                    assertThat(strategy.isUseLockForDeployments()).isFalse();
                    assertThat(strategy.getDeploymentLockWaitTime()).isEqualTo(Duration.ofMinutes(5));
                });

            deleteDeployments(appEngine);

            assertThat(context).hasSingleBean(CustomUserEngineConfigurerConfiguration.class)
                .getBean(CustomUserEngineConfigurerConfiguration.class)
                .satisfies(configuration -> {
                    assertThat(configuration.getInvokedConfigurations())
                        .containsExactly(
                            SpringIdmEngineConfiguration.class,
                            SpringAppEngineConfiguration.class
                        );
                });
        });
}
 
Example #6
Source File: AppEngineAutoConfigurationTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Test
public void standaloneAppEngineWithBasicDatasourceAndAutoDeploymentWithLocking() {
    contextRunner
        .withPropertyValues(
            "flowable.auto-deployment.engine.app.use-lock=true",
            "flowable.auto-deployment.engine.app.lock-wait-time=10m",
            "flowable.auto-deployment.engine.app.throw-exception-on-deployment-failure=false",
            "flowable.auto-deployment.engine.app.lock-name=testLock"
        )
        .run(context -> {
            AppEngine appEngine = context.getBean(AppEngine.class);
            assertThat(appEngine).as("App engine").isNotNull();

            assertAllServicesPresent(context, appEngine);
            assertAutoDeployment(context);

            SpringAppEngineConfiguration engineConfiguration = (SpringAppEngineConfiguration) appEngine.getAppEngineConfiguration();
            Collection<AutoDeploymentStrategy<AppEngine>> deploymentStrategies = engineConfiguration.getDeploymentStrategies();

            assertThat(deploymentStrategies).element(0)
                .isInstanceOfSatisfying(DefaultAutoDeploymentStrategy.class, strategy -> {
                    assertThat(strategy.isUseLockForDeployments()).isTrue();
                    assertThat(strategy.getDeploymentLockWaitTime()).isEqualTo(Duration.ofMinutes(10));
                    assertThat(strategy.isThrowExceptionOnDeploymentFailure()).isFalse();
                    assertThat(strategy.getLockName()).isEqualTo("testLock");
                });

            deleteDeployments(appEngine);

            assertThat(context).hasSingleBean(CustomUserEngineConfigurerConfiguration.class)
                .getBean(CustomUserEngineConfigurerConfiguration.class)
                .satisfies(configuration -> {
                    assertThat(configuration.getInvokedConfigurations())
                        .containsExactly(
                            SpringIdmEngineConfiguration.class,
                            SpringAppEngineConfiguration.class
                        );
                });
        });
}
 
Example #7
Source File: FlowableIdmConfig.java    From plumdo-work with Apache License 2.0 5 votes vote down vote up
@Autowired
public SpringIdmEngineConfiguration idmEngineConfiguration(DataSource dataSource, PlatformTransactionManager platformTransactionManager) {
    SpringIdmEngineConfiguration configuration = super.idmEngineConfiguration(dataSource, platformTransactionManager);
    configuration.setGroupEntityManager(new AiaGroupEntityManager(restClient, configuration, configuration.getGroupDataManager()));
    configuration.setUserEntityManager(new AiaUserEntityManager(restClient, configuration, configuration.getUserDataManager()));
    return configuration;
}
 
Example #8
Source File: FlowableLdapAutoConfiguration.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected LDAPGroupCache createCache(SpringIdmEngineConfiguration engineConfiguration, LDAPConfiguration ldapConfiguration) {
    LDAPGroupCache ldapGroupCache = null;
    if (ldapConfiguration.getGroupCacheSize() > 0) {
        // We need to use a supplier for the clock as the clock would be created later
        ldapGroupCache = new LDAPGroupCache(ldapConfiguration.getGroupCacheSize(),
            ldapConfiguration.getGroupCacheExpirationTime(), engineConfiguration::getClock);

        if (ldapConfiguration.getGroupCacheListener() != null) {
            ldapGroupCache.setLdapCacheListener(ldapConfiguration.getGroupCacheListener());
        }
    }
    return ldapGroupCache;
}
 
Example #9
Source File: IdmEngineAutoConfiguration.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public SpringIdmEngineConfiguration idmEngineConfiguration(DataSource dataSource, PlatformTransactionManager platformTransactionManager) {
    SpringIdmEngineConfiguration configuration = new SpringIdmEngineConfiguration();

    configuration.setTransactionManager(platformTransactionManager);
    configureEngine(configuration, dataSource);

    return configuration;
}
 
Example #10
Source File: IdmEngineServicesAutoConfiguration.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Bean
public IdmEngineFactoryBean idmEngine(SpringIdmEngineConfiguration idmEngineConfiguration) {
    IdmEngineFactoryBean factory = new IdmEngineFactoryBean();
    factory.setIdmEngineConfiguration(idmEngineConfiguration);
    
    invokeConfigurers(idmEngineConfiguration);
    
    return factory;
}
 
Example #11
Source File: CmmnEngineAutoConfigurationTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Test
public void standaloneCmmnEngineWithBasicDataSourceAndAutoDeploymentWithLocking() {
    contextRunner
        .withPropertyValues(
            "flowable.auto-deployment.engine.cmmn.use-lock=true",
            "flowable.auto-deployment.engine.cmmn.lock-wait-time=10m",
            "flowable.auto-deployment.engine.cmmn.throw-exception-on-deployment-failure=false",
            "flowable.auto-deployment.engine.cmmn.lock-name=testLock"
        )
        .run(context -> {
            assertThat(context)
                .doesNotHaveBean(AppEngine.class)
                .doesNotHaveBean(ProcessEngine.class)
                .doesNotHaveBean("cmmnProcessEngineConfigurationConfigurer")
                .doesNotHaveBean("cmmnAppEngineConfigurationConfigurer");
            CmmnEngine cmmnEngine = context.getBean(CmmnEngine.class);
            assertThat(cmmnEngine).as("Cmmn engine").isNotNull();

            assertAllServicesPresent(context, cmmnEngine);

            assertAutoDeployment(context);

            assertThat(context).hasSingleBean(CustomUserEngineConfigurerConfiguration.class)
                .getBean(CustomUserEngineConfigurerConfiguration.class)
                .satisfies(configuration -> {
                    assertThat(configuration.getInvokedConfigurations())
                        .containsExactlyInAnyOrder(
                            SpringCmmnEngineConfiguration.class,
                            SpringIdmEngineConfiguration.class
                        );
                });

            SpringCmmnEngineConfiguration engineConfiguration = (SpringCmmnEngineConfiguration) cmmnEngine.getCmmnEngineConfiguration();
            Collection<AutoDeploymentStrategy<CmmnEngine>> deploymentStrategies = engineConfiguration.getDeploymentStrategies();

            assertThat(deploymentStrategies).element(0)
                .isInstanceOfSatisfying(DefaultAutoDeploymentStrategy.class, strategy -> {
                    assertThat(strategy.isUseLockForDeployments()).isTrue();
                    assertThat(strategy.getDeploymentLockWaitTime()).isEqualTo(Duration.ofMinutes(10));
                    assertThat(strategy.isThrowExceptionOnDeploymentFailure()).isFalse();
                    assertThat(strategy.getLockName()).isEqualTo("testLock");
                });

            assertThat(deploymentStrategies).element(1)
                .isInstanceOfSatisfying(SingleResourceAutoDeploymentStrategy.class, strategy -> {
                    assertThat(strategy.isUseLockForDeployments()).isTrue();
                    assertThat(strategy.getDeploymentLockWaitTime()).isEqualTo(Duration.ofMinutes(10));
                    assertThat(strategy.isThrowExceptionOnDeploymentFailure()).isFalse();
                    assertThat(strategy.getLockName()).isEqualTo("testLock");
                });

            assertThat(deploymentStrategies).element(2)
                .isInstanceOfSatisfying(ResourceParentFolderAutoDeploymentStrategy.class, strategy -> {
                    assertThat(strategy.isUseLockForDeployments()).isTrue();
                    assertThat(strategy.getDeploymentLockWaitTime()).isEqualTo(Duration.ofMinutes(10));
                    assertThat(strategy.isThrowExceptionOnDeploymentFailure()).isFalse();
                    assertThat(strategy.getLockName()).isEqualTo("testLock");
                });

            deleteDeployments(cmmnEngine);
        });
}
 
Example #12
Source File: CmmnEngineAutoConfigurationTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Test
public void standaloneCmmnEngineWithBasicDataSourceAndCustomAutoDeploymentStrategies() {
    contextRunner
        .withUserConfiguration(CustomAutoDeploymentStrategyConfiguration.class)
        .withPropertyValues("flowable.auto-deployment.lock-wait-time=10m")
        .run(context -> {
            assertThat(context)
                .doesNotHaveBean(AppEngine.class)
                .doesNotHaveBean(ProcessEngine.class)
                .doesNotHaveBean("cmmnProcessEngineConfigurationConfigurer")
                .doesNotHaveBean("cmmnAppEngineConfigurationConfigurer");
            CmmnEngine cmmnEngine = context.getBean(CmmnEngine.class);
            assertThat(cmmnEngine).as("Cmmn engine").isNotNull();

            assertAllServicesPresent(context, cmmnEngine);

            assertAutoDeployment(context);

            assertThat(context).hasSingleBean(CustomUserEngineConfigurerConfiguration.class)
                .getBean(CustomUserEngineConfigurerConfiguration.class)
                .satisfies(configuration -> {
                    assertThat(configuration.getInvokedConfigurations())
                        .containsExactlyInAnyOrder(
                            SpringCmmnEngineConfiguration.class,
                            SpringIdmEngineConfiguration.class
                        );
                });

            SpringCmmnEngineConfiguration engineConfiguration = (SpringCmmnEngineConfiguration) cmmnEngine.getCmmnEngineConfiguration();
            Collection<AutoDeploymentStrategy<CmmnEngine>> deploymentStrategies = engineConfiguration.getDeploymentStrategies();

            assertThat(deploymentStrategies).element(0)
                .isInstanceOf(TestCmmnEngineAutoDeploymentStrategy.class);
            assertThat(deploymentStrategies).element(1)
                .isInstanceOfSatisfying(DefaultAutoDeploymentStrategy.class, strategy -> {
                    assertThat(strategy.isUseLockForDeployments()).isFalse();
                    assertThat(strategy.getDeploymentLockWaitTime()).isEqualTo(Duration.ofMinutes(10));
                });

            assertThat(deploymentStrategies).element(2)
                .isInstanceOfSatisfying(SingleResourceAutoDeploymentStrategy.class, strategy -> {
                    assertThat(strategy.isUseLockForDeployments()).isFalse();
                    assertThat(strategy.getDeploymentLockWaitTime()).isEqualTo(Duration.ofMinutes(10));
                });

            assertThat(deploymentStrategies).element(3)
                .isInstanceOfSatisfying(ResourceParentFolderAutoDeploymentStrategy.class, strategy -> {
                    assertThat(strategy.isUseLockForDeployments()).isFalse();
                    assertThat(strategy.getDeploymentLockWaitTime()).isEqualTo(Duration.ofMinutes(10));
                });

            deleteDeployments(cmmnEngine);
        });
}
 
Example #13
Source File: CmmnEngineAutoConfigurationTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Test
public void standaloneCmmnEngineWithBasicDataSource() {
    contextRunner.run(context -> {
        assertThat(context)
            .doesNotHaveBean(AppEngine.class)
            .doesNotHaveBean(ProcessEngine.class)
            .doesNotHaveBean("cmmnProcessEngineConfigurationConfigurer")
            .doesNotHaveBean("cmmnAppEngineConfigurationConfigurer");
        CmmnEngine cmmnEngine = context.getBean(CmmnEngine.class);
        assertThat(cmmnEngine).as("Cmmn engine").isNotNull();

        assertAllServicesPresent(context, cmmnEngine);

        assertAutoDeployment(context);

        assertThat(context).hasSingleBean(CustomUserEngineConfigurerConfiguration.class)
            .getBean(CustomUserEngineConfigurerConfiguration.class)
            .satisfies(configuration -> {
                assertThat(configuration.getInvokedConfigurations())
                    .containsExactlyInAnyOrder(
                        SpringCmmnEngineConfiguration.class,
                        SpringIdmEngineConfiguration.class
                    );
            });

        SpringCmmnEngineConfiguration engineConfiguration = (SpringCmmnEngineConfiguration) cmmnEngine.getCmmnEngineConfiguration();
        Collection<AutoDeploymentStrategy<CmmnEngine>> deploymentStrategies = engineConfiguration.getDeploymentStrategies();

        assertThat(deploymentStrategies).element(0)
            .isInstanceOfSatisfying(DefaultAutoDeploymentStrategy.class, strategy -> {
                assertThat(strategy.isUseLockForDeployments()).isFalse();
                assertThat(strategy.getDeploymentLockWaitTime()).isEqualTo(Duration.ofMinutes(5));
                assertThat(strategy.isThrowExceptionOnDeploymentFailure()).isTrue();
                assertThat(strategy.getLockName()).isNull();
            });

        assertThat(deploymentStrategies).element(1)
            .isInstanceOfSatisfying(SingleResourceAutoDeploymentStrategy.class, strategy -> {
                assertThat(strategy.isUseLockForDeployments()).isFalse();
                assertThat(strategy.getDeploymentLockWaitTime()).isEqualTo(Duration.ofMinutes(5));
                assertThat(strategy.isThrowExceptionOnDeploymentFailure()).isTrue();
                assertThat(strategy.getLockName()).isNull();
            });

        assertThat(deploymentStrategies).element(2)
            .isInstanceOfSatisfying(ResourceParentFolderAutoDeploymentStrategy.class, strategy -> {
                assertThat(strategy.isUseLockForDeployments()).isFalse();
                assertThat(strategy.getDeploymentLockWaitTime()).isEqualTo(Duration.ofMinutes(5));
                assertThat(strategy.isThrowExceptionOnDeploymentFailure()).isTrue();
                assertThat(strategy.getLockName()).isNull();
            });

        deleteDeployments(cmmnEngine);
    });
}
 
Example #14
Source File: AppEngineAutoConfigurationTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Test
public void standaloneAppEngineWithBasicDatasource() {
    contextRunner
        .run(context -> {
            AppEngine appEngine = context.getBean(AppEngine.class);
            assertThat(appEngine).as("App engine").isNotNull();

            assertAllServicesPresent(context, appEngine);
            assertAutoDeployment(context);

            SpringAppEngineConfiguration engineConfiguration = (SpringAppEngineConfiguration) appEngine.getAppEngineConfiguration();
            Collection<AutoDeploymentStrategy<AppEngine>> deploymentStrategies = engineConfiguration.getDeploymentStrategies();

            assertThat(deploymentStrategies).element(0)
                .isInstanceOfSatisfying(DefaultAutoDeploymentStrategy.class, strategy -> {
                    assertThat(strategy.isUseLockForDeployments()).isFalse();
                    assertThat(strategy.getDeploymentLockWaitTime()).isEqualTo(Duration.ofMinutes(5));
                    assertThat(strategy.isThrowExceptionOnDeploymentFailure()).isTrue();
                    assertThat(strategy.getLockName()).isNull();
                });

            deleteDeployments(appEngine);

            assertThat(engineConfiguration.getEngineConfigurations())
                    .containsOnlyKeys(
                            EngineConfigurationConstants.KEY_APP_ENGINE_CONFIG,
                            EngineConfigurationConstants.KEY_EVENT_REGISTRY_CONFIG,
                            EngineConfigurationConstants.KEY_IDM_ENGINE_CONFIG
                    );

            assertThat(context).hasSingleBean(CustomUserEngineConfigurerConfiguration.class)
                .getBean(CustomUserEngineConfigurerConfiguration.class)
                .satisfies(configuration -> {
                    assertThat(configuration.getInvokedConfigurations())
                        .containsExactly(
                            SpringIdmEngineConfiguration.class,
                            SpringAppEngineConfiguration.class
                        );
                });
        });
}
 
Example #15
Source File: FlowableLdapAutoConfiguration.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Bean
public EngineConfigurationConfigurer<SpringIdmEngineConfiguration> ldapIdmEngineConfigurer(LDAPConfiguration ldapConfiguration) {
    return idmEngineConfiguration -> idmEngineConfiguration
        .setIdmIdentityService(new LDAPIdentityServiceImpl(ldapConfiguration, createCache(idmEngineConfiguration, ldapConfiguration)));
}
 
Example #16
Source File: CustomUserEngineConfigurerConfiguration.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Bean
public EngineConfigurationConfigurer<SpringIdmEngineConfiguration> customUserSpringIdmEngineConfigurer() {
    return this::configurationInvoked;
}
 
Example #17
Source File: SpringIdmEngineConfigurator.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public SpringIdmEngineConfigurator setIdmEngineConfiguration(SpringIdmEngineConfiguration idmEngineConfiguration) {
    this.idmEngineConfiguration = idmEngineConfiguration;
    return this;
}
 
Example #18
Source File: IdmEngineAutoConfiguration.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnBean(PasswordEncoder.class)
@ConditionalOnMissingBean(name = "passwordEncoderIdmEngineConfigurationConfigurer")
public EngineConfigurationConfigurer<SpringIdmEngineConfiguration> passwordEncoderIdmEngineConfigurationConfigurer(PasswordEncoder passwordEncoder) {
    return idmEngineConfiguration -> idmEngineConfiguration.setPasswordEncoder(new SpringEncoder(passwordEncoder));
}