use of org.teiid.client.security.InvalidSessionException in project teiid by teiid.
the class TestJBossSecurityHelper method validateSession.
public void validateSession(boolean securityEnabled) throws Exception {
final ArrayList<String> domains = new ArrayList<String>();
domains.add("somedomain");
AuthenticationManager authManager = Mockito.mock(AuthenticationManager.class);
Mockito.stub(authManager.isValid(new SimplePrincipal("steve"), "pass1", new Subject())).toReturn(true);
final SecurityDomainContext securityContext = new SecurityDomainContext(authManager, null, null, null, null, null);
SessionServiceImpl jss = new SessionServiceImpl() {
@Override
protected VDBMetaData getActiveVDB(String vdbName, String vdbVersion) throws SessionServiceException {
return Mockito.mock(VDBMetaData.class);
}
};
jss.setSecurityHelper(buildSecurityHelper("somedomain", securityContext));
jss.setSecurityDomain("somedomain");
try {
jss.validateSession(String.valueOf(1));
// $NON-NLS-1$
fail("exception expected");
} catch (InvalidSessionException e) {
}
// $NON-NLS-1$ //$NON-NLS-2$
SessionMetadata info = jss.createSession("x", "1", AuthenticationType.USERPASSWORD, "steve", new Credentials("pass1".toCharArray()), "foo", new Properties());
if (securityEnabled) {
Mockito.verify(authManager).isValid(new SimplePrincipal("steve"), "pass1", new Subject());
}
String id1 = info.getSessionId();
jss.validateSession(id1);
assertEquals(1, jss.getActiveSessionsCount());
// $NON-NLS-1$
assertEquals(0, jss.getSessionsLoggedInToVDB(new VDBKey("a", 1)).size());
jss.closeSession(id1);
try {
jss.validateSession(id1);
// $NON-NLS-1$
fail("exception expected");
} catch (InvalidSessionException e) {
}
try {
jss.closeSession(id1);
// $NON-NLS-1$
fail("exception expected");
} catch (InvalidSessionException e) {
}
}
use of org.teiid.client.security.InvalidSessionException in project teiid by teiid.
the class EmbeddedServer method startVDBRepository.
private void startVDBRepository() {
this.repo.addListener(new VDBLifeCycleListener() {
@Override
public void added(String name, CompositeVDB vdb) {
}
@Override
public void removed(String name, CompositeVDB vdb) {
if (replicator != null) {
replicator.stop(vdb.getVDB().getAttachment(GlobalTableStore.class));
}
rs.clearForVDB(vdb.getVDBKey());
ppc.clearForVDB(vdb.getVDBKey());
for (SessionMetadata session : sessionService.getSessionsLoggedInToVDB(vdb.getVDBKey())) {
try {
sessionService.closeSession(session.getSessionId());
} catch (InvalidSessionException e) {
}
}
}
@Override
public void finishedDeployment(String name, CompositeVDB vdb) {
if (!vdb.getVDB().getStatus().equals(Status.ACTIVE)) {
return;
}
GlobalTableStore gts = CompositeGlobalTableStore.createInstance(vdb, dqp.getBufferManager(), replicator);
vdb.getVDB().addAttchment(GlobalTableStore.class, gts);
}
@Override
public void beforeRemove(String name, CompositeVDB vdb) {
}
});
this.repo.setSystemFunctionManager(SystemMetadata.getInstance().getSystemFunctionManager());
this.repo.start();
}
use of org.teiid.client.security.InvalidSessionException in project teiid by teiid.
the class SessionServiceImpl method closeSession.
@Override
public void closeSession(String sessionID) throws InvalidSessionException {
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_SECURITY, MessageLevel.DETAIL)) {
// $NON-NLS-1$
LogManager.logDetail(LogConstants.CTX_SECURITY, new Object[] { "closeSession", sessionID });
}
SessionMetadata info = getSessionInfo(sessionID, true);
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_AUDITLOGGING, MessageLevel.DETAIL)) {
// $NON-NLS-1$ //$NON-NLS-2$
LogManager.logDetail(LogConstants.CTX_AUDITLOGGING, new AuditMessage("session", "logoff", info));
}
if (info.getVDBName() != null) {
try {
dqp.terminateSession(info.getSessionId());
} catch (Exception e) {
LogManager.logWarning(LogConstants.CTX_SECURITY, e, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40018));
}
}
info.setSecurityContext(null);
info.setClosed();
info.getSessionVariables().clear();
}
use of org.teiid.client.security.InvalidSessionException in project teiid by teiid.
the class TestFailover method createListener.
private SocketListener createListener(InetSocketAddress address, SSLConfiguration config) {
ClientServiceRegistryImpl server = new ClientServiceRegistryImpl() {
@Override
public ClassLoader getCallerClassloader() {
return getClass().getClassLoader();
}
};
SessionService ss = mock(SessionService.class);
server.registerClientService(ILogon.class, new // $NON-NLS-1$
LogonImpl(// $NON-NLS-1$
ss, // $NON-NLS-1$
"fakeCluster") {
@Override
public LogonResult logon(Properties connProps) throws LogonException {
logonAttempts++;
return new LogonResult(new SessionToken("dummy"), "x", "z");
}
@Override
public ResultsFuture<?> ping() throws InvalidSessionException, TeiidComponentException {
return ResultsFuture.NULL_FUTURE;
}
@Override
public void assertIdentity(SessionToken checkSession) throws InvalidSessionException, TeiidComponentException {
throw new InvalidSessionException();
}
}, null);
server.registerClientService(FakeService.class, new TestSocketRemoting.FakeServiceImpl(), null);
return new SocketListener(new InetSocketAddress(address.getAddress().getHostAddress(), address.getPort()), 0, 0, 2, config, server, BufferManagerFactory.getStandaloneBufferManager());
}
use of org.teiid.client.security.InvalidSessionException 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