Package io.undertow.server.session

Examples of io.undertow.server.session.SessionConfig


        return result;
    }

    @Override
    public String getRequestedSessionId() {
        SessionConfig config = originalServletContext.getSessionConfig();
        return config.findSessionId(exchange);
    }
View Full Code Here


        return result;
    }

    @Override
    public String getRequestedSessionId() {
        SessionConfig config = originalServletContext.getSessionConfig();
        return config.findSessionId(exchange);
    }
View Full Code Here

                sb.append("<button>Save to Session</button>");
                // To retrive the SessionManager use the attachmentKey
                SessionManager sm = exchange
                        .getAttachment(SessionManager.ATTACHMENT_KEY);
                // same goes to SessionConfig
                SessionConfig sessionConfig = exchange
                        .getAttachment(SessionConfig.ATTACHMENT_KEY);
                sb.append("</form>");
                sb.append("<a href='/destroySession'>Destroy Session</a>");
                sb.append("<br/>");

                Session session = sm.getSession(exchange, sessionConfig);
                if (session == null)
                    session = sm.createSession(exchange, sessionConfig);

                sb.append("<ul>");
                for (String string : session.getAttributeNames()) {
                    sb.append("<li>" + string + " : "
                            + session.getAttribute(string) + "</li>");
                }
                sb.append("</ul>");

                exchange.getResponseHeaders().add(Headers.CONTENT_TYPE,
                        "text/html;");
                exchange.getResponseSender().send(sb.toString());
            }
        });
        pathHandler.addPrefixPath("/addToSession", new HttpHandler() {
            @Override
            public void handleRequest(HttpServerExchange exchange)
                    throws Exception {
                SessionManager sm = exchange
                        .getAttachment(SessionManager.ATTACHMENT_KEY);
                SessionConfig sessionConfig = exchange
                        .getAttachment(SessionConfig.ATTACHMENT_KEY);

                Map<String, Deque<String>> reqParams = exchange
                        .getQueryParameters();
                Session session = sm.getSession(exchange, sessionConfig);
                if (session == null)
                    session = sm.createSession(exchange, sessionConfig);

                Deque<String> deque = reqParams.get("attrName");
                Deque<String> dequeVal = reqParams.get("value");
                session.setAttribute(deque.getLast(), dequeVal.getLast());

                exchange.setResponseCode(StatusCodes.TEMPORARY_REDIRECT);
                exchange.getResponseHeaders().put(Headers.LOCATION, "/");
                exchange.getResponseSender().close();
            }
        });
        pathHandler.addPrefixPath("/destroySession", new HttpHandler() {
            public void handleRequest(HttpServerExchange exchange)
                    throws Exception {
                SessionManager sm = exchange
                        .getAttachment(SessionManager.ATTACHMENT_KEY);
                SessionConfig sessionConfig = exchange
                        .getAttachment(SessionConfig.ATTACHMENT_KEY);
                Session session = sm.getSession(exchange, sessionConfig);
                if (session == null)
                    session = sm.createSession(exchange, sessionConfig);
                session.invalidate(exchange);
View Full Code Here

    }

    @Override
    public Object getSession() {
        SessionManager sm = exchange.getAttachment(SessionManager.ATTACHMENT_KEY);
        SessionConfig sessionCookieConfig = exchange.getAttachment(SessionConfig.ATTACHMENT_KEY);
        if(sm != null && sessionCookieConfig != null) {
            return sm.getSession(exchange, sessionCookieConfig);
        }
        return null;
    }
View Full Code Here

     *
     * @param create
     * @return
     */
    public HttpSessionImpl getSession(final HttpServerExchange exchange, boolean create) {
        final SessionConfig c = sessionConfig;
        HttpSessionImpl httpSession = exchange.getAttachment(sessionAttachmentKey);
        if (httpSession != null && httpSession.isInvalid()) {
            exchange.removeAttachment(sessionAttachmentKey);
            httpSession = null;
        }
View Full Code Here

     *
     * @param create
     * @return
     */
    public HttpSessionImpl getSession(final HttpServerExchange exchange, boolean create) {
        final SessionConfig c = sessionConfig;
        HttpSessionImpl httpSession = exchange.getAttachment(sessionAttachmentKey);
        if (httpSession != null && httpSession.isInvalid()) {
            exchange.removeAttachment(sessionAttachmentKey);
            httpSession = null;
        }
View Full Code Here

        return result;
    }

    @Override
    public String getRequestedSessionId() {
        SessionConfig config = servletContext.getSessionConfig();
        return config.findSessionId(exchange);
    }
View Full Code Here

        return result;
    }

    @Override
    public String getRequestedSessionId() {
        SessionConfig config = originalServletContext.getSessionConfig();
        return config.findSessionId(exchange);
    }
View Full Code Here

    }

    public void initDone() {
        initialized = true;
        Set<SessionTrackingMode> trackingMethods = sessionTrackingModes;
        SessionConfig sessionConfig = sessionCookieConfig;
        if (trackingMethods != null && !trackingMethods.isEmpty()) {
            if (sessionTrackingModes.contains(SessionTrackingMode.SSL)) {
                sessionConfig = new SslSessionConfig(deployment.getSessionManager());
            } else {
                if (sessionTrackingModes.contains(SessionTrackingMode.COOKIE) && sessionTrackingModes.contains(SessionTrackingMode.URL)) {
View Full Code Here

        }
        return null;
    }

    public HttpSessionImpl getSession(final ServletContextImpl originalServletContext, final HttpServerExchange exchange, boolean create) {
        SessionConfig c = originalServletContext.getSessionConfig();
        HttpSessionImpl httpSession = exchange.getAttachment(sessionAttachmentKey);
        if (httpSession != null && httpSession.isInvalid()) {
            exchange.removeAttachment(sessionAttachmentKey);
            httpSession = null;
        }
        if (httpSession == null) {
            final SessionManager sessionManager = deployment.getSessionManager();
            Session session = sessionManager.getSession(exchange, c);
            if (session != null) {
                httpSession = SecurityActions.forSession(session, this, false);
                exchange.putAttachment(sessionAttachmentKey, httpSession);
            } else if (create) {

                String existing = c.findSessionId(exchange);
                if (originalServletContext != this) {
                    //this is a cross context request
                    //we need to make sure there is a top level session
                    originalServletContext.getSession(originalServletContext, exchange, true);
                } else if (existing != null) {
                    c.clearSession(exchange, existing);
                }

                final Session newSession = sessionManager.createSession(exchange, c);
                httpSession = SecurityActions.forSession(newSession, this, true);
                exchange.putAttachment(sessionAttachmentKey, httpSession);
View Full Code Here

TOP

Related Classes of io.undertow.server.session.SessionConfig

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.