Package com.saperion.ngc.util
Class CookieUtil
- java.lang.Object
-
- com.saperion.ngc.util.CookieUtil
-
public final class CookieUtil extends java.lang.Object
Utility class to store and read from cookies.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
SA_WEB_CLIENT_LAST_USER
Name of the user-cookie.static java.lang.String
SA_WEB_CLIENT_LAST_USER_LANGUAGE
Name of the user-language-cookie.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
getCookieContent(java.lang.String cookieName)
Reads from a cookie.static java.lang.String
getLastLocaleFromCookie()
Reads the last active Locale from a cookie.static AuthenticationInformation
getLastLoginFromCookie()
Reads the last active user from a cookie.static void
setCookie(java.lang.String name, java.lang.String content, int maxAge)
Sets a new cookie.static void
storeLastLocale(java.lang.String locale)
Stores a cookie with information about the last active user Locale.static void
storeLastUser()
Stores a cookie with information about the last active user.
-
-
-
Field Detail
-
SA_WEB_CLIENT_LAST_USER
public static final java.lang.String SA_WEB_CLIENT_LAST_USER
Name of the user-cookie.- See Also:
- Constant Field Values
-
SA_WEB_CLIENT_LAST_USER_LANGUAGE
public static final java.lang.String SA_WEB_CLIENT_LAST_USER_LANGUAGE
Name of the user-language-cookie.- See Also:
- Constant Field Values
-
-
Method Detail
-
setCookie
public static void setCookie(java.lang.String name, java.lang.String content, int maxAge)
Sets a new cookie.- Parameters:
name
- cookie namecontent
- cookie contentmaxAge
- maximum age of this cookie in seconds
-
getCookieContent
public static java.lang.String getCookieContent(java.lang.String cookieName)
Reads from a cookie.- Parameters:
cookieName
- name of the cookie to read from- Returns:
- cookie content as string or null, if no cookie with the specified name was found
-
storeLastUser
public static void storeLastUser()
Stores a cookie with information about the last active user. The cookie contains a string like 'Username;Mandant;Type'.
-
getLastLoginFromCookie
public static AuthenticationInformation getLastLoginFromCookie()
Reads the last active user from a cookie. Will NOT retrieve the password.- Returns:
- last user or null if cookie was not found or contains invalid content
-
storeLastLocale
public static void storeLastLocale(java.lang.String locale)
Stores a cookie with information about the last active user Locale. The cookie contains a string like 'Locale'.- Parameters:
locale
- like de_DE or en_US
-
getLastLocaleFromCookie
public static java.lang.String getLastLocaleFromCookie()
Reads the last active Locale from a cookie.- Returns:
- last locale or null if cookie was not found or contains invalid content
-
-