org.apache.catalina.session.StandardSession Java Examples
The following examples show how to use
org.apache.catalina.session.StandardSession.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestCrawlerSessionManagerValve.java From Tomcat8-Source-Read with MIT License | 6 votes |
@Test public void testCrawlersSessionIdIsRemovedAfterSessionExpiry() throws IOException, ServletException { CrawlerSessionManagerValve valve = new CrawlerSessionManagerValve(); valve.setCrawlerIps("216\\.58\\.206\\.174"); valve.setCrawlerUserAgents(valve.getCrawlerUserAgents()); valve.setNext(EasyMock.createMock(Valve.class)); valve.setSessionInactiveInterval(0); StandardSession session = new StandardSession(TEST_MANAGER); session.setId("id"); session.setValid(true); Request request = createRequestExpectations("216.58.206.174", session, true); EasyMock.replay(request); valve.invoke(request, EasyMock.createMock(Response.class)); EasyMock.verify(request); MatcherAssert.assertThat(valve.getClientIpSessionId().values(), CoreMatchers.hasItem("id")); session.expire(); Assert.assertEquals(0, valve.getClientIpSessionId().values().size()); }
Example #2
Source File: RedissonSession.java From redisson with Apache License 2.0 | 6 votes |
public RedissonSession(RedissonSessionManager manager, ReadMode readMode, UpdateMode updateMode, boolean broadcastSessionEvents) { super(manager); this.redissonManager = manager; this.readMode = readMode; this.updateMode = updateMode; this.topic = redissonManager.getTopic(); this.broadcastSessionEvents = broadcastSessionEvents; if (updateMode == UpdateMode.AFTER_REQUEST) { removedAttributes = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>()); updatedAttributes = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>()); } try { Field attr = StandardSession.class.getDeclaredField("attributes"); attrs = (Map<String, Object>) attr.get(this); } catch (Exception e) { throw new IllegalStateException(e); } }
Example #3
Source File: RedissonSession.java From redisson with Apache License 2.0 | 6 votes |
public RedissonSession(RedissonSessionManager manager, ReadMode readMode, UpdateMode updateMode, boolean broadcastSessionEvents) { super(manager); this.redissonManager = manager; this.readMode = readMode; this.updateMode = updateMode; this.topic = redissonManager.getTopic(); this.broadcastSessionEvents = broadcastSessionEvents; if (updateMode == UpdateMode.AFTER_REQUEST) { removedAttributes = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>()); updatedAttributes = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>()); } try { Field attr = StandardSession.class.getDeclaredField("attributes"); attrs = (Map<String, Object>) attr.get(this); } catch (Exception e) { throw new IllegalStateException(e); } }
Example #4
Source File: RedissonSession.java From redisson with Apache License 2.0 | 6 votes |
public RedissonSession(RedissonSessionManager manager, ReadMode readMode, UpdateMode updateMode, boolean broadcastSessionEvents) { super(manager); this.redissonManager = manager; this.readMode = readMode; this.updateMode = updateMode; this.topic = redissonManager.getTopic(); this.broadcastSessionEvents = broadcastSessionEvents; if (updateMode == UpdateMode.AFTER_REQUEST) { removedAttributes = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>()); updatedAttributes = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>()); } try { Field attr = StandardSession.class.getDeclaredField("attributes"); attrs = (Map<String, Object>) attr.get(this); } catch (Exception e) { throw new IllegalStateException(e); } }
Example #5
Source File: TesterRequest.java From Tomcat8-Source-Read with MIT License | 5 votes |
public TesterRequest(boolean withSession) { context = new TesterContext(); servletContext = new TesterServletContext(); context.setServletContext(servletContext); if (withSession) { Set<SessionTrackingMode> modes = new HashSet<>(); modes.add(SessionTrackingMode.URL); modes.add(SessionTrackingMode.COOKIE); servletContext.setSessionTrackingModes(modes); session = new StandardSession(null); session.setId("1234", false); session.setValid(true); } }
Example #6
Source File: TesterRequest.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
public TesterRequest(boolean withSession) { context = new TesterContext(); servletContext = new TesterServletContext(); context.setServletContext(servletContext); if (withSession) { Set<SessionTrackingMode> modes = new HashSet<SessionTrackingMode>(); modes.add(SessionTrackingMode.URL); modes.add(SessionTrackingMode.COOKIE); servletContext.setSessionTrackingModes(modes); session = new StandardSession(null); session.setId("1234", false); session.setValid(true); } }
Example #7
Source File: TesterRequest.java From tomcatsrc with Apache License 2.0 | 5 votes |
public TesterRequest(boolean withSession) { context = new TesterContext(); servletContext = new TesterServletContext(); context.setServletContext(servletContext); if (withSession) { Set<SessionTrackingMode> modes = new HashSet<SessionTrackingMode>(); modes.add(SessionTrackingMode.URL); modes.add(SessionTrackingMode.COOKIE); servletContext.setSessionTrackingModes(modes); session = new StandardSession(null); session.setId("1234", false); session.setValid(true); } }
Example #8
Source File: RedisStoreTest.java From session-managers with Apache License 2.0 | 5 votes |
@Test public void load() throws IOException { Session session = new StandardSession(this.manager); session.setId("test-id"); byte[] response = this.sessionSerializationUtils.serialize(session); when(this.jedisClient.get("test-id")).thenReturn(response); Session result = this.store.load("test-id"); assertEquals(session.getId(), result.getId()); }
Example #9
Source File: RedisStoreTest.java From session-managers with Apache License 2.0 | 5 votes |
@Test public void save() throws IOException { Session session = new StandardSession(this.manager); session.setId("test-id"); this.store.save(session); verify(this.jedisClient).set(getRedisSessionId(session), SESSIONS_KEY, this.sessionSerializationUtils.serialize(session), session.getMaxInactiveInterval()); }
Example #10
Source File: RedisStoreTest.java From session-managers with Apache License 2.0 | 5 votes |
@Test public void saveJedisConnectionException() throws UnsupportedEncodingException { Session session = new StandardSession(this.manager); session.setId("test-id"); doThrow(new JedisConnectionException("test-message")) .when(this.jedisClient) .set(anyString(), anyString(), any((byte[].class)), eq(session.getMaxInactiveInterval())); this.store.save(session); }
Example #11
Source File: DatastoreManager.java From tomcat-runtime with Apache License 2.0 | 4 votes |
@Override protected StandardSession getNewSession() { return new DatastoreSession(this); }