Java Code Examples for javax.ws.rs.core.NewCookie#getDomain()

The following examples show how to use javax.ws.rs.core.NewCookie#getDomain() . 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: ProxyServlet.java    From openwebbeans-meecrowave with Apache License 2.0 5 votes vote down vote up
protected void addCookie(final HttpServletResponse resp, final Map.Entry<String, NewCookie> cookie) {
    final NewCookie nc = cookie.getValue();
    final Cookie servletCookie = new Cookie(cookie.getKey(), nc.getValue());
    servletCookie.setComment(nc.getComment());
    if (nc.getDomain() != null) {
        servletCookie.setDomain(nc.getDomain());
    }
    servletCookie.setHttpOnly(nc.isHttpOnly());
    servletCookie.setSecure(nc.isSecure());
    servletCookie.setMaxAge(nc.getMaxAge());
    servletCookie.setPath(nc.getPath());
    servletCookie.setVersion(nc.getVersion());
    resp.addCookie(servletCookie);
}
 
Example 2
Source File: NewCookieHeaderProvider.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Override
public String toString(NewCookie value) {

    if (null == value) {
        throw new NullPointerException("Null cookie input");
    }

    StringBuilder sb = new StringBuilder();
    sb.append(value.getName()).append('=').append(maybeQuoteAll(value.getValue()));
    if (value.getComment() != null) {
        sb.append(';').append(COMMENT).append('=').append(maybeQuoteAll(value.getComment()));
    }
    if (value.getDomain() != null) {
        sb.append(';').append(DOMAIN).append('=').append(maybeQuoteAll(value.getDomain()));
    }
    if (value.getMaxAge() != -1) {
        sb.append(';').append(MAX_AGE).append('=').append(value.getMaxAge());
    }
    if (value.getPath() != null) {
        sb.append(';').append(PATH).append('=').append(maybeQuotePath(value.getPath()));
    }
    if (value.getExpiry() != null) {
        sb.append(';').append(EXPIRES).append('=').append(HttpUtils.toHttpDate(value.getExpiry()));
    }
    if (value.isSecure()) {
        sb.append(';').append(SECURE);
    }
    if (value.isHttpOnly()) {
        sb.append(';').append(HTTP_ONLY);
    }
    sb.append(';').append(VERSION).append('=').append(value.getVersion());
    return sb.toString();

}
 
Example 3
Source File: NewCookieHeaderDelegate.java    From everrest with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public String toString(NewCookie cookie) {
    checkArgument(cookie != null);
    StringBuilder sb = new StringBuilder();
    sb.append(cookie.getName()).append('=').append(addQuotesIfHasWhitespace(cookie.getValue()));

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

    if (cookie.getComment() != null) {
        sb.append(';').append("Comment=").append(addQuotesIfHasWhitespace(cookie.getComment()));
    }

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

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

    if (cookie.getMaxAge() != -1) {
        sb.append(';').append("Max-Age=").append(addQuotesIfHasWhitespace(Integer.toString(cookie.getMaxAge())));
    }

    if (cookie.getExpiry() != null) {
        sb.append(';').append("Expires=");
        sb.append(HeaderHelper.formatDate(cookie.getExpiry()));
    }

    if (cookie.isSecure()) {
        sb.append(';').append("Secure");
    }

    if (cookie.isHttpOnly()) {
        sb.append(';').append("HttpOnly");
    }

    return sb.toString();
}