下面列出了javax.ws.rs.core.NewCookie#isSecure() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@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();
}
@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();
}
@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();
}