use of org.teiid.runtime.EmbeddedConfiguration in project teiid by teiid.
the class TestTeiidPlatform method init.
@BeforeClass
public static void init() throws VirtualDatabaseException, ConnectorManagerException, TranslatorException, FileNotFoundException, IOException, ResourceException, SQLException {
server = new EmbeddedServer();
FileExecutionFactory executionFactory = new FileExecutionFactory();
server.addTranslator("file", executionFactory);
FileManagedConnectionFactory fileManagedconnectionFactory = new FileManagedConnectionFactory();
fileManagedconnectionFactory.setParentDirectory(UnitTestUtil.getTestDataPath() + File.separator + "file");
ConnectionFactory connectionFactory = fileManagedconnectionFactory.createConnectionFactory();
ConnectionFactoryProvider<ConnectionFactory> connectionFactoryProvider = new EmbeddedServer.SimpleConnectionFactoryProvider<ConnectionFactory>(connectionFactory);
server.addConnectionFactoryProvider("java:/marketdata-file", connectionFactoryProvider);
EmbeddedConfiguration config = new EmbeddedConfiguration();
server.start(config);
DriverManager.registerDriver(server.getDriver());
server.deployVDB(new FileInputStream(UnitTestUtil.getTestDataFile("vdb" + File.separator + "marketdata-vdb.xml")));
factory = Persistence.createEntityManagerFactory("org.teiid.eclipselink.test");
}
use of org.teiid.runtime.EmbeddedConfiguration in project teiid by teiid.
the class TestPassthroughAuthentication method oneTimeSetup.
@BeforeClass
public static void oneTimeSetup() throws Exception {
server.setUseCallingThread(true);
server.start(new EmbeddedConfiguration() {
@Override
public SecurityHelper getSecurityHelper() {
return securityHelper;
}
}, false);
}
use of org.teiid.runtime.EmbeddedConfiguration in project teiid by teiid.
the class TestRowBasedSecurity method testSecurity.
@Test
public void testSecurity() throws Exception {
es = new EmbeddedServer();
EmbeddedConfiguration ec = new EmbeddedConfiguration();
final Vector<Principal> v = new Vector<Principal>();
v.add(new Identity("myrole") {
});
final Subject subject = new Subject();
Group g = Mockito.mock(Group.class);
Mockito.stub(g.getName()).toReturn("Roles");
Mockito.stub(g.members()).toReturn((Enumeration) v.elements());
subject.getPrincipals().add(g);
ec.setSecurityHelper(new DoNothingSecurityHelper() {
@Override
public Subject getSubjectInContext(String securityDomain) {
return subject;
}
@Override
public Subject getSubjectInContext(Object context) {
return subject;
}
});
es.start(ec);
HardCodedExecutionFactory hcef = new HardCodedExecutionFactory() {
@Override
public void getMetadata(MetadataFactory metadataFactory, Object conn) throws TranslatorException {
Table t = metadataFactory.addTable("x");
Column col = metadataFactory.addColumn("col", TypeFacility.RUNTIME_NAMES.STRING, t);
metadataFactory.addColumn("col2", TypeFacility.RUNTIME_NAMES.STRING, t);
metadataFactory.addPermission("y", t, null, null, Boolean.TRUE, null, null, null, "col = 'a'", null);
metadataFactory.addColumnPermission("y", col, null, null, null, null, "null", null);
t = metadataFactory.addTable("y");
col = metadataFactory.addColumn("col", TypeFacility.RUNTIME_NAMES.STRING, t);
metadataFactory.addColumn("col2", TypeFacility.RUNTIME_NAMES.STRING, t);
metadataFactory.addPermission("z", t, null, null, null, null, null, null, "col = 'e'", null);
Table v = metadataFactory.addTable("v");
metadataFactory.addPermission("y", v, null, null, Boolean.TRUE, null, null, null, null, null);
col = metadataFactory.addColumn("col", TypeFacility.RUNTIME_NAMES.STRING, v);
metadataFactory.addColumn("col2", TypeFacility.RUNTIME_NAMES.STRING, v);
v.setTableType(Type.View);
v.setVirtual(true);
v.setSelectTransformation("/*+ cache(scope:session) */ select col, col2 from y");
}
@Override
public boolean isSourceRequiredForMetadata() {
return false;
}
};
hcef.addData("SELECT x.col, x.col2 FROM x", Arrays.asList(Arrays.asList("a", "b"), Arrays.asList("c", "d")));
hcef.addData("SELECT y.col, y.col2 FROM y", Arrays.asList(Arrays.asList("e", "f"), Arrays.asList("h", "g")));
es.addTranslator("hc", hcef);
es.deployVDB(new FileInputStream(UnitTestUtil.getTestDataFile("roles-vdb.xml")));
Connection c = es.getDriver().connect("jdbc:teiid:z;PassthroughAuthentication=true", null);
Statement s = c.createStatement();
ResultSet rs = s.executeQuery("select * from x");
rs.next();
// masking
assertEquals(null, rs.getString(1));
assertEquals("b", rs.getString(2));
// row filter
assertFalse(rs.next());
rs.close();
s = c.createStatement();
rs = s.executeQuery("select lookup('myschema.x', 'col', 'col2', 'b')");
rs.next();
// global scoped
assertEquals(null, rs.getString(1));
s = c.createStatement();
rs = s.executeQuery("select count(col2) from v where col is not null");
rs.next();
assertEquals(1, rs.getInt(1));
// different session with different roles
v.clear();
c = es.getDriver().connect("jdbc:teiid:z;PassthroughAuthentication=true", null);
s = c.createStatement();
rs = s.executeQuery("select count(col2) from v where col is not null");
rs.next();
assertEquals(2, rs.getInt(1));
}
use of org.teiid.runtime.EmbeddedConfiguration in project teiid by teiid.
the class TestExternalMatViews method createServer.
private FakeServer createServer(String nodeName, String ispn, String jgroups) throws Exception {
FakeServer server = new FakeServer(false);
EmbeddedConfiguration config = new EmbeddedConfiguration();
config.setInfinispanConfigFile(ispn);
config.setJgroupsConfigFile(jgroups);
config.setNodeName(nodeName);
config.setTransactionManager(new DummyTransactionManager());
server.start(config, true);
return server;
}
use of org.teiid.runtime.EmbeddedConfiguration in project teiid by teiid.
the class TestReplication method createServer.
private FakeServer createServer(String ispn, String jgroups) throws Exception {
FakeServer server = new FakeServer(false);
EmbeddedConfiguration config = new EmbeddedConfiguration();
config.setInfinispanConfigFile(ispn);
config.setJgroupsConfigFile(jgroups);
config.setTransactionManager(new DummyTransactionManager());
server.start(config, true);
return server;
}
Aggregations