For information about the user and user preferences (including locale, time zone, currency, etc).
| Type | Name and description |
|---|---|
java.util.Map<java.lang.String, java.lang.Object> |
getContext()A per-user context like the execution context for but data specific to a user and maintained through service calls, etc unlike ExecutionContext.getContext(). |
java.lang.String |
getCurrencyUomId()@return String The active ISO currency code from user preference or system default. |
java.util.Locale |
getLocale()@return Locale The active Locale from user preference or system default. |
java.lang.String |
getLoginKey()Get a login key for the active user. |
java.util.Calendar |
getNowCalendar()Get a Calendar object with user's TimeZone and Locale set, and set to same time as returned by getNowTimestamp(). |
java.sql.Timestamp |
getNowTimestamp()Get the current date and time in a Timestamp object. |
java.util.List<java.sql.Timestamp> |
getPeriodRange(java.lang.String period, java.lang.String poffset) |
java.lang.String |
getPreference(java.lang.String preferenceKey)Get the value of a user preference. |
java.util.TimeZone |
getTimeZone()@return TimeZone The active TimeZone from user preference or system default. |
EntityValue |
getUserAccount()@return EntityValue for the current active user (the moqui.security.UserAccount entity). |
java.util.Set<java.lang.String> |
getUserGroupIdSet() |
java.lang.String |
getUserId()@return ID of the current active user (from the moqui.security.UserAccount entity). |
java.lang.String |
getUsername()@return Username of the current active user (NOT the UserAccount.userId, may even be a username from another system). |
EntityValue |
getVisit()
|
java.lang.String |
getVisitId()
|
java.lang.String |
getVisitUserId()
|
boolean |
hasPermission(java.lang.String userPermissionId)Check to see if current user has the given permission. |
boolean |
isInGroup(java.lang.String userGroupId)Check to see if current user is in the given group (UserGroup). |
boolean |
loginAnonymousIfNoUser()If no user is logged in consider an anonymous user logged in. |
boolean |
loginUser(java.lang.String username, java.lang.String password)Authenticate a user and make active in this ExecutionContext (and session of WebExecutionContext if applicable). |
boolean |
loginUserKey(java.lang.String loginKey)Authenticate a user and make active using a login key |
void |
logoutUser()Remove (logout) active user. |
void |
setCurrencyUomId(java.lang.String uomId)Set the user's Time Zone. |
void |
setEffectiveTime(java.sql.Timestamp effectiveTime)Set an EffectiveTime for the current context which will then be returned from the getNowTimestamp() method. |
void |
setLocale(java.util.Locale locale)Set the user's Locale. |
void |
setPreference(java.lang.String preferenceKey, java.lang.String preferenceValue)Set the value of a user preference. |
void |
setTimeZone(java.util.TimeZone tz)Set the user's Time Zone. |
A per-user context like the execution context for but data specific to a user and maintained through service calls, etc unlike ExecutionContext.getContext(). Used for security data, etc such as entity filter values.
Get a login key for the active user.
Get a Calendar object with user's TimeZone and Locale set, and set to same time as returned by getNowTimestamp().
Get the current date and time in a Timestamp object. This is either the current system time, or the Effective Time if that has been set for this context (allowing testing of past and future system behavior). All internal tools and code built on the framework should treat this as the actual current time.
Get the value of a user preference.
preferenceKey - The key for the preference, looked up on UserPreference.preferenceKey
Check to see if current user has the given permission. To have a permission a user must be in a group (UserGroupMember => UserGroup) that has the given permission (UserGroupPermission).
userPermissionId - Permission ID for record in UserPermission or any arbitrary permission name (does
not have to be pre-configured, ie does not have to be in the UserPermission entity's table)Check to see if current user is in the given group (UserGroup). The user group concept in Moqui is similar to the "role" concept in many security contexts (including Apache Shiro which is used in Moqui) though that term is avoided because of the use of the term "role" for the Party part of the Mantle Universal Data Model.
userGroupId - The user group ID to check against.If no user is logged in consider an anonymous user logged in. For internal purposes to run things that require authentication.
Authenticate a user and make active in this ExecutionContext (and session of WebExecutionContext if applicable).
username - An ID to match the UserAccount.username field.password - The user's current password.Authenticate a user and make active using a login key
Remove (logout) active user.
Set the user's Time Zone. This is used in this context and saved to the database for future contexts.
uomId - The new currency UOM ID (ISO currency code).Set an EffectiveTime for the current context which will then be returned from the getNowTimestamp() method. This is used to test past and future behavior of applications.
effectiveTime - The new effective date/time. Pass in null to reset to the default of the current system time.Set the user's Locale. This is used in this context and saved to the database for future contexts.
locale - The new Locale.Set the value of a user preference.
preferenceKey - The key for the preference, used to create or update a record with UserPreference.preferenceKeypreferenceValue - The value to set on the preference, set in UserPreference.preferenceValueSet the user's Time Zone. This is used in this context and saved to the database for future contexts.
tz - The new TimeZone.