Package com.alibaba.citrus.service.requestcontext.util

Examples of com.alibaba.citrus.service.requestcontext.util.CookieSupport


    protected void init() throws Exception {
    }

    /** 向response中写入cookie。 */
    protected void writeCookie(HttpServletResponse response, String cookieName, String cookieValue) {
        CookieSupport cookie = new CookieSupport(cookieName, cookieValue);

        if (!StringUtil.isEmpty(domain)) {
            cookie.setDomain(domain);
        }

        if (!StringUtil.isEmpty(path)) {
            cookie.setPath(path);
        }

        if (maxAge > 0) {
            cookie.setMaxAge(maxAge);
        }

        cookie.setHttpOnly(httpOnly);
        cookie.setSecure(secure);

        log.debug("{}", cookie);

        cookie.addCookie(response);
    }
View Full Code Here


    }

    /** 写cookie。 */
    private void writeSessionIDCookie(String cookieValue) {
        CookieConfig cookieConfig = sessionConfig.getId().getCookie();
        CookieSupport cookie = new CookieSupport(cookieConfig.getName(), cookieValue);
        String cookieDomain = cookieConfig.getDomain();

        if (!StringUtil.isEmpty(cookieDomain)) {
            cookie.setDomain(cookieDomain);
        }

        String cookiePath = cookieConfig.getPath();

        if (!StringUtil.isEmpty(cookiePath)) {
            cookie.setPath(cookiePath);
        }

        int cookieMaxAge = cookieConfig.getMaxAge();

        if (cookieMaxAge > 0) {
            cookie.setMaxAge(cookieMaxAge);
        }

        cookie.setHttpOnly(cookieConfig.isHttpOnly());
        cookie.setSecure(cookieConfig.isSecure());

        log.debug("Set-cookie: {}", cookie);

        cookie.addCookie(getResponse());
    }
View Full Code Here

    }

    @Override
    public void addCookie(Cookie cookie) {
        Cookie newCookie = checkCookie(cookie);
        CookieSupport newCookieSupport;

        if (newCookie instanceof CookieSupport) {
            newCookieSupport = (CookieSupport) newCookie;
        } else {
            newCookieSupport = new CookieSupport(newCookie); // 将cookie强制转化成cookie support
        }

        newCookieSupport.addCookie(this); // 通过set-cookie header来添加cookie,以便统一监管
    }
View Full Code Here

        String filteredValue = filterCRLF(value, "cookie " + name);

        if (filteredValue == null) {
            return cookie;
        } else {
            CookieSupport newCookie = new CookieSupport(cookie);
            newCookie.setValue(filteredValue);
            return newCookie;
        }
    }
View Full Code Here

    protected void init() throws Exception {
    }

    /** 向response中写入cookie。 */
    protected void writeCookie(HttpServletResponse response, String cookieName, String cookieValue) {
        CookieSupport cookie = new CookieSupport(cookieName, cookieValue);

        if (!StringUtil.isEmpty(domain)) {
            cookie.setDomain(domain);
        }

        if (!StringUtil.isEmpty(path)) {
            cookie.setPath(path);
        }

        if (maxAge > 0) {
            cookie.setMaxAge(maxAge);
        }

        cookie.setHttpOnly(httpOnly);
        cookie.setSecure(secure);

        log.debug("Set-cookie: {}", cookie);

        cookie.addCookie(response);
    }
View Full Code Here

    /**
     * дcookie��
     */
    private void writeSessionIDCookie(String cookieValue) {
        CookieConfig cookieConfig = sessionConfig.getId().getCookie();
        CookieSupport cookie = new CookieSupport(cookieConfig.getName(), cookieValue);
        String cookieDomain = cookieConfig.getDomain();

        if (!StringUtil.isEmpty(cookieDomain)) {
            cookie.setDomain(cookieDomain);
        }

        String cookiePath = cookieConfig.getPath();

        if (!StringUtil.isEmpty(cookiePath)) {
            cookie.setPath(cookiePath);
        }

        int cookieMaxAge = cookieConfig.getMaxAge();

        if (cookieMaxAge > 0) {
            cookie.setMaxAge(cookieMaxAge);
        }

        cookie.setHttpOnly(cookieConfig.isHttpOnly());
        cookie.setSecure(cookieConfig.isSecure());

        log.debug("Set-cookie: {}", cookie);

        cookie.addCookie(getResponse());
    }
View Full Code Here

    /**
     * ��response��д��cookie��
     */
    protected void writeCookie(HttpServletResponse response, String cookieName, String cookieValue) {
        CookieSupport cookie = new CookieSupport(cookieName, cookieValue);

        if (!StringUtil.isEmpty(domain)) {
            cookie.setDomain(domain);
        }

        if (!StringUtil.isEmpty(path)) {
            cookie.setPath(path);
        }

        if (maxAge > 0) {
            cookie.setMaxAge(maxAge);
        }

        cookie.setHttpOnly(httpOnly);
        cookie.setSecure(secure);

        log.debug("Set-cookie: {}", cookie);

        cookie.addCookie(response);
    }
View Full Code Here

    }

    @Override
    public void addCookie(Cookie cookie) {
        Cookie newCookie = checkCookie(cookie);
        CookieSupport newCookieSupport;

        if (newCookie instanceof CookieSupport) {
            newCookieSupport = (CookieSupport) newCookie;
        } else {
            newCookieSupport = new CookieSupport(newCookie); // ��cookieǿ��ת����cookie support
        }

        newCookieSupport.addCookie(this); // ͨ��set-cookie header�����cookie���Ա�ͳһ���
    }
View Full Code Here

        String filteredValue = filterCRLF(value, "cookie " + name);

        if (filteredValue == null) {
            return cookie;
        } else {
            CookieSupport newCookie = new CookieSupport(cookie);
            newCookie.setValue(filteredValue);
            return newCookie;
        }
    }
View Full Code Here

TOP

Related Classes of com.alibaba.citrus.service.requestcontext.util.CookieSupport

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.