use of org.kie.api.runtime.manager.RuntimeEnvironment in project jbpm by kiegroup.
the class SecurityManagerTest method testNoSecurityManager.
@Test
public void testNoSecurityManager() {
RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newEmptyBuilder().userGroupCallback(userGroupCallback).addAsset(ResourceFactory.newClassPathResource("BPMN2-ScriptTask.bpmn2"), ResourceType.BPMN2).get();
manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
assertNotNull(manager);
RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
assertNotNull(runtime);
manager.disposeRuntimeEngine(runtime);
}
use of org.kie.api.runtime.manager.RuntimeEnvironment in project jbpm by kiegroup.
the class SecurityManagerTest method testDenyAllSecurityManager.
@Test(expected = SecurityException.class)
public void testDenyAllSecurityManager() {
RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newEmptyBuilder().userGroupCallback(userGroupCallback).addAsset(ResourceFactory.newClassPathResource("BPMN2-ScriptTask.bpmn2"), ResourceType.BPMN2).get();
manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
assertNotNull(manager);
((InternalRuntimeManager) manager).setSecurityManager(new SecurityManager() {
@Override
public void checkPermission() throws SecurityException {
throw new SecurityException("Deny all on purpose");
}
});
manager.getRuntimeEngine(EmptyContext.get());
}
use of org.kie.api.runtime.manager.RuntimeEnvironment in project jbpm by kiegroup.
the class SecurityManagerTest method testCustomSecurityManager.
@Test(expected = SecurityException.class)
public void testCustomSecurityManager() {
RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newEmptyBuilder().userGroupCallback(userGroupCallback).addAsset(ResourceFactory.newClassPathResource("BPMN2-ScriptTask.bpmn2"), ResourceType.BPMN2).get();
manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
assertNotNull(manager);
final User user = new User("john");
((InternalRuntimeManager) manager).setSecurityManager(new SecurityManager() {
@Override
public void checkPermission() throws SecurityException {
if ("mary".equals(user.getName())) {
throw new SecurityException("Mary is not allowed to use runtime manager");
}
}
});
RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
assertNotNull(runtime);
manager.disposeRuntimeEngine(runtime);
user.setName("mary");
manager.getRuntimeEngine(EmptyContext.get());
}
use of org.kie.api.runtime.manager.RuntimeEnvironment in project jbpm by kiegroup.
the class ExecutionErrorHandlingRuntimeManagerTest method createRuntimeManager.
private void createRuntimeManager() {
RuntimeEnvironment environment = createEnvironment();
if ("singleton".equals(strategy)) {
manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment, "first");
} else if ("processinstance".equals(strategy)) {
manager = RuntimeManagerFactory.Factory.get().newPerProcessInstanceRuntimeManager(environment, "first");
} else if ("request".equals(strategy)) {
manager = RuntimeManagerFactory.Factory.get().newPerRequestRuntimeManager(environment, "first");
} else if ("case".equals(strategy)) {
manager = RuntimeManagerFactory.Factory.get().newPerCaseRuntimeManager(environment, "first");
}
assertNotNull(manager);
}
use of org.kie.api.runtime.manager.RuntimeEnvironment in project jbpm by kiegroup.
the class InMemorySessionFactoryLeakTest method createRuntimeManager.
private void createRuntimeManager() {
RuntimeEnvironment environment = createEnvironment();
if ("singleton".equals(strategy)) {
manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment, "first");
} else if ("processinstance".equals(strategy)) {
manager = RuntimeManagerFactory.Factory.get().newPerProcessInstanceRuntimeManager(environment, "first");
} else if ("request".equals(strategy)) {
manager = RuntimeManagerFactory.Factory.get().newPerRequestRuntimeManager(environment, "first");
} else if ("case".equals(strategy)) {
manager = RuntimeManagerFactory.Factory.get().newPerCaseRuntimeManager(environment, "first");
}
assertNotNull(manager);
}
Aggregations