本文整理汇总了Java中javax.ws.rs.core.Cookie.DEFAULT_VERSION属性的典型用法代码示例。如果您正苦于以下问题:Java Cookie.DEFAULT_VERSION属性的具体用法?Java Cookie.DEFAULT_VERSION怎么用?Java Cookie.DEFAULT_VERSION使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.ws.rs.core.Cookie
的用法示例。
在下文中一共展示了Cookie.DEFAULT_VERSION属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newDeletedCookie
/**
* <p>newDeletedCookie.</p>
*
* @param name a {@link java.lang.String} object.
* @return a {@link javax.ws.rs.core.NewCookie} object.
*/
public static NewCookie newDeletedCookie(String name) {
/**
* Create a new instance.
*
* @param name the name of the cookie
* @param value the value of the cookie
* @param path the URI path for which the cookie is valid
* @param domain the host domain for which the cookie is valid
* @param version the version of the specification to which the cookie complies
* @param comment the comment
* @param maxAge the maximum age of the cookie in seconds
* @param expiry the cookie expiry date.
* @param secure specifies whether the cookie will only be sent over a secure connection
* @param httpOnly if {@code true} make the cookie HTTP only, i.e. only visible as part of an HTTP request.
* @throws IllegalArgumentException if name is {@code null}.
* @since 2.0
*/
return new NewCookie(name, DELETED_COOKIE_VALUE, "/", null, Cookie.DEFAULT_VERSION, null, 0, null, false, true);
}
示例2: newHttpOnlyCookie
/**
* <p>newHttpOnlyCookie.</p>
*
* @param name a {@link java.lang.String} object.
* @param value a {@link java.lang.String} object.
* @return a {@link javax.ws.rs.core.NewCookie} object.
*/
public static NewCookie newHttpOnlyCookie(String name, String value) {
/**
* Create a new instance.
*
* @param name the name of the cookie
* @param value the value of the cookie
* @param path the URI path for which the cookie is valid
* @param domain the host domain for which the cookie is valid
* @param version the version of the specification to which the cookie complies
* @param comment the comment
* @param maxAge the maximum age of the cookie in seconds
* @param expiry the cookie expiry date.
* @param secure specifies whether the cookie will only be sent over a secure connection
* @param httpOnly if {@code true} make the cookie HTTP only, i.e. only visible as part of an HTTP request.
* @throws IllegalArgumentException if name is {@code null}.
* @since 2.0
*/
return new NewCookie(name, value, null, null, Cookie.DEFAULT_VERSION, null, -1, null, false, true);
}
示例3: toString
@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();
}
示例4: createToken
@Override
public void createToken(String token) {
NewCookie cookie = new NewCookie(
SESSION_ID_KEY,
token,
"/",
null,
Cookie.DEFAULT_VERSION,
null,
SessionFeature.CLIENT_MAX_AGE,
null,
Requests.getSecurityContext().isSecure(),
true);
Requests.setProperty(SET_COOKIE_KEY, cookie);
}
示例5: logout
@Override
public Response logout(String token, Cookie tokenAccessCookie, UriInfo uriInfo) {
NewCookie newCookie = new NewCookie(AdaptiveEnvironmentFilter.COOKIE_NAME, COOKIE_DELETE_VALUE, "/", null, Cookie.DEFAULT_VERSION, null, 1, new Date(0), false, false);
return Response.ok().cookie(newCookie).build();
}
示例6: addCookie
/**
* Return the generated hash as cookie
*
* @param rb
* The {@link ResponseBuilder} to complete.
* @param login
* User login used to match the hash.
* @param hash
* The cookie value also stored in data base.
* @return the {@link ResponseBuilder} including cookie value. Same object
* than the original parameter.
*/
public ResponseBuilder addCookie(final ResponseBuilder rb, final String login, final String hash) {
if (hash != null) {
// There is a preference, add it to a cookie
final Date expire = new Date(System.currentTimeMillis() + COOKIE_AGE * DateUtils.MILLIS_PER_SECOND);
final NewCookie cookieHash = new NewCookie(PREFERRED_COOKIE_HASH, login + "|" + hash, "/", null, Cookie.DEFAULT_VERSION, null,
COOKIE_AGE, expire, true, true);
rb.cookie(cookieHash);
}
return rb;
}