b.append(cookie.getMaxAge()); if (cookie.isSecure()) { b.append(";Secure");
b.append(cookie.getMaxAge()); if (cookie.isSecure()) { b.append(";Secure");
b.append(DateUtil.formatDate(cookie.getExpiry(), OLD_COOKIE_PATTERN)); if (cookie.isSecure()) b.append(";Secure"); if (cookie.isHttpOnly())
private String secureOrEmpty(NewCookie cookie) { if (cookie.isSecure()) { return ";secure"; } return ""; } }
public String toString(NewCookie value) { StringBuilder sb = new StringBuilder(); sb.append(value.getName()).append('=').append(value.getValue()); if (value.getComment() != null) { sb.append(';').append(COMMENT).append('=').append(value.getComment()); } if (value.getDomain() != null) { sb.append(';').append(DOMAIN).append('=').append(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(value.getPath()); } if (value.isSecure()) { sb.append(';').append(SECURE); } sb.append(';').append(VERSION).append('=').append(value.getVersion()); return sb.toString(); }
/** * {@inheritDoc} */ public String toString(NewCookie cookie) { StringBuffer sb = new StringBuffer(); sb.append(cookie.getName()).append('=').append(HeaderHelper.addQuotesIfHasWhitespace(cookie.getValue())); sb.append(';').append("Version=").append(cookie.getVersion()); if (cookie.getComment() != null) sb.append(';').append("Comment=").append(HeaderHelper.addQuotesIfHasWhitespace(cookie.getComment())); if (cookie.getDomain() != null) sb.append(';').append("Domain=").append(HeaderHelper.addQuotesIfHasWhitespace(cookie.getDomain())); if (cookie.getPath() != null) sb.append(';').append("Path=").append(HeaderHelper.addQuotesIfHasWhitespace(cookie.getPath())); if (cookie.getMaxAge() != -1) sb.append(';').append("Max-Age=").append(HeaderHelper.addQuotesIfHasWhitespace("" + cookie.getMaxAge())); if (cookie.isSecure()) sb.append(';').append("Secure"); return sb.toString(); }
if (cookie.isSecure()) { buf.append(";Secure");
public void addNewCookie(NewCookie cookie) { Cookie cook = new Cookie(cookie.getName(), cookie.getValue()); cook.setMaxAge(cookie.getMaxAge()); cook.setVersion(cookie.getVersion()); if (cookie.getDomain() != null) cook.setDomain(cookie.getDomain()); if (cookie.getPath() != null) cook.setPath(cookie.getPath()); cook.setSecure(cookie.isSecure()); if (cookie.getComment() != null) cook.setComment(cookie.getComment()); response.addCookie(cook); }
public String toString(NewCookie cookie) { StringBuilder b = new StringBuilder(); b.append(cookie.getName()).append('='); WriterUtil.appendQuotedIfWhitespace(b, cookie.getValue()); b.append(";").append("Version=").append(cookie.getVersion()); if (cookie.getComment() != null) { b.append(";Comment="); WriterUtil.appendQuotedIfWhitespace(b, cookie.getComment()); } if (cookie.getDomain() != null) { b.append(";Domain="); WriterUtil.appendQuotedIfWhitespace(b, cookie.getDomain()); } if (cookie.getPath() != null) { b.append(";Path="); WriterUtil.appendQuotedIfWhitespace(b, cookie.getPath()); } if (cookie.getMaxAge()!=-1) { b.append(";Max-Age="); b.append(cookie.getMaxAge()); } if (cookie.isSecure()) b.append(";Secure"); return b.toString(); }
@Test public void shouldPersistAsInRfcErrata() { final ClientSideState clientSideState = new ClientSideState(RFC_EDITION, RFC_TIME, RFC_IV_SOURCE, SIMPLE_SERIALIZATION, SIMPLE_DESERIALIZATION, ClientSideState.DEFAULT_TIMEOUT); final NewCookie cookie = clientSideState.persist("id", "/path", "a state string"); assertThat(cookie).isNotNull(); assertThat(cookie.getName()).isEqualTo("id"); assertThat(cookie.getValue()) .isEqualTo("pzSOjcNui9-HWS_Qk1Pwpg|MTM0NzI2NTk1NQ|dGlk|tL3lJPf2nUSFMN6dtVXJTw|uea1fgC67RmOxfpNz8gMbnPWfDA"); assertThat(cookie.getPath()).isEqualTo("/path"); assertThat(cookie.isHttpOnly()).isFalse(); assertThat(cookie.isSecure()).isTrue(); }
@Override public void addNewCookie(NewCookie cookie) { Cookie cook = new Cookie(cookie.getName(), cookie.getValue()); cook.setMaxAge(cookie.getMaxAge()); cook.setVersion(cookie.getVersion()); if (cookie.getDomain() != null) cook.setDomain(cookie.getDomain()); if (cookie.getPath() != null) cook.setPath(cookie.getPath()); cook.setSecure(cookie.isSecure()); if (cookie.getComment() != null) cook.setComment(cookie.getComment()); if (cookie.isHttpOnly()) cook.setHttpOnly(true); this.response.addCookie(cook); } };
@Override public void addNewCookie(NewCookie cookie) { Cookie cook = new Cookie(cookie.getName(), cookie.getValue()); cook.setMaxAge(cookie.getMaxAge()); cook.setVersion(cookie.getVersion()); if (cookie.getDomain() != null) cook.setDomain(cookie.getDomain()); if (cookie.getPath() != null) cook.setPath(cookie.getPath()); cook.setSecure(cookie.isSecure()); if (cookie.getComment() != null) cook.setComment(cookie.getComment()); if (cookie.isHttpOnly()) cook.setHttpOnly(true); this.response.addCookie(cook); } };
b.append(cookie.getMaxAge()); if (cookie.isSecure()) { b.append(";Secure");
@Test public void shouldPersistAsInRfcErrata() { final ClientSideState clientSideState = new ClientSideState(RFC_EDITION, RFC_TIME, RFC_IV_SOURCE, SIMPLE_SERIALIZATION, SIMPLE_DESERIALIZATION, ClientSideState.DEFAULT_TIMEOUT); final NewCookie cookie = clientSideState.persist("id", "/path", "a state string"); assertThat(cookie).isNotNull(); assertThat(cookie.getName()).isEqualTo("id"); assertThat(cookie.getValue()) .isEqualTo("pzSOjcNui9-HWS_Qk1Pwpg|MTM0NzI2NTk1NQ|dGlk|tL3lJPf2nUSFMN6dtVXJTw|uea1fgC67RmOxfpNz8gMbnPWfDA"); assertThat(cookie.getPath()).isEqualTo("/path"); assertThat(cookie.isHttpOnly()).isFalse(); assertThat(cookie.isSecure()).isTrue(); }
@Test public void shouldPersistAsInRfcErrata() { final ClientSideState clientSideState = new ClientSideState(RFC_EDITION, RFC_TIME, RFC_IV_SOURCE, SIMPLE_SERIALIZATION, SIMPLE_DESERIALIZATION, ClientSideState.DEFAULT_TIMEOUT); final NewCookie cookie = clientSideState.persist("id", "/path", "a state string"); assertThat(cookie).isNotNull(); assertThat(cookie.getName()).isEqualTo("id"); assertThat(cookie.getValue()) .isEqualTo("pzSOjcNui9-HWS_Qk1Pwpg|MTM0NzI2NTk1NQ|dGlk|tL3lJPf2nUSFMN6dtVXJTw|uea1fgC67RmOxfpNz8gMbnPWfDA"); assertThat(cookie.getPath()).isEqualTo("/path"); assertThat(cookie.isHttpOnly()).isFalse(); assertThat(cookie.isSecure()).isTrue(); }
@Override public String toString(NewCookie cookie) { if (cookie == null) { throw new IllegalArgumentException("Cookie is null"); } return buildCookie(cookie.getName(), cookie.getValue(), cookie.getPath(), cookie.getDomain(), cookie.getVersion(), cookie.getComment(), cookie.getMaxAge(), cookie.isSecure()); }
public String toString(NewCookie cookie) { if (cookie == null) { throw new IllegalArgumentException(Messages.getMessage("cookieIsNull")); //$NON-NLS-1$ } return buildCookie(cookie.getName(), cookie.getValue(), cookie.getPath(), cookie .getDomain(), cookie.getVersion(), cookie.getComment(), cookie.getMaxAge(), cookie .isSecure()); }
/** * Converts the Restlet JAX-RS NewCookie to a CookieSettings. * * @param newCookie * @return the converted CookieSetting * @throws IllegalArgumentException */ public static CookieSetting toRestletCookieSetting(NewCookie newCookie) throws IllegalArgumentException { if (newCookie == null) { return null; } return new CookieSetting(newCookie.getVersion(), newCookie.getName(), newCookie.getValue(), newCookie.getPath(), newCookie.getDomain(), newCookie.getComment(), newCookie.getMaxAge(), newCookie.isSecure()); }
/** * Converts the Restlet JAX-RS NewCookie to a CookieSettings. * * @param newCookie * @return the converted CookieSetting * @throws IllegalArgumentException */ public static CookieSetting toRestletCookieSetting(NewCookie newCookie) throws IllegalArgumentException { if (newCookie == null) { return null; } return new CookieSetting(newCookie.getVersion(), newCookie.getName(), newCookie.getValue(), newCookie.getPath(), newCookie.getDomain(), newCookie.getComment(), newCookie.getMaxAge(), newCookie.isSecure()); }
private void saveCookies(Exchange exchange, Client client, CookieHandler cookieHandler) { if (cookieHandler != null) { CookieStore cookieStore = cookieHandler.getCookieStore(exchange); for (NewCookie newCookie: client.getResponse().getCookies().values()) { HttpCookie cookie = new HttpCookie(newCookie.getName(), newCookie.getValue()); cookie.setComment(newCookie.getComment()); cookie.setDomain(newCookie.getDomain()); cookie.setHttpOnly(newCookie.isHttpOnly()); cookie.setMaxAge(newCookie.getMaxAge()); cookie.setPath(newCookie.getPath()); cookie.setSecure(newCookie.isSecure()); cookie.setVersion(newCookie.getVersion()); cookieStore.add(client.getCurrentURI(), cookie); } } }