Example usage for org.apache.commons.httpclient.cookie CookieSpecBase match

List of usage examples for org.apache.commons.httpclient.cookie CookieSpecBase match

Introduction

In this page you can find the example usage for org.apache.commons.httpclient.cookie CookieSpecBase match.

Prototype

public Cookie[] match(String paramString1, int paramInt, String paramString2, boolean paramBoolean,
            Cookie[] paramArrayOfCookie) 

Source Link

Usage

From source file:org.glite.slcs.shibclient.ShibbolethClient.java

private Cookie[] getMatchingCookies(String host, String path) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("search all Cookies matching for host:" + host + " path:" + path);
    }/*from   w w  w  .j  av a 2 s . co m*/
    List<Cookie> matchingCookies = new ArrayList<Cookie>();
    Cookie[] cookies = this.httpClient_.getState().getCookies();
    CookieSpecBase cookieSpecBase = new CookieSpecBase();
    for (int i = 0; i < cookies.length; i++) {
        Cookie cookie = cookies[i];
        if (cookieSpecBase.match(host, 443, path, true, cookie)) {
            LOG.debug("Cookie " + cookie + " matched");
            matchingCookies.add(cookie);
        }
    }
    return (Cookie[]) matchingCookies.toArray(new Cookie[matchingCookies.size()]);
}

From source file:org.glite.slcs.shibclient.ShibbolethClient.java

private Cookie[] getMatchingCookies(String name, String host, String path) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("search Cookie matching name:" + name + " host:" + host + " path:" + path);
    }/*from  w  w  w . ja  va2 s.c o m*/
    List<Cookie> matchingCookies = new ArrayList<Cookie>();
    Cookie[] cookies = this.httpClient_.getState().getCookies();
    CookieSpecBase cookieSpecBase = new CookieSpecBase();
    for (int i = 0; i < cookies.length; i++) {
        Cookie cookie = cookies[i];
        if (cookieSpecBase.match(host, 443, path, true, cookie)) {
            if (cookie.getName().equals(name)) {
                LOG.debug("Cookie " + cookie + " matched");
                matchingCookies.add(cookie);
            }
        }
    }
    return (Cookie[]) matchingCookies.toArray(new Cookie[matchingCookies.size()]);
}