public static UserInfo getUserInfo() { UserInfo userInfo = new DefaultUserInfo(true); if ("ldap".equalsIgnoreCase(USER_INFO_IMPL)) { userInfo = new LDAPUserInfoImpl(true); } else if ("db".equalsIgnoreCase(USER_INFO_IMPL)) { userInfo = new DBUserInfoImpl(true); } else if ("props".equalsIgnoreCase(USER_INFO_IMPL)) { userInfo = new PropertyUserInfoImpl(true); } else if ("custom".equalsIgnoreCase(USER_INFO_IMPL)) { try { userInfo = (UserInfo) Class.forName(CUSTOM_USER_INFO_IMPL).newInstance(); } catch (Exception e) { throw new RuntimeException("Unable to create instance of custom user info impl", e); } } return userInfo; } }
public PropertyUserInfoImpl(boolean activate) { // use as no-arg constructor super(new Properties()); try { String propertiesLocation = System.getProperty("jbpm.user.info.properties"); Properties registryProps = readProperties(propertiesLocation, DEFAULT_USER_PROPS_LOCATION); buildRegistry(registryProps); } catch (Exception e) { throw new IllegalStateException("Problem loading userinfo properties", e); } }
@Test public void testRuntimeEnvironmentUserInfo() { UserInfo userInfo = new PropertyUserInfoImpl(true); EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.persistence.jpa"); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get() .newDefaultBuilder() .entityManagerFactory(emf) .userInfo(userInfo) .get(); LocalTaskServiceFactory factory = new LocalTaskServiceFactory(environment); InternalTaskService service = (InternalTaskService) factory.newTaskService(); // we should get the same instance provided in the environment Assert.assertTrue(service.getUserInfo().equals(userInfo)); }
public static UserInfo getUserInfo() { UserInfo userInfo = new DefaultUserInfo(true); if ("ldap".equalsIgnoreCase(USER_INFO_IMPL)) { userInfo = new LDAPUserInfoImpl(true); } else if ("db".equalsIgnoreCase(USER_INFO_IMPL)) { userInfo = new DBUserInfoImpl(true); } else if ("props".equalsIgnoreCase(USER_INFO_IMPL)) { userInfo = new PropertyUserInfoImpl(true); } else if ("custom".equalsIgnoreCase(USER_INFO_IMPL)) { try { userInfo = (UserInfo) Class.forName(CUSTOM_USER_INFO_IMPL).newInstance(); } catch (Exception e) { throw new RuntimeException("Unable to create instance of custom user info impl", e); } } return userInfo; } }