List of usage examples for org.apache.shiro.session.mgt SessionManager getSession
Session getSession(SessionKey key) throws SessionException;
From source file:org.obiba.opal.core.runtime.security.AbstractHttpAuthenticatingRealm.java
License:Open Source License
@Nullable protected Session getSession(String sessionId) { if (sessionId != null) { SessionManager manager = getSessionManager(); if (manager != null) { SessionKey key = new DefaultSessionKey(sessionId); try { return manager.getSession(key); } catch (SessionException e) { // Means that the session does not exist or has expired. }// w ww .j av a 2 s.co m } } return null; }
From source file:org.obiba.opal.web.security.SecurityResourceTest.java
License:Open Source License
@Test public void testCheckSession() { Session mockSession = EasyMock.createMock(Session.class); SessionManager sessionManager = mockSessionManager(); expect(sessionManager.getSession(expectSession(testSessionId))).andReturn(mockSession).atLeastOnce(); replay(sessionManager);/*w ww.j a v a 2 s . c o m*/ Response response = securityResource.checkSession(testSessionId); Assert.assertEquals(Status.OK.getStatusCode(), response.getStatus()); verify(sessionManager); }
From source file:org.obiba.opal.web.security.SecurityResourceTest.java
License:Open Source License
@Test public void testCheckSessionThrowsSessionException() { SessionManager sessionManager = mockSessionManager(); expect(sessionManager.getSession(expectSession(testSessionId))).andThrow(new SessionException()) .atLeastOnce();// w ww . j ava2 s. c o m replay(sessionManager); Response response = securityResource.checkSession(testSessionId); Assert.assertEquals(Status.NOT_FOUND.getStatusCode(), response.getStatus()); verify(sessionManager); }
From source file:org.obiba.opal.web.security.SecurityResourceTest.java
License:Open Source License
@Test public void testCheckSessionReturnsNull() { SessionManager sessionManager = mockSessionManager(); expect(sessionManager.getSession(expectSession(testSessionId))).andReturn(null).atLeastOnce(); replay(sessionManager);//from ww w.ja va 2s . c om Response response = securityResource.checkSession(testSessionId); Assert.assertEquals(Status.NOT_FOUND.getStatusCode(), response.getStatus()); verify(sessionManager); }