private SessionMetadata getSessionInfo(String sessionID, boolean remove) throws InvalidSessionException { if (sessionID == null) { throw new InvalidSessionException(RuntimePlugin.Event.TEIID40041, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40041)); } SessionMetadata info = remove?this.sessionCache.remove(sessionID):this.sessionCache.get(sessionID); if (info == null) { throw new InvalidSessionException(RuntimePlugin.Event.TEIID40042, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40042, sessionID)); } return info; }
public InvalidSessionException(BundleUtil.Event event) { super(); setCode(event.toString()); } }
@Override public boolean terminateSession(String terminatedSessionID, String adminSessionID) { Object[] params = {adminSessionID, terminatedSessionID}; LogManager.logInfo(LogConstants.CTX_SECURITY, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40009, params)); try { closeSession(terminatedSessionID); return true; } catch (InvalidSessionException e) { LogManager.logDetail(LogConstants.CTX_SECURITY,e,e.getMessage()); return false; } }
public void testSubclass() throws Exception { Method m = DQP.class.getMethod("getMetadata", new Class[] {Long.TYPE}); Throwable t = ExceptionUtil.convertException(m, new InvalidSessionException()); assertTrue(t instanceof InvalidSessionException); } }
public InvalidSessionException(BundleUtil.Event event) { super(); setCode(event.toString()); } }
@Test public void testNotification() throws Exception { ConnectionImpl conn = Mockito.mock(ConnectionImpl.class); Mockito.doThrow(new SQLException(new InvalidSessionException())).when(conn).commit(); XAConnectionImpl xaConn = new XAConnectionImpl(conn); ConnectionEventListener cel = Mockito.mock(ConnectionEventListener.class); xaConn.addConnectionEventListener(cel); Connection c = xaConn.getConnection(); try { c.commit(); } catch (SQLException e) { } Mockito.verify(cel).connectionErrorOccurred((ConnectionEvent) Mockito.anyObject()); }
@Override public void assertIdentity(SessionToken checkSession) throws InvalidSessionException, TeiidComponentException { if (checkSession == null) { //disassociate this.updateDQPContext(new SessionMetadata()); return; } SessionMetadata sessionInfo = null; try { sessionInfo = this.service.validateSession(checkSession.getSessionID()); } catch (SessionServiceException e) { throw new TeiidComponentException(RuntimePlugin.Event.TEIID40062, e); } if (sessionInfo == null) { throw new InvalidSessionException(RuntimePlugin.Event.TEIID40063); } SessionToken st = sessionInfo.getSessionToken(); if (!st.equals(checkSession)) { throw new InvalidSessionException(RuntimePlugin.Event.TEIID40064); } this.updateDQPContext(sessionInfo); }
@Test(expected=XAException.class) public void testStartFailure() throws Exception { ConnectionImpl conn = Mockito.mock(ConnectionImpl.class); XidImpl xid = new XidImpl(); Mockito.doThrow(new SQLException(new InvalidSessionException())).when(conn).startTransaction(xid, XAResource.TMNOFLAGS, 100); XAConnectionImpl xaConn = new XAConnectionImpl(conn); xaConn.setTransactionTimeout(100); xaConn.start(xid, XAResource.TMNOFLAGS); }
@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")) { //$NON-NLS-1$ //the client can issue close request effectively concurrently with close session //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); } }