/** * Clear all of this session's attributes. */ public void clearAttributes() { for (Iterator<Map.Entry<String, Object>> it = this.attributes.entrySet().iterator(); it.hasNext();) { Map.Entry<String, Object> entry = it.next(); String name = entry.getKey(); Object value = entry.getValue(); it.remove(); if (value instanceof HttpSessionBindingListener) { ((HttpSessionBindingListener) value).valueUnbound(new HttpSessionBindingEvent(this, name, value)); } } }
public static HttpSessionBindingEvent createHttpSessionBindingEvent(HttpSession session) { HttpSessionBindingEvent sessionBindingEvent = mock(HttpSessionBindingEvent.class); when(sessionBindingEvent.getSession()).thenReturn(session); return sessionBindingEvent; } }
@Override public void attributeAdded(HttpSessionBindingEvent hsbe) { HttpSession session = hsbe.getSession(); if (Objects.equals(hsbe.getName(), SamlSession.class.getName())) { map(session.getId(), hsbe.getValue()); } }
@Override public void valueBound(HttpSessionBindingEvent event) { List<HttpSessionAttributeListener> listeners = getEventListeners().get( HttpSessionAttributeListener.class); for (HttpSessionAttributeListener listener : listeners) { if (added) { listener.attributeAdded(event); } else { listener.attributeReplaced(event); } } if (value instanceof HttpSessionBindingListener) { ((HttpSessionBindingListener) value).valueBound(new HttpSessionBindingEvent(innerSession, name, value)); } }
public void valueBound(HttpSessionBindingEvent event) { Debug.logVerbose("[JdonFramework] valueBound active, sessionId :" + event.getSession().getId(), module); componentsboxsInSession.clear(); }
@Override public void attributeAdded( HttpSessionBindingEvent httpSessionBindingEvent) { Object value = httpSessionBindingEvent.getValue(); if ((value instanceof Serializable) || (value == null)) { return; } Class<?> clazz = value.getClass(); _log.error( clazz.getName() + " is not serializable and will prevent this session from " + "being replicated"); if (_requiresSerializable == null) { HttpSession session = httpSessionBindingEvent.getSession(); ServletContext servletContext = session.getServletContext(); _requiresSerializable = Boolean.valueOf( GetterUtil.getBoolean( servletContext.getInitParameter( "session-attributes-requires-serializable"))); } if (_requiresSerializable) { HttpSession session = httpSessionBindingEvent.getSession(); String name = httpSessionBindingEvent.getName(); session.removeAttribute(name); } }
/** * From javax.servlet.http.SessionBindingListener */ @Override public void valueBound(HttpSessionBindingEvent e) { if (logger.isDebugEnabled()) { logger.debug("Received value bound event on " + e.getName() + " from session " + e.getSession().getId()); } }
@Override public void removeAttribute(final String name) { this.checkInvalid(); final Object oldValue = this.getAttribute(name); if ( oldValue != null ) { this.delegate.removeAttribute(this.getKey(name)); if ( oldValue instanceof HttpSessionBindingListener ) { ((HttpSessionBindingListener)oldValue).valueUnbound(new HttpSessionBindingEvent(this, name)); } if ( this.context.getHttpSessionAttributeListener() != null ) { this.context.getHttpSessionAttributeListener().attributeRemoved(new HttpSessionBindingEvent(this, name, oldValue)); } } }
/** * Notifies listeners that attribute was removed. See {@link SessionNotifier} * {@link #attributeRemoved(RepositoryBackedSession, String, Object)}. * <p> * If the the old value of attribute <code>removedValue</code> is a * HttpSessionBindingListener, it will receive the * {@link HttpSessionBindingEvent}. If there are * {@link HttpSessionAttributeListener} instances associated to * {@link ServletContext}, they will be notified via * {@link HttpSessionAttributeListener#attributeRemoved(HttpSessionBindingEvent)} * . */ @Override public void attributeRemoved(RepositoryBackedSession session, String key, Object removedValue) { if (session instanceof HttpSession && removedValue instanceof HttpSessionBindingListener) { ((HttpSessionBindingListener)removedValue).valueUnbound(new HttpSessionBindingEvent((HttpSession)session, key)); } HttpSessionBindingEvent event = new HttpSessionBindingEvent((HttpSession)session, key); for (HttpSessionAttributeListener listener : descriptor.getHttpSessionAttributeListeners()) { listener.attributeRemoved(event); } }
@Override public void valueBound(final HttpSessionBindingEvent event) { if (session == null && SESSION_KEY.equals(event.getName())) { session = event.getSession(); } else { // don't allow storing this instance under any other session attribute and/or any other session event.getSession().removeAttribute(event.getName()); } }
@Override public void valueUnbound(HttpSessionBindingEvent hsbe) { final ServletContext sc = hsbe.getSession().getServletContext(); final Map<Class, AbstractPerSession> abstractPerSessionMap = (Map<Class, AbstractPerSession>)sc.getAttribute(abstractPerSessionMapPropertyName); for (final Object o : values()) { final AbstractPerSession aps = abstractPerSessionMap.get(o.getClass()); if (aps != null) { aps.destroy(o); } } } }
private synchronized void callAttributeListenersAddedMethod(String key, Object value) { for (int ii = 0; ii < attributeListener.size(); ii++) { HttpSessionBindingEvent event = new HttpSessionBindingEvent(this, key, value); ((HttpSessionAttributeListener) attributeListener.get(ii)) .attributeAdded(event); } }
private synchronized void callAttributeListenersRemovedMethod(String key, Object value) { for (Object anAttributeListener : attributeListener) { HttpSessionBindingEvent event = new HttpSessionBindingEvent(this, key, value); ((HttpSessionAttributeListener) anAttributeListener).attributeRemoved(event); } }
@Override public void setAttribute(String name, @Nullable Object value) { assertIsValid(); Assert.notNull(name, "Attribute name must not be null"); if (value != null) { Object oldValue = this.attributes.put(name, value); if (value != oldValue) { if (oldValue instanceof HttpSessionBindingListener) { ((HttpSessionBindingListener) oldValue).valueUnbound(new HttpSessionBindingEvent(this, name, oldValue)); } if (value instanceof HttpSessionBindingListener) { ((HttpSessionBindingListener) value).valueBound(new HttpSessionBindingEvent(this, name, value)); } } } else { removeAttribute(name); } }
/** * Notifies listeners that attribute was added. See {@link SessionNotifier} * {@link #attributeAdded(RepositoryBackedSession, String, Object)}. * <p> * If the added attribute <code>value</code> is a HttpSessionBindingListener, * it will receive the {@link HttpSessionBindingEvent}. If there are * {@link HttpSessionAttributeListener} instances associated to * {@link ServletContext}, they will be notified via * {@link HttpSessionAttributeListener#attributeAdded(HttpSessionBindingEvent)} * . */ @Override public void attributeAdded(RepositoryBackedSession session, String key, Object value) { // If the if (session instanceof HttpSession && value instanceof HttpSessionBindingListener) { ((HttpSessionBindingListener)value).valueBound(new HttpSessionBindingEvent((HttpSession)session, key)); } HttpSessionBindingEvent event = new HttpSessionBindingEvent((HttpSession)session, key, value); for (HttpSessionAttributeListener listener : descriptor.getHttpSessionAttributeListeners()) { listener.attributeAdded(event); } }
private synchronized void callAttributeListenersReplacedMethod(String key, Object value) { for (int ii = 0; ii < attributeListener.size(); ii++) { HttpSessionBindingEvent event = new HttpSessionBindingEvent(this, key, value); ((HttpSessionAttributeListener) attributeListener.get(ii)) .attributeReplaced(event); } }
protected HttpSessionBindingEvent getHttpSessionBindingEvent( HttpSessionBindingEvent httpSessionBindingEvent) { if (CompoundSessionIdSplitterUtil.hasSessionDelimiter()) { CompoundSessionIdHttpSession compoundSessionIdHttpSession = new CompoundSessionIdHttpSession( httpSessionBindingEvent.getSession()); httpSessionBindingEvent = new HttpSessionBindingEvent( compoundSessionIdHttpSession, httpSessionBindingEvent.getName(), httpSessionBindingEvent.getValue()); } return httpSessionBindingEvent; }
protected void afterBound(String s, Object o) { if (o instanceof HttpSessionBindingListener) { HttpSessionBindingListener listener = (HttpSessionBindingListener) o; HttpSessionBindingEvent event = new HttpSessionBindingEvent(this, s, o); listener.valueBound(event); } }
/** * Notifies listeners that attribute was replaced. See {@link SessionNotifier} * {@link #attributeReplaced(RepositoryBackedSession, String, Object)}. * <p> * If the the old value of attribute <code>replacedValue</code> is a * HttpSessionBindingListener, it will receive the * {@link HttpSessionBindingEvent}. If there are * {@link HttpSessionAttributeListener} instances associated to * {@link ServletContext}, they will be notified via * {@link HttpSessionAttributeListener#attributeReplaced(HttpSessionBindingEvent)} * . */ @Override public void attributeReplaced(RepositoryBackedSession session, String key, Object replacedValue) { if (session instanceof HttpSession && replacedValue instanceof HttpSessionBindingListener) { ((HttpSessionBindingListener)replacedValue).valueUnbound(new HttpSessionBindingEvent((HttpSession)session, key)); } HttpSessionBindingEvent event = new HttpSessionBindingEvent((HttpSession)session, key, replacedValue); for (HttpSessionAttributeListener listener : descriptor.getHttpSessionAttributeListeners()) { listener.attributeReplaced(event); } }