Package io.undertow.server.handlers

Examples of io.undertow.server.handlers.Cookie


        this.cookieName = cookieName;
    }

    @Override
    public String readAttribute(final HttpServerExchange exchange) {
        Cookie cookie = exchange.getRequestCookies().get(cookieName);
        if (cookie == null) {
            return null;
        }
        return cookie.getValue();
    }
View Full Code Here


    }

    protected Host findStickyHost(HttpServerExchange exchange) {
        Map<String, Cookie> cookies = exchange.getRequestCookies();
        for (String cookieName : sessionCookieNames) {
            Cookie sk = cookies.get(cookieName);
            if (sk != null) {
                int index = sk.getValue().indexOf('.');

                if (index == -1) {
                    continue;
                }
                String route = sk.getValue().substring(index + 1);
                index = route.indexOf('.');
                if (index != -1) {
                    route = route.substring(0, index);
                }
                return routes.get(route);
View Full Code Here

        this.manager = storage;
    }

    @Override
    public AuthenticationMechanismOutcome authenticate(HttpServerExchange exchange, SecurityContext securityContext) {
        Cookie cookie = exchange.getRequestCookies().get(cookieName);
        if (cookie != null) {
            final String ssoId = cookie.getValue();
            try (SingleSignOn sso = this.manager.findSingleSignOn(ssoId)) {
                if (sso != null) {
                    Account verified = securityContext.getIdentityManager().verify(sso.getAccount());
                    if (verified == null) {
                        //we return not attempted here to allow other mechanisms to proceed as normal
View Full Code Here

    }

    @Override
    public void handleRequest(HttpServerExchange exchange) throws Exception {

        Cookie sessionId = exchange.getRequestCookies().get(sessionCookieName);
        if (sessionId != null) {
            int part = sessionId.getValue().indexOf('.');
            if (part != -1) {
                sessionId.setValue(sessionId.getValue().substring(0, part));
            }
        }
        exchange.addResponseWrapper(wrapper);
        next.handleRequest(exchange);
    }
View Full Code Here

    private class JvmRouteWrapper implements ConduitWrapper<StreamSinkConduit> {

        @Override
        public StreamSinkConduit wrap(ConduitFactory<StreamSinkConduit> factory, HttpServerExchange exchange) {

            Cookie sessionId = exchange.getResponseCookies().get(sessionCookieName);
            if (sessionId != null) {
                StringBuilder sb = new StringBuilder(sessionId.getValue());
                sb.append('.');
                sb.append(jvmRoute);
                sessionId.setValue(sb.toString());
            }
            return factory.create();
        }
View Full Code Here

    private String comment;


    public void attachSession(final HttpServerExchange exchange, final Session session) {
        exchange.putAttachment(attachmentKey, session);
        Cookie cookie = new CookieImpl(name, session.getId())
                .setPath(path)
                .setDomain(domain)
                .setSecure(secure)
                .setHttpOnly(httpOnly)
                .setComment(comment);
        if(maxAge > 0) {
            cookie.setMaxAge(maxAge);
        }
        CookieImpl.addResponseCookie(exchange, cookie);

    }
View Full Code Here

        CookieImpl.addResponseCookie(exchange, cookie);

    }

    public void clearSession(final HttpServerExchange exchange, final Session session) {
        Cookie cookie = new CookieImpl(name, session.getId())
                .setPath(path)
                .setDomain(domain)
                .setSecure(secure)
                .setHttpOnly(httpOnly)
                .setMaxAge(0);
View Full Code Here

    @Override
    public String findSessionId(final HttpServerExchange exchange) {
        Map<String, Cookie> cookies = CookieImpl.getRequestCookies(exchange);
        if (cookies != null) {
            Cookie sessionId = cookies.get(name);
            if (sessionId != null) {
                return sessionId.getValue();
            }
        }
        return null;
    }
View Full Code Here

        return originalUrl;
    }

    @Override
    public void setSessionId(final HttpServerExchange exchange, final String sessionId) {
        Cookie cookie = new CookieImpl(name, sessionId)
                .setPath(path)
                .setDomain(domain)
                .setSecure(secure)
                .setHttpOnly(httpOnly)
                .setComment(comment);
        if (maxAge > 0) {
            cookie.setMaxAge(maxAge);
        }
        exchange.setResponseCookie(cookie);
    }
View Full Code Here

        exchange.setResponseCookie(cookie);
    }

    @Override
    public void clearSession(final HttpServerExchange exchange, final String sessionId) {
        Cookie cookie = new CookieImpl(name, sessionId)
                .setPath(path)
                .setDomain(domain)
                .setSecure(secure)
                .setHttpOnly(httpOnly)
                .setMaxAge(0);
View Full Code Here

TOP

Related Classes of io.undertow.server.handlers.Cookie

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.