List of usage examples for org.apache.shiro.session.mgt SimpleSession isExpired
public boolean isExpired()
From source file:com.leshazlewood.samples.shiro.cassandra.CassandraSessionDAO.java
License:Apache License
protected void save(SimpleSession ss) { //Cassandra TTL values are in seconds, so we need to convert from Shiro's millis: int timeoutInSeconds = (int) (ss.getTimeout() / 1000); PreparedStatement ps = prepareSaveStatement(); BoundStatement bs = new BoundStatement(ps); byte[] serialized = serializer.serialize(ss); ByteBuffer bytes = ByteBuffer.wrap(serialized); bs.bind(timeoutInSeconds, ss.getStartTimestamp(), ss.getStopTimestamp() != null ? ss.getStartTimestamp() : null, ss.getLastAccessTime(), ss.getTimeout(), ss.isExpired(), ss.getHost(), bytes, ss.getId()); cassandraSession.execute(bs);//from w w w . j a v a 2 s .com }
From source file:org.graylog2.security.MongoDbSessionDAO.java
License:Open Source License
@Override protected void doUpdate(Session session) { final MongoDbSession dbSession = mongoDBSessionService.load(session.getId().toString()); if (null == dbSession) { throw new RuntimeException("Couldn't load session <" + session.getId() + ">"); }/* ww w . ja v a 2 s . c o m*/ LOG.debug("Updating session {}", session); dbSession.setHost(session.getHost()); dbSession.setTimeout(session.getTimeout()); dbSession.setStartTimestamp(session.getStartTimestamp()); dbSession.setLastAccessTime(session.getLastAccessTime()); if (session instanceof SimpleSession) { final SimpleSession simpleSession = (SimpleSession) session; dbSession.setAttributes(simpleSession.getAttributes()); dbSession.setExpired(simpleSession.isExpired()); } else { throw new RuntimeException("Unsupported session type: " + session.getClass().getCanonicalName()); } mongoDBSessionService.saveWithoutValidation(dbSession); }