public class Users
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ADMIN_OX |
static java.lang.String |
SHARED_OX |
Constructor and Description |
---|
Users() |
Modifier and Type | Method and Description |
---|---|
static java.util.prefs.Preferences |
getAdminPreferences()
Preferences of the admin user.
|
static java.lang.String |
getCurrent()
The user name associated to the current thread.
|
static java.lang.String |
getCurrentIP() |
static java.util.prefs.Preferences |
getCurrentPreferences()
Preferences of the user associated to the current thread.
|
static UserInfo |
getCurrentUserInfo()
Info about the current logged user.
|
static java.util.prefs.Preferences |
getSharedPreferences()
Preferences of the shared user.
|
static void |
setCurrent(HttpServletRequest request)
Associated the user of the request to the current thread.
|
static void |
setCurrent(java.lang.String userName)
Associated an user to the current thread.
|
static void |
setCurrentUserInfo(UserInfo userInfo)
Associated the UserInfo object to the current thread.
|
public static final java.lang.String ADMIN_OX
public static final java.lang.String SHARED_OX
public static java.lang.String getCurrent()
null
if no user logged.public static java.lang.String getCurrentIP()
public static java.util.prefs.Preferences getCurrentPreferences() throws java.util.prefs.BackingStoreException
You can use this preference for read and update user preferences, in this way:
// Obtain preferences for the current user and node (an arbitrary category of your choice). Preferences preferences = Users.getCurrentPreferences().node("mynode"); // Read a property value boolean rowsHidden = preferences.getBoolean(ROWS_HIDDEN, false); // Modify and save a property preferences.putBoolean(ROWS_HIDDEN, rowsHidden); preferences.flush();Remember, you must call flush() always in order to make persistent the changes in preferences.
java.util.prefs.BackingStoreException
- Some problem on load preferences.public static java.util.prefs.Preferences getAdminPreferences() throws java.util.prefs.BackingStoreException
java.util.prefs.BackingStoreException
- Some problem on load preferences.public static java.util.prefs.Preferences getSharedPreferences() throws java.util.prefs.BackingStoreException
java.util.prefs.BackingStoreException
- Some problem on load preferences.public static UserInfo getCurrentUserInfo()
It only returns meaningful info if we are inside a portal.
public static void setCurrent(java.lang.String userName)
public static void setCurrentUserInfo(UserInfo userInfo)
public static void setCurrent(HttpServletRequest request)
Takes into account JetSpeed 1.5 user managament, althought it's generic enought to work in any servlet container.