use of org.teiid.adminapi.impl.SessionMetadata in project teiid by teiid.
the class ODBCServerRemoteImpl method setConnectionProperties.
public static void setConnectionProperties(ConnectionImpl conn) throws SQLException {
SessionMetadata sm = ((LocalServerConnection) conn.getServerConnection()).getWorkContext().getSession();
VDB vdb = sm.getVdb();
Properties p = vdb.getProperties();
setConnectionProperties(conn, p);
}
use of org.teiid.adminapi.impl.SessionMetadata in project teiid by teiid.
the class TestSessionServiceImpl method testSecurityDomain.
@Test
public void testSecurityDomain() throws Exception {
VDBRepository repo = Mockito.mock(VDBRepository.class);
VDBMetaData vdb = new VDBMetaData();
vdb.setName("name");
vdb.setVersion(1);
vdb.setStatus(Status.ACTIVE);
vdb.addProperty(SessionServiceImpl.SECURITY_DOMAIN_PROPERTY, "domain");
Mockito.stub(repo.getLiveVDB("name", "1")).toReturn(vdb);
ssi.setVDBRepository(repo);
Properties properties = new Properties();
properties.setProperty(TeiidURL.JDBC.VDB_NAME, "name.1");
SessionMetadata s = ssi.createSession("name", "1", AuthenticationType.USERPASSWORD, "x", new Credentials(new char[] { 'y' }), "z", properties);
assertEquals("domain", s.getSecurityDomain());
}
use of org.teiid.adminapi.impl.SessionMetadata in project teiid by teiid.
the class TestSessionServiceImpl method testLegacySecurityDomain.
@Test
public void testLegacySecurityDomain() throws Exception {
VDBRepository repo = Mockito.mock(VDBRepository.class);
VDBMetaData vdb = new VDBMetaData();
vdb.setName("name");
vdb.setVersion(1);
vdb.setStatus(Status.ACTIVE);
Mockito.stub(repo.getLiveVDB("name", "1")).toReturn(vdb);
ssi.setVDBRepository(repo);
ssi.setSecurityDomain("sd");
Properties properties = new Properties();
properties.setProperty(TeiidURL.JDBC.VDB_NAME, "name.1");
SessionMetadata s = ssi.createSession("name", "1", AuthenticationType.USERPASSWORD, "x@sd", new Credentials(new char[] { 'y' }), "z", properties);
assertEquals("sd", s.getSecurityDomain());
s = ssi.createSession("name", "1", AuthenticationType.USERPASSWORD, "x", new Credentials(new char[] { 'y' }), "z", properties);
assertEquals("sd", s.getSecurityDomain());
ssi.setAllowSecurityDomainQualifier(true);
ssi.setSecurityDomain("sd");
s = ssi.createSession("name", "1", AuthenticationType.USERPASSWORD, "x@sd", new Credentials(new char[] { 'y' }), "z", properties);
assertEquals("sd", s.getSecurityDomain());
assertEquals("x", s.getUserName());
ssi.setAllowSecurityDomainQualifier(false);
s = ssi.createSession("name", "1", AuthenticationType.USERPASSWORD, "x@sd", new Credentials(new char[] { 'y' }), "z", properties);
assertEquals("sd", s.getSecurityDomain());
assertEquals("x@sd", s.getUserName());
}
use of org.teiid.adminapi.impl.SessionMetadata in project teiid by teiid.
the class TestLogonImpl method testLogonResult.
@Test
public void testLogonResult() throws Exception {
SessionService ssi = Mockito.mock(SessionService.class);
Mockito.stub(ssi.getAuthenticationType(Mockito.anyString(), Mockito.anyString(), Mockito.anyString())).toReturn(AuthenticationType.USERPASSWORD);
DQPWorkContext.setWorkContext(new DQPWorkContext());
// $NON-NLS-1$
String userName = "Fred";
// $NON-NLS-1$
String applicationName = "test";
Properties p = new Properties();
p.setProperty(TeiidURL.CONNECTION.USER_NAME, userName);
p.setProperty(TeiidURL.CONNECTION.APP_NAME, applicationName);
p.setProperty(TeiidURL.JDBC.VDB_NAME, "x");
p.setProperty(TeiidURL.JDBC.VDB_VERSION, "1");
SessionMetadata session = new SessionMetadata();
session.setUserName(userName);
session.setApplicationName(applicationName);
session.setSessionId(String.valueOf(1));
session.setSessionToken(new SessionToken(1, userName));
Mockito.stub(ssi.createSession("x", "1", AuthenticationType.USERPASSWORD, userName, null, applicationName, p)).toReturn(session);
// $NON-NLS-1$
LogonImpl impl = new LogonImpl(ssi, "fakeCluster");
LogonResult result = impl.logon(p);
assertEquals(userName, result.getUserName());
assertEquals(String.valueOf(1), result.getSessionID());
}
use of org.teiid.adminapi.impl.SessionMetadata in project teiid by teiid.
the class SessionCheckingProxy method invoke.
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
Throwable exception = null;
try {
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
if (workContext.getSession().isClosed() || workContext.getSessionId() == null) {
if (method.getName().equals("closeRequest")) {
// there's no need for this to raise an exception
return ResultsFuture.NULL_FUTURE;
}
String sessionID = workContext.getSession().getSessionId();
if (sessionID == null) {
throw new InvalidSessionException(RuntimePlugin.Event.TEIID40041, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40041));
}
workContext.setSession(new SessionMetadata());
throw new InvalidSessionException(RuntimePlugin.Event.TEIID40042, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40042, sessionID));
}
return super.invoke(proxy, method, args);
} catch (InvocationTargetException e) {
exception = e.getTargetException();
} catch (Throwable t) {
exception = t;
}
throw ExceptionUtil.convertException(method, exception);
}
Aggregations