List of usage examples for org.apache.shiro.session.mgt SimpleSession setAttributes
public void setAttributes(Map<Object, Object> attributes)
From source file:com.parallax.server.blocklyprop.security.BlocklyPropSessionDao.java
/** * Concert a SessionRecord object to a Session object * * @param sessionRecord/* w w w. j a v a 2 s . c o m*/ * the SessionRecord object to convert * * @return * a Session object. The session object attributes may be missing if the original * SessionRecord object contained non-string data. */ private Session convert(SessionRecord sessionRecord) { LOG.trace("Converting SessionRecord {} into a SimpleSession object", sessionRecord.getIdsession()); SimpleSession ssession = new SimpleSession(); ssession.setId(sessionRecord.getIdsession()); ssession.setStartTimestamp(sessionRecord.getStarttimestamp()); ssession.setLastAccessTime(sessionRecord.getLastaccesstime()); ssession.setTimeout(sessionRecord.getTimeout()); ssession.setHost(sessionRecord.getHost()); // Gather the session attributes into a HashMap that can be persisted into the // Session object if (sessionRecord.getAttributes() != null) { // In case there is something in the session attributes that isn't a string value // We can trap the issue here and deal with it. The @SuppressWarnings tells the IDE // that we have thought about this and taken appropriate defensive measures. try { @SuppressWarnings("unchecked") HashMap<Object, Object> attributes = (HashMap<Object, Object>) SerializationUtils .deserialize(sessionRecord.getAttributes()); ssession.setAttributes(attributes); } catch (ClassCastException ex) { LOG.warn("Unable to convert SessionRecord attributes in session {}", sessionRecord.getIdsession()); } } return ssession; }
From source file:org.graylog2.security.MongoDbSessionDAO.java
License:Open Source License
private SimpleSession getSimpleSession(Serializable sessionId, MongoDbSession dbSession) { final SimpleSession session = new SimpleSession(); assignSessionId(session, sessionId); session.setHost(dbSession.getHost()); session.setTimeout(dbSession.getTimeout()); session.setStartTimestamp(dbSession.getStartTimestamp()); session.setLastAccessTime(dbSession.getLastAccessTime()); session.setExpired(dbSession.isExpired()); session.setAttributes(dbSession.getAttributes()); return session; }
From source file:org.killbill.billing.util.security.shiro.dao.SessionModelDao.java
License:Apache License
public Session toSimpleSession() throws IOException { final SimpleSession simpleSession = new SimpleSession(); if (id != null) { // Make sure to use a String here! It will be used as-is as the key in Ehcache. // When retrieving the session, the sessionId will be a String // See https://github.com/killbill/killbill/issues/299 simpleSession.setId(id);//from w w w . ja v a 2 s .c om } simpleSession.setStartTimestamp(startTimestamp.toDate()); simpleSession.setLastAccessTime(lastAccessTime.toDate()); simpleSession.setTimeout(timeout); simpleSession.setHost(host); final Map attributes = serializer.deserialize(sessionData); //noinspection unchecked simpleSession.setAttributes(attributes); return simpleSession; }