Package com.gargoylesoftware.htmlunit

Examples of com.gargoylesoftware.htmlunit.CookieManager


   
    configurePageCreator(webClient);
   
    // workaround for a bug in HU-2.3 where cookie modified by server are not updated
    // can be removed with HU-2.4
    webClient.setCookieManager(new CookieManager() {
      protected void updateFromState(final HttpState state) {
        super.clearCookies();
        final Cookie[] cookies = state.getCookies();
        for (int i=0; i<cookies.length; ++i)
        {
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(endpointCookie);
        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

      return null;
    }

    public void deleteCookieNamed(String name) {
      CookieManager cookieManager = webClient.getCookieManager();

      URL url = lastPage().getWebResponse().getRequestSettings().getUrl();
      Set<com.gargoylesoftware.htmlunit.util.Cookie> rawCookies =
          webClient.getCookieManager().getCookies(url);
      for (com.gargoylesoftware.htmlunit.util.Cookie cookie : rawCookies) {
        if (name.equals(cookie.getName())) {
          cookieManager.removeCookie(cookie);
        }
      }
    }
View Full Code Here

     * Adds a cookie, as long as cookies are enabled.
     * @see <a href="http://msdn.microsoft.com/en-us/library/ms533693.aspx">MSDN documentation</a>
     * @param newCookie in the format "name=value[;expires=date][;domain=domainname][;path=path][;secure]
     */
    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

TOP

Related Classes of com.gargoylesoftware.htmlunit.CookieManager

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.