Package io.undertow.servlet.spec

Examples of io.undertow.servlet.spec.HttpSessionImpl


                        }
                    }
                    ByteBuffer data = ByteBuffer.wrap(buffer, 0, read);
                    SavedRequest request = new SavedRequest(data, exchange.getRequestMethod(), exchange.getRequestURI());
                    final ServletRequestContext sc = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
                    HttpSessionImpl session = sc.getCurrentServetContext().getSession(exchange, true);
                    session.setAttribute(SESSION_KEY, request);
                } catch (IOException e) {
                    UndertowLogger.REQUEST_IO_LOGGER.ioException(e);
                }
            }
        }
View Full Code Here


        //we have some old data
        PersistentSession result = data.remove(incomingSessionId);
        if (result != null) {
            long time = System.currentTimeMillis();
            if (time < result.getExpiration().getTime()) {
                final HttpSessionImpl session = servletContext.getSession(exchange, true);
                final HttpSessionEvent event = new HttpSessionEvent(session);
                for (Map.Entry<String, Object> entry : result.getSessionData().entrySet()) {

                    if (entry.getValue() instanceof HttpSessionActivationListener) {
                        ((HttpSessionActivationListener) entry.getValue()).sessionWillPassivate(event);
                    }
                    session.setAttribute(entry.getKey(), entry.getValue());
                }
            }
        }
        next.handleRequest(exchange);
    }
View Full Code Here

        this.servletContext = servletContext;
    }

    @Override
    public void sessionCreated(final Session session, final HttpServerExchange exchange) {
        final HttpSessionImpl httpSession = SecurityActions.forSession(session, servletContext, true);
        applicationListeners.sessionCreated(httpSession);
    }
View Full Code Here

    @Override
    public void sessionDestroyed(final Session session, final HttpServerExchange exchange, final SessionDestroyedReason reason) {
        ThreadSetupAction.Handle handle = null;
        try {
            final HttpSessionImpl httpSession = SecurityActions.forSession(session, servletContext, false);
            if (reason == SessionDestroyedReason.TIMEOUT) {
                handle = threadSetup.setup(exchange);
            }
            applicationListeners.sessionDestroyed(httpSession);
            //we make a defensive copy here, as there is no guarantee that the underlying session map
View Full Code Here

    @Override
    public void attributeAdded(final Session session, final String name, final Object value) {
        if(name.startsWith(IO_UNDERTOW)) {
            return;
        }
        final HttpSessionImpl httpSession = SecurityActions.forSession(session, servletContext, false);
        applicationListeners.httpSessionAttributeAdded(httpSession, name, value);
        if (value instanceof HttpSessionBindingListener) {
            ((HttpSessionBindingListener) value).valueBound(new HttpSessionBindingEvent(httpSession, name, value));
        }
    }
View Full Code Here

    @Override
    public void attributeUpdated(final Session session, final String name, final Object value, final Object old) {
        if(name.startsWith(IO_UNDERTOW)) {
            return;
        }
        final HttpSessionImpl httpSession = SecurityActions.forSession(session, servletContext, false);
        if (old != value) {
            if (old instanceof HttpSessionBindingListener) {
                ((HttpSessionBindingListener) old).valueUnbound(new HttpSessionBindingEvent(httpSession, name, old));
            }
            applicationListeners.httpSessionAttributeReplaced(httpSession, name, old);
View Full Code Here

    @Override
    public void attributeRemoved(final Session session, final String name, final Object old) {
        if(name.startsWith(IO_UNDERTOW)) {
            return;
        }
        final HttpSessionImpl httpSession = SecurityActions.forSession(session, servletContext, false);
        if (old != null) {
            applicationListeners.httpSessionAttributeRemoved(httpSession, name, old);
            if (old instanceof HttpSessionBindingListener) {
                ((HttpSessionBindingListener) old).valueUnbound(new HttpSessionBindingEvent(httpSession, name, old));
            }
View Full Code Here

                        }
                        headers.putAll(entry.getHeaderName(), entry);
                    }
                    SavedRequest request = new SavedRequest(buffer, read, exchange.getRequestMethod(), exchange.getRequestURI(), exchange.getRequestHeaders());
                    final ServletRequestContext sc = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
                    HttpSessionImpl session = sc.getCurrentServletContext().getSession(exchange, true);
                    Session underlyingSession;
                    if(System.getSecurityManager() == null) {
                        underlyingSession = session.getSession();
                    } else {
                        underlyingSession = AccessController.doPrivileged(new HttpSessionImpl.UnwrapSessionAction(session));
                    }
                    underlyingSession.setAttribute(SESSION_KEY, request);
                } catch (IOException e) {
View Full Code Here

        //we have some old data
        PersistentSession result = data.remove(incomingSessionId);
        if (result != null) {
            long time = System.currentTimeMillis();
            if (time < result.getExpiration().getTime()) {
                final HttpSessionImpl session = servletContext.getSession(exchange, true);
                final HttpSessionEvent event = new HttpSessionEvent(session);
                for (Map.Entry<String, Object> entry : result.getSessionData().entrySet()) {

                    if (entry.getValue() instanceof HttpSessionActivationListener) {
                        ((HttpSessionActivationListener) entry.getValue()).sessionDidActivate(event);
                    }
                    if(entry.getKey().startsWith(HttpSessionImpl.IO_UNDERTOW)) {
                        session.getSession().setAttribute(entry.getKey(), entry.getValue());
                    } else {
                        session.setAttribute(entry.getKey(), entry.getValue());
                    }
                }
            }
        }
        next.handleRequest(exchange);
View Full Code Here

        public void handleNotification(SecurityNotification notification) {
            EventType eventType = notification.getEventType();
            switch (eventType) {
                case AUTHENTICATED:
                    if (isCacheable(notification)) {
                        HttpSessionImpl httpSession = servletContext.getSession(notification.getExchange(), true);
                        Session session;
                        if(System.getSecurityManager() == null) {
                            session = httpSession.getSession();
                        } else {
                            session = AccessController.doPrivileged(new HttpSessionImpl.UnwrapSessionAction(httpSession));
                        }
                        // It is normal for this notification to be received when using a previously cached session - in that
                        // case the IDM would have been given an opportunity to re-load the Account so updating here ready for
                        // the next request is desired.
                        session.setAttribute(ATTRIBUTE_NAME,
                                new AuthenticatedSession(notification.getAccount(), notification.getMechanism()));
                    }
                    break;
                case LOGGED_OUT:
                    HttpSessionImpl httpSession = servletContext.getSession(notification.getExchange(), false);
                    if (httpSession != null) {
                        Session session;
                        if (System.getSecurityManager() == null) {
                            session = httpSession.getSession();
                        } else {
                            session = AccessController.doPrivileged(new HttpSessionImpl.UnwrapSessionAction(httpSession));
                        }
                        session.removeAttribute(ATTRIBUTE_NAME);
                    }
View Full Code Here

TOP

Related Classes of io.undertow.servlet.spec.HttpSessionImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.