/** * Immediately delegates to the underlying proxied session. */ public Collection<Object> getAttributeKeys() throws InvalidSessionException { return delegate.getAttributeKeys(); }
@SuppressWarnings({"unchecked"}) protected Set<String> getKeyNames() { Collection<Object> keySet; try { keySet = getSession().getAttributeKeys(); } catch (InvalidSessionException e) { throw new IllegalStateException(e); } Set<String> keyNames; if (keySet != null && !keySet.isEmpty()) { keyNames = new HashSet<String>(keySet.size()); for (Object o : keySet) { keyNames.add(o.toString()); } } else { keyNames = Collections.EMPTY_SET; } return keyNames; }
public Collection<Object> getAttributeKeys(SessionKey key) { Collection<Object> c = lookupRequiredSession(key).getAttributeKeys(); if (!CollectionUtils.isEmpty(c)) { return Collections.unmodifiableCollection(c); } return Collections.emptySet(); }
private byte[] serializeSessionData(final Session session) throws IOException { final Map<Object, Object> sessionAttributes = new HashMap<Object, Object>(); for (final Object key : session.getAttributeKeys()) { sessionAttributes.put(key, session.getAttribute(key)); } return serializer.serialize(sessionAttributes); } }
@Override protected Serializable doCreate(Session session) { final Serializable id = generateSessionId(session); assignSessionId(session, id); Map<String, Object> fields = Maps.newHashMap(); fields.put("session_id", id); fields.put("host", session.getHost()); fields.put("start_timestamp", session.getStartTimestamp()); fields.put("last_access_time", session.getLastAccessTime()); fields.put("timeout", session.getTimeout()); Map<String, Object> attributes = Maps.newHashMap(); for (Object key : session.getAttributeKeys()) { attributes.put(key.toString(), session.getAttribute(key)); } fields.put("attributes", attributes); final MongoDbSession dbSession = new MongoDbSession(fields); final String objectId = mongoDBSessionService.saveWithoutValidation(dbSession); LOG.debug("Created session {}", objectId); return id; }
private void tryToCleanSession(Session session) { Collection<Object> keys = session.getAttributeKeys(); for (Object key : keys) { session.removeAttribute(key); } } };
/** * Immediately delegates to the underlying proxied session. */ public Collection<Object> getAttributeKeys() throws InvalidSessionException { return delegate.getAttributeKeys(); }
public Collection<Object> getAttributeKeys(SessionKey key) { Collection<Object> c = lookupRequiredSession(key).getAttributeKeys(); if (!CollectionUtils.isEmpty(c)) { return Collections.unmodifiableCollection(c); } return Collections.emptySet(); }
/** * Immediately delegates to the underlying proxied session. */ public Collection<Object> getAttributeKeys() throws InvalidSessionException { return delegate.getAttributeKeys(); }
private byte[] serializeSessionData(final Session session) throws IOException { final Map<Object, Object> sessionAttributes = new HashMap<Object, Object>(); for (final Object key : session.getAttributeKeys()) { sessionAttributes.put(key, session.getAttribute(key)); } return serializer.serialize(sessionAttributes); } }
private byte[] serializeSessionData(final Session session) throws IOException { final Map<Object, Object> sessionAttributes = new HashMap<Object, Object>(); for (final Object key : session.getAttributeKeys()) { sessionAttributes.put(key, session.getAttribute(key)); } return serializer.serialize(sessionAttributes); } }
public Collection<Object> getAttributeKeys(SessionKey key) { Collection<Object> c = lookupRequiredSession(key).getAttributeKeys(); if (!CollectionUtils.isEmpty(c)) { return Collections.unmodifiableCollection(c); } return Collections.emptySet(); }
@Override protected Serializable doCreate(Session session) { final Serializable id = generateSessionId(session); assignSessionId(session, id); Map<String, Object> fields = Maps.newHashMap(); fields.put("session_id", id); fields.put("host", session.getHost()); fields.put("start_timestamp", session.getStartTimestamp()); fields.put("last_access_time", session.getLastAccessTime()); fields.put("timeout", session.getTimeout()); Map<String, Object> attributes = Maps.newHashMap(); for (Object key : session.getAttributeKeys()) { attributes.put(key.toString(), session.getAttribute(key)); } fields.put("attributes", attributes); final MongoDbSession dbSession = new MongoDbSession(fields); final String objectId = mongoDBSessionService.saveWithoutValidation(dbSession); LOG.debug("Created session {}", objectId); return id; }
/** * Regenerate the session if any. This prevents a potential session fixation issue by forcing a new session id on * login success. See https://issues.apache.org/jira/browse/SHIRO-170. * * @param subject the successfully logged in subject */ default void regenerateSession(Subject subject) { Session session = subject.getSession(false); if (session != null) { // Retain session attributes Map<Object, Object> attributes = new LinkedHashMap<>(); for (Object key : session.getAttributeKeys()) { Object value = session.getAttribute(key); if (value != null) { attributes.put(key, value); } } // Destroy the current sessions and recreate a new one session.stop(); session = subject.getSession(true); // Restore attributes in the new session for (Map.Entry<Object, Object> entry : attributes.entrySet()) { session.setAttribute(entry.getKey(), entry.getValue()); } } } }
Collection<Object> temp = session.getAttributeKeys(); for (Object o : temp) { keys.add(o);
Collection<Object> temp = session.getAttributeKeys(); for (Object o : temp) { keys.add(o);