use of org.kie.internal.runtime.manager.SecurityManager 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.internal.runtime.manager.SecurityManager 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());
}
Aggregations