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

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


    /**
     * ��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

    /**
     * д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

        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

    @Test
    public void reuseSessionId() throws Exception {
        // request 1
        invokeNoopServlet("/servlet");

        CookieSupport cookie = new CookieSupport("JSESSIONID", "1234567890ABCDEFG");

        cookie.setPath("/");
        cookie.addCookie(response);

        commitToClient();

        assertEquals("1234567890ABCDEFG", clientResponse.getNewCookieValue("JSESSIONID")); // new added cookie
View Full Code Here

        // Ԥ��ȷ��session id �Ա����
        sessionId = "1234567890ABCDEFG";
        invokeNoopServlet("/servlet");

        CookieSupport cookie = new CookieSupport("JSESSIONID", sessionId);

        cookie.setPath("/");
        cookie.addCookie(response);

        commitToClient();

        assertEquals(sessionId, clientResponse.getNewCookieValue("JSESSIONID")); // new added cookie
View Full Code Here

    @Test
    public void session_reuseSessionID() throws Exception {
        // request 1
        invokeNoopServlet("/servlet");

        CookieSupport cookie = new CookieSupport("JSESSIONID", "1234567890ABCDEFG");

        cookie.setPath("/");
        cookie.addCookie(response);

        commitToClient();

        assertEquals("1234567890ABCDEFG", clientResponse.getNewCookieValue("JSESSIONID")); // new added cookie
View Full Code Here

    @Test
    public void checkCookie_modifiy_cookieSupport() {
        createResponse(new MyCookieInterceptor() {
            public Cookie checkCookie(Cookie cookie) {
                return new CookieSupport(cookie, "new" + cookie.getName());
            }
        });

        responseMock.addHeader("Set-Cookie", "newtest=value");
View Full Code Here

        assertEquals(true, session.isNew());

        session.setAttribute("count", 0);

        // α��checksum cookie�����ݲ�ƥ��
        CookieSupport cookie = new CookieSupport("myCookieStoresum", "hello");
        cookie.setDomain(".taobao.com");
        cookie.setPath("/");
        cookie.setMaxAge(10);
        cookie.addCookie(newResponse);

        requestContexts.commitRequestContext(requestContext);
        commitToClient();

        // check new added cookie
View Full Code Here

        invokeNoopServlet("/servlet");
        noSession = true; // ��Ҫ����session���ֹ���cookies
        initRequestContext("session_cookie");

        // α��checksum cookie��������ƥ��
        CookieSupport cookie = new CookieSupport("JSESSIONID", sessionID);
        cookie.setDomain(".taobao.com");
        cookie.setPath("/");
        cookie.setMaxAge(10);
        cookie.addCookie(newResponse);

        cookie = new CookieSupport("myCookieStore0", myCookieStore0);
        cookie.setDomain(".taobao.com");
        cookie.setPath("/");
        cookie.setMaxAge(10);
        cookie.addCookie(newResponse);

        cookie = new CookieSupport("myCookieStoresum", myCookieStoresum + "|hello");
        cookie.setDomain(".taobao.com");
        cookie.setPath("/");
        cookie.setMaxAge(10);
        cookie.addCookie(newResponse);

        requestContexts.commitRequestContext(requestContext);
        commitToClient();

        // check new added cookie
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.