Java Code Examples for javax.ws.rs.core.Cookie#getPath()

The following examples show how to use javax.ws.rs.core.Cookie#getPath() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CookieHeaderDelegate.java    From everrest with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public String toString(Cookie cookie) {
    if (cookie == null) {
        throw new IllegalArgumentException();
    }
    StringBuilder sb = new StringBuilder();

    sb.append("$Version=").append(cookie.getVersion()).append(';');

    sb.append(cookie.getName()).append('=').append(addQuotesIfHasWhitespace(cookie.getValue()));

    if (cookie.getDomain() != null) {
        sb.append(';').append("$Domain=").append(addQuotesIfHasWhitespace(cookie.getDomain()));
    }

    if (cookie.getPath() != null) {
        sb.append(';').append("$Path=").append(addQuotesIfHasWhitespace(cookie.getPath()));
    }

    return sb.toString();
}
 
Example 2
Source File: CookieHeaderProvider.java    From msf4j with Apache License 2.0 5 votes vote down vote up
@Override
public String toString(Cookie cookie) {
    StringBuilder sb = new StringBuilder();

    if (cookie.getVersion() != Cookie.DEFAULT_VERSION) {
        sb.append(VERSION).append('=').append(cookie.getVersion()).append(';');
    }
    sb.append(cookie.getName()).append('=').append(cookie.getValue());
    if (cookie.getPath() != null) {
        sb.append(';').append(PATH).append('=').append(cookie.getPath());
    }
    if (cookie.getDomain() != null) {
        sb.append(';').append(DOMAIN).append('=').append(cookie.getDomain());
    }
    if (cookie instanceof NewCookie) {
        NewCookie newCookie = (NewCookie) cookie;
        if (newCookie.getMaxAge() != NewCookie.DEFAULT_MAX_AGE) {
            sb.append(';').append(MAX_AGE).append('=').append(newCookie.getMaxAge());
        }
        if (newCookie.getComment() != null) {
            sb.append(';').append(COMMENT).append('=').append(newCookie.getComment());
        }
        if (newCookie.getExpiry() != null) {
            //All HTTP date/time stamps MUST be represented in Greenwich Mean Time (GMT)
            dateFormat.setTimeZone(TimeZone.getTimeZone(GMT_TIMEZONE));
            sb.append(';').append(EXPIRES).append('=').append(dateFormat.format(newCookie.getExpiry()));
        }
        if (newCookie.isSecure()) {
            sb.append(';').append(SECURE);
        }
        if (newCookie.isHttpOnly()) {
            sb.append(';').append(HTTP_ONLY);
        }
    }
    return sb.toString();
}
 
Example 3
Source File: CookieHeaderProvider.java    From cxf with Apache License 2.0 5 votes vote down vote up
public String toString(Cookie c) {
    StringBuilder sb = new StringBuilder();

    if (c.getVersion() != 0) {
        sb.append(VERSION).append('=').append(c.getVersion()).append(';');
    }
    sb.append(c.getName()).append('=').append(NewCookieHeaderProvider.maybeQuoteAll(c.getValue()));
    if (c.getPath() != null) {
        sb.append(';').append(PATH).append('=').append(NewCookieHeaderProvider.maybeQuotePath(c.getPath()));
    }
    if (c.getDomain() != null) {
        sb.append(';').append(DOMAIN).append('=').append(NewCookieHeaderProvider.maybeQuoteAll(c.getDomain()));
    }
    return sb.toString();
}