use of org.teiid.dqp.internal.process.DQPWorkContext in project teiid by teiid.
the class TestRowBasedSecurity method createContext.
private static CommandContext createContext() {
CommandContext context = createCommandContext();
DQPWorkContext workContext = new DQPWorkContext();
HashMap<String, DataPolicy> policies = new HashMap<String, DataPolicy>();
DataPolicyMetadata policy = new DataPolicyMetadata();
pmd = new PermissionMetaData();
pmd.setResourceName("pm1.g1");
pmd.setCondition("e1 = user()");
PermissionMetaData pmd1 = new PermissionMetaData();
pmd1.setResourceName("pm1.g2");
pmd1.setCondition("foo = bar");
PermissionMetaData pmd2 = new PermissionMetaData();
pmd2.setResourceName("pm1.g4");
pmd2.setCondition("e1 = max(e2)");
PermissionMetaData pmd3 = new PermissionMetaData();
pmd3.setResourceName("pm1.g3");
pmd3.setAllowDelete(true);
PermissionMetaData pmd4 = new PermissionMetaData();
pmd4.setResourceName("pm1.sp1");
pmd4.setCondition("e1 = 'a'");
policy.addPermission(pmd, pmd1, pmd2, pmd3, pmd4);
policy.setName("some-role");
policies.put("some-role", policy);
workContext.setPolicies(policies);
context.setDQPWorkContext(workContext);
return context;
}
use of org.teiid.dqp.internal.process.DQPWorkContext in project teiid by teiid.
the class TestSourceHints method testKeepAliases.
@Test
public void testKeepAliases() throws Exception {
// $NON-NLS-1$
String sql = "SELECT /*+ sh KEEP ALIASES bar:'leading(g)' */ e1 from pm1.g1 g order by e1 limit 1";
CommandContext cc = TestProcessor.createCommandContext();
cc.setDQPWorkContext(new DQPWorkContext());
cc.getDQPWorkContext().getSession().setVdb(RealMetadataFactory.example1VDB());
ProcessorPlan plan = TestOptimizer.getPlan(TestOptimizer.helpGetCommand(sql, RealMetadataFactory.example1Cached(), null), RealMetadataFactory.example1Cached(), TestOptimizer.getGenericFinder(), null, true, cc);
TestOptimizer.checkAtomicQueries(new String[] { "SELECT /*+sh KEEP ALIASES bar:'leading(g)' */ g.e1 AS c_0 FROM pm1.g1 AS g ORDER BY c_0" }, plan);
List<?>[] expected = new List[] {};
helpProcess(plan, manager(null, "leading(g)"), expected);
}
use of org.teiid.dqp.internal.process.DQPWorkContext in project teiid by teiid.
the class RealMetadataFactory method buildWorkContext.
public static DQPWorkContext buildWorkContext(QueryMetadataInterface metadata, VDBMetaData vdb) {
DQPWorkContext workContext = new DQPWorkContext();
SessionMetadata session = new SessionMetadata();
workContext.setSession(session);
session.setVDBName(vdb.getName());
session.setVDBVersion(vdb.getVersion());
session.setSessionId(String.valueOf(1));
// $NON-NLS-1$
session.setUserName("foo");
session.setVdb(vdb);
workContext.getVDB().addAttchment(QueryMetadataInterface.class, metadata);
if (metadata instanceof TransformationMetadata) {
workContext.getVDB().addAttchment(TransformationMetadata.class, (TransformationMetadata) metadata);
}
DQPWorkContext.setWorkContext(workContext);
return workContext;
}
use of org.teiid.dqp.internal.process.DQPWorkContext in project teiid by teiid.
the class TestLogonImpl method testLogonAuthenticationType.
@Test
public void testLogonAuthenticationType() throws Exception {
VDBRepository repo = Mockito.mock(VDBRepository.class);
VDBMetaData vdb = new VDBMetaData();
vdb.addProperty(SessionServiceImpl.GSS_PATTERN_PROPERTY, "GSS");
vdb.setName("name");
vdb.setVersion(1);
vdb.setStatus(Status.ACTIVE);
Mockito.stub(repo.getLiveVDB("name", "1")).toReturn(vdb);
ssi.setVDBRepository(repo);
ssi.setSecurityDomain("SC");
// default transport - what Teiid has before TEIID-2863
// this is transport default
ssi.setAuthenticationType(AuthenticationType.USERPASSWORD);
DQPWorkContext.setWorkContext(new DQPWorkContext());
Properties p = buildProperties("fred", "name");
// $NON-NLS-1$
LogonImpl impl = new LogonImpl(ssi, "fakeCluster");
LogonResult result = impl.logon(p);
assertEquals("fred", result.getUserName());
// if no preference then choose USERPASSWORD
// this is transport default
ssi.setAuthenticationType(AuthenticationType.USERPASSWORD);
DQPWorkContext.setWorkContext(new DQPWorkContext());
p = buildProperties("fred", "name");
// $NON-NLS-1$
impl = new LogonImpl(ssi, "fakeCluster");
result = impl.logon(p);
assertEquals("fred", result.getUserName());
// if user name is set to "GSS", then the preference is set to "GSS"
// this is transport default
ssi.setAuthenticationType(AuthenticationType.USERPASSWORD);
DQPWorkContext.setWorkContext(new DQPWorkContext());
p = buildProperties("GSS", "name");
// $NON-NLS-1$
FakeGssLogonImpl fimpl = new FakeGssLogonImpl(ssi, "fakeCluster");
fimpl.addToken("bytes".getBytes(), new Subject());
p.put(ILogon.KRB5TOKEN, "bytes".getBytes());
result = fimpl.logon(p);
assertEquals("GSS", result.getUserName());
// if the transport default defined as GSS, then preference is USERPASSWORD, additional challenge
ssi.setAuthenticationType(AuthenticationType.GSS);
DQPWorkContext.setWorkContext(new DQPWorkContext());
p = buildProperties("fred", "name");
// $NON-NLS-1$
impl = new LogonImpl(ssi, "fakeCluster");
result = impl.logon(p);
assertEquals(AuthenticationType.GSS, result.getProperty("authType"));
}
use of org.teiid.dqp.internal.process.DQPWorkContext in project teiid by teiid.
the class TestLogonImpl method testLogonAuthenticationTypeByVDB.
@Test
public void testLogonAuthenticationTypeByVDB() throws Exception {
VDBRepository repo = Mockito.mock(VDBRepository.class);
ssi.setVDBRepository(repo);
// when VDB value is is avavailble this will not be used
ssi.setAuthenticationType(AuthenticationType.GSS);
// default transport - what Teiid has before TEIID-2863
addVdb(repo, "name", "SC", AuthenticationType.USERPASSWORD.name());
DQPWorkContext.setWorkContext(new DQPWorkContext());
Properties p = buildProperties("fred", "name");
// $NON-NLS-1$
LogonImpl impl = new LogonImpl(ssi, "fakeCluster");
LogonResult result = impl.logon(p);
assertEquals("fred", result.getUserName());
// if no preference then choose USERPASSWORD
VDBMetaData metadata = addVdb(repo, "name1", "SC", AuthenticationType.USERPASSWORD.name());
metadata.addProperty(SessionServiceImpl.GSS_PATTERN_PROPERTY, "GSS");
DQPWorkContext.setWorkContext(new DQPWorkContext());
// $NON-NLS-1$
impl = new LogonImpl(ssi, "fakeCluster");
p = buildProperties("fred", "name1");
result = impl.logon(p);
assertEquals("fred", result.getUserName());
p = buildProperties("GSS", "name1");
// $NON-NLS-1$
FakeGssLogonImpl fimpl = new FakeGssLogonImpl(ssi, "fakeCluster");
fimpl.addToken("bytes".getBytes(), new Subject());
p.put(ILogon.KRB5TOKEN, "bytes".getBytes());
result = fimpl.logon(p);
assertEquals("GSS", result.getUserName());
// here preference is GSS
try {
p = buildProperties("GSS", "name");
result = impl.logon(p);
assertEquals("GSS", result.getUserName());
} catch (LogonException e) {
}
// if the transport default defined as GSS, then preference is USERPASSWORD, additional challenge
addVdb(repo, "name2", "SC", "GSS");
DQPWorkContext.setWorkContext(new DQPWorkContext());
// $NON-NLS-1$
impl = new LogonImpl(ssi, "fakeCluster");
p = buildProperties("fred", "name2");
result = impl.logon(p);
assertEquals(AuthenticationType.GSS, result.getProperty("authType"));
// doesn't match gss pattern
metadata.addProperty(SessionServiceImpl.GSS_PATTERN_PROPERTY, "GSS");
DQPWorkContext.setWorkContext(new DQPWorkContext());
// $NON-NLS-1$
impl = new LogonImpl(ssi, "fakeCluster");
p = buildProperties(null, "name1");
result = impl.logon(p);
assertEquals("anonymous", result.getUserName());
}
Aggregations