Errai 3.0.1-SNAPSHOT

org.jboss.errai.security.shared.api
Class UserCookieEncoder

java.lang.Object
  extended by org.jboss.errai.security.shared.api.UserCookieEncoder

public class UserCookieEncoder
extends Object

Encodes and decodes User objects persisted in Errai Security cookies.


Field Summary
static String USER_COOKIE_NAME
          The cookie name for the Errai Security cookie.
 
Constructor Summary
UserCookieEncoder()
           
 
Method Summary
static User fromCookieValue(String userString)
          Decode a persisted User from a cookie value.
static String toCookieValue(User user)
          Encode a cookie value used for persisting a User.
static String unquoteIfNeeded(String s)
          Unquotes a cookie value if it has been quoted and escaped by the Jetty web server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USER_COOKIE_NAME

public static final String USER_COOKIE_NAME
The cookie name for the Errai Security cookie.

See Also:
Constant Field Values
Constructor Detail

UserCookieEncoder

public UserCookieEncoder()
Method Detail

toCookieValue

public static String toCookieValue(User user)
Encode a cookie value used for persisting a User.

Parameters:
user - The user to be persisted.
Returns:
A marhsalled User that can be decoded by fromCookieValue(String).
See Also:
User, USER_COOKIE_NAME, fromCookieValue(String)

fromCookieValue

public static User fromCookieValue(String userString)
Decode a persisted User from a cookie value.

Parameters:
userString - A cookie value that has been persisted using toCookieValue(User).
Returns:
The User object persisted in the given cookie value.
See Also:
User, USER_COOKIE_NAME, toCookieValue(User)

unquoteIfNeeded

public static String unquoteIfNeeded(String s)
Unquotes a cookie value if it has been quoted and escaped by the Jetty web server.

This method is based on (originally copied from) the org.mortbay.util.QuotedStringTokenizer.unquote method from Jetty 6.1.25.

Parameters:
s - the cookie value that may or may not be quoted.
Returns:
an unquoted version of the string, or the given input string if it was not quoted.

Errai 3.0.1-SNAPSHOT

Copyright © 2013-2014 JBoss, a division of Red Hat. All Rights Reserved.