Package com.gargoylesoftware.htmlunit.util

Examples of com.gargoylesoftware.htmlunit.util.Cookie


    }

    public HttpResponse send() throws IOException {
        client.getOptions().setTimeout(timeoutInMillis);
        for (String cookie: cookies.keySet()) {
            client.getCookieManager().addCookie(new Cookie(domain, cookie, cookies.get(cookie)));
        }
        client.getCookieManager().setCookiesEnabled(applyCookies);
        client.getOptions().setRedirectEnabled(followRedirects);
        WebRequest request = new WebRequest(requestUrl(), method);
        request.setRequestParameters(requestParameters());
View Full Code Here


    /**
     * Remove the sdk cookies from the client so that we can test that login is forced.
     */
    private void removeSdkCookies() {
        CookieManager cookieManager = getWebClient().getCookieManager();
        Cookie securityContextCookie =
            cookieManager.getCookie(SecurityContextCookieStore.SECURITY_CONTEXT_COOKIE_NAME);
        Cookie endpointCookie = cookieManager.getCookie(SecurityContextUtil.FORCE_FORCE_ENDPOINT);
        Cookie sidCookie = cookieManager.getCookie(SecurityContextUtil.FORCE_FORCE_SESSION);
       
        cookieManager.removeCookie(securityContextCookie);
        cookieManager.removeCookie(endpointCookie);
        cookieManager.removeCookie(sidCookie);
    }
View Full Code Here

        cookieManager.removeCookie(sidCookie);
    }
   
    private void corruptSecurityContextCookie() {
        CookieManager cookieManager = getWebClient().getCookieManager();
        Cookie securityContextCookie =
            cookieManager.getCookie(SecurityContextCookieStore.SECURITY_CONTEXT_COOKIE_NAME);

        cookieManager.removeCookie(securityContextCookie);

        securityContextCookie =
            new Cookie(SecurityContextCookieStore.SECURITY_CONTEXT_COOKIE_NAME,
                    securityContextCookie.getValue().substring(5, 30));
       
        cookieManager.addCookie(securityContextCookie);
    }
View Full Code Here

        @Override
        public String call() throws Exception {

            WebClient client = new WebClient();
            client.setThrowExceptionOnFailingStatusCode(false);
            client.getCookieManager().addCookie(new Cookie(contextPath.getHost(), "JSESSIONID", jsessionid));

            Page page = client.getPage(contextPath + "introspect?mode=" + mode + "&cid=" + cid);

            if (!(page instanceof TextPage)) {
                return "" + page.getWebResponse().getStatusCode();
View Full Code Here

        @Override
        public String call() throws Exception {

            WebClient client = new WebClient();
            client.setThrowExceptionOnFailingStatusCode(false);
            client.getCookieManager().addCookie(new Cookie(contextPath.getHost(), "JSESSIONID", jsessionid));

            Page page = client.getPage(contextPath + "introspect?mode=" + mode + "&cid=" + cid);

            if (!(page instanceof TextPage)) {
                return "" + page.getWebResponse().getStatusCode();
View Full Code Here

            }
            else {
                notifyIncorrectness("set-cookie http-equiv meta tag: unknown attribute '" + partName + "'.");
            }
        }
        final Cookie cookie = new Cookie(host, name, value, path, expires, secure);
        getPage().getWebClient().getCookieManager().addCookie(cookie);
    }
View Full Code Here

    public void jsxSet_cookie(final String newCookie) {
        final CookieManager cookieManager = getHtmlPage().getWebClient().getCookieManager();
        if (cookieManager.isCookiesEnabled()) {
            URL url = getHtmlPage().getWebResponse().getRequestSettings().getUrl();
            url = replaceForCookieIfNecessary(url);
            final Cookie cookie = buildCookie(newCookie, url);
            cookieManager.addCookie(cookie);
            LOG.debug("Added cookie: " + cookie);
        }
        else {
            LOG.debug("Skipped adding cookie: " + newCookie);
View Full Code Here

        // Build the cookie.
        final String domain = (String) atts.get("domain");
        final String path = (String) atts.get("path");
        final boolean secure = (atts.get("secure") != null);
        final Cookie cookie = new Cookie(domain, name, value, path, expires, secure);

        return cookie;
    }
View Full Code Here

        @Override
        public String call() throws Exception {

            WebClient client = new WebClient();
            client.setThrowExceptionOnFailingStatusCode(false);
            client.getCookieManager().addCookie(new Cookie(contextPath.getHost(), "JSESSIONID", jsessionid));

            Page page = client.getPage(contextPath + "introspect?mode=" + mode + "&cid=" + cid);

            if (!(page instanceof TextPage)) {
                return "" + page.getWebResponse().getStatusCode();
View Full Code Here

    public void ShouldparseCookieWithExpiryButNoValueCorrectly() {
        Date testDate = getTestDate(2010, 8, 3, 9, 25, 3);
        final String rawCookie = "USER=; expires=Tue, 03-Aug-2010 09:25:03 GMT; path=/";

        CookieParser cookieParser = new CookieParser();
        Cookie cookie = cookieParser.parseCookie("localhost", rawCookie);

        assertThat(cookie.getName(), is("USER"));
        assertThat(cookie.getValue(), is(""));
        assertThat(cookie.getExpires(), is(testDate));
    }
View Full Code Here

TOP

Related Classes of com.gargoylesoftware.htmlunit.util.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.