Example usage for org.apache.http.cookie Cookie getPath

List of usage examples for org.apache.http.cookie Cookie getPath

Introduction

In this page you can find the example usage for org.apache.http.cookie Cookie getPath.

Prototype

String getPath();

Source Link

Document

Returns the path attribute of the cookie.

Usage

From source file:com.woonoz.proxy.servlet.CookieFormatter.java

public static CookieFormatter createFromApacheCookie(org.apache.http.cookie.Cookie cookie) {
    return new CookieFormatter(cookie.getName(), cookie.getValue(), cookie.getPath());
}

From source file:net.emphased.lastcontact.CookieFileStore.java

private static String[] cookieToStringArray(Cookie cookie) {
    return new String[] { cookie.getName(), cookie.getValue(), String.valueOf(cookie.getExpiryDate().getTime()),
            cookie.getPath(), cookie.getDomain(), };
}

From source file:org.qi4j.library.shiro.AbstractServletTestSupport.java

protected static void soutCookies(Iterable<Cookie> cookies) {
    StringBuilder sb = new StringBuilder();
    sb.append("\nLogging cookies for the curious");
    for (Cookie eachCookie : cookies) {
        sb.append("\t").append(eachCookie.getName()).append(": ").append(eachCookie.getValue()).append(" ( ")
                .append(eachCookie.getDomain()).append(" - ").append(eachCookie.getPath()).append(" )");
    }//from  w ww  .  ja  v  a  2 s .c  om
    System.out.println(sb.append("\n").toString());
}

From source file:org.droidparts.http.CookieJar.java

private static boolean isEqual(Cookie first, Cookie second) {
    boolean equal = first.getName().equals(second.getName()) && first.getDomain().equals(second.getDomain())
            && first.getPath().equals(second.getPath());
    return equal;
}

From source file:Main.java

@Deprecated
// Deprecated because this uses org.apache.http, which is itself deprecated
public static HttpCookie servletCookieFromApacheCookie(org.apache.http.cookie.Cookie apacheCookie) {
    if (apacheCookie == null) {
        return null;
    }/*from ww w .  j a va 2  s.co  m*/

    String name = apacheCookie.getName();
    String value = apacheCookie.getValue();

    HttpCookie cookie = new HttpCookie(name, value);

    value = apacheCookie.getDomain();
    if (value != null) {
        cookie.setDomain(value);
    }
    value = apacheCookie.getPath();
    if (value != null) {
        cookie.setPath(value);
    }
    cookie.setSecure(apacheCookie.isSecure());

    value = apacheCookie.getComment();
    if (value != null) {
        cookie.setComment(value);
    }

    // version
    cookie.setVersion(apacheCookie.getVersion());

    // From the Apache source code, maxAge is converted to expiry date using the following formula
    // if (maxAge >= 0) {
    //     setExpiryDate(new Date(System.currentTimeMillis() + maxAge * 1000L));
    // }
    // Reverse this to get the actual max age

    Date expiryDate = apacheCookie.getExpiryDate();
    if (expiryDate != null) {
        long maxAge = (expiryDate.getTime() - System.currentTimeMillis()) / 1000;
        // we have to lower down, no other option
        cookie.setMaxAge((int) maxAge);
    }

    // return the servlet cookie
    return cookie;
}

From source file:org.droidparts.http.CookieJar.java

private static String toString(Cookie cookie) {
    StringBuilder sb = new StringBuilder();
    sb.append(cookie.getName());//from  w  ww . j av a  2 s.co  m
    sb.append(SEP);
    sb.append(cookie.getValue());
    sb.append(SEP);
    sb.append(cookie.getDomain());
    sb.append(SEP);
    sb.append(cookie.getPath());
    sb.append(SEP);
    sb.append(cookie.getExpiryDate().getTime());
    return sb.toString();
}

From source file:org.droidparts.net.http.CookieJar.java

private static String toString(Cookie cookie) {
    StringBuilder sb = new StringBuilder();
    sb.append(cookie.getName());//from  w  ww  . j  a  v  a  2s.com
    sb.append(SEP);
    sb.append(cookie.getValue());
    sb.append(SEP);
    sb.append(cookie.getDomain());
    sb.append(SEP);
    sb.append(cookie.getPath());
    Date expiryDate = cookie.getExpiryDate();
    if (expiryDate != null) {
        sb.append(SEP);
        sb.append(expiryDate.getTime());
    }
    return sb.toString();
}

From source file:cn.ttyhuo.common.MyApplication.java

public static void getJavaCookieStore(java.net.CookieStore jCookieStore) {
    if (cookieStore == null)
        return;//from w  ww. j  av  a2  s.  co m

    for (Cookie h : cookieStore.getCookies()) {
        HttpCookie newCookie = new HttpCookie(h.getName(), h.getValue());
        newCookie.setVersion(h.getVersion());
        newCookie.setDomain(h.getDomain());
        newCookie.setPath(h.getPath());
        newCookie.setSecure(h.isSecure());
        newCookie.setComment(h.getComment());
        jCookieStore.add(URI.create("http://" + h.getDomain()), newCookie);
    }
}

From source file:fr.mixit.android.utils.NetworkUtils.java

static Cookie getCookie(DefaultHttpClient httpClient) {
    Cookie c = null;/*  www  .ja v a  2s  . c om*/
    for (final Cookie cookie : httpClient.getCookieStore().getCookies()) {
        if (cookie != null) {
            c = cookie;
            if (DEBUG_MODE) {
                Log.i("AppInfosFragment", "cookieInfos : "//
                        + "comment:" + cookie.getComment() + //
                        " commentURL:" + cookie.getCommentURL() + //
                        " domain:" + cookie.getDomain() + //
                        " name:" + cookie.getName() + //
                        " path:" + cookie.getPath() + //
                        " value:" + cookie.getValue() + //
                        " version:" + cookie.getVersion() + //
                        " expiryDate:" + cookie.getExpiryDate());
            }
        }
    }

    return c;
}

From source file:cookies.FlashIT.java

@Test
public void testFlash() throws Exception {
    HttpResponse<String> response = get("/flash").asString();
    Cookie flash = response.cookie("wisdom_FLASH");
    assertThat(flash).isNotNull();//from w w  w  .jav a  2  s . c om
    assertThat(flash.getPath()).isEqualTo("/");
    assertThat(flash.getValue()).contains("flash_error=Fail").contains("flash_success=Success")
            .contains("message=Hello");

    response = get("/flash/no").asString();
    flash = response.cookie("wisdom_FLASH");
    assertThat(flash).isNull();
    assertThat(response.body()).contains("Hello").contains("Success !");

    response = get("/flash/no").asString();
    flash = response.cookie("wisdom_FLASH");
    assertThat(flash).isNull();
    assertThat(response.body()).doesNotContain("Hello").doesNotContain("Success !");
}