Class User
- All Implemented Interfaces:
RenameSoftDeletedInNameConflict
U) is a Pricefx login account: its identity fields (login name, name, email), authentication settings (password, Two-Factor Authentication, Single Sign-On), and the Roles, UserGroups and BusinessRoles that govern what it can access.
The current user is available in a logic via api.user(), which returns the whole User object, or api.user(fieldName), which returns a single value. Supported field names are loginName, firstName, lastName, email, additionalInfo1 to additionalInfo4, and currentLocale (the language of the current request locale, not a stored field). Field names are case-insensitive. An unknown field name returns null. Both calls return null when there is no current user.
Example:
def email = api.user()?.email
def loginName = api.user("loginName")
-
Nested Class Summary
Nested classes/interfaces inherited from class PersistedObject
PersistedObject.BatchDelete, PersistedObject.BulkloadFilterCheckCallback, PersistedObject.ComputedFieldMapping, PersistedObject.ComputedFields, PersistedObject.HardDelete, PersistedObject.ImportManagerEnabled, PersistedObject.PersistedObjectMeta, PersistedObject.VirtualField, PersistedObject.VirtualFieldMapping, PersistedObject.VirtualFields, PersistedObject.VirtualSearchFields, PersistedObject.VirtualSortFields -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected static final StringFields inherited from class PartitionedObject
FIELD_PARTITION, FIELD_PARTITIONID, PARTITION_FILTER_NAME, PARTITION_FILTER_PARAMFields inherited from class PersistedObject
FIELD_CREATEDATE, FIELD_CREATEDBY, FIELD_DELETEDATE, FIELD_DELETEDBY, FIELD_ID, FIELD_ISDELETED, FIELD_LASTUPDATEBY, FIELD_LASTUPDATEDATE, FIELD_VERSION -
Constructor Summary
ConstructorsConstructorDescriptionUser()Creates a User that isactivatedand hasworkflow emailingenabled.User(Partition partition) Creates a User in the given partition that isactivatedand hasworkflow emailingenabled.User(Partition partition, String loginName, String firstName, String lastName, String clearTextPassword) Creates a User in the given partition that isactivatedand hasworkflow emailingenabled. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddRelevantFilter(Search search) Adds this User's access restriction filter tosearch, if one applies.voidauditOperation(AuditOperation operation, User byUser, CommandContext context, PersistedObjectService objService, String details) Records a security-relevant operation performed on this User (for example, an edit) as aSecurityAuditTrailentry.booleancanEdit(User user, ValidationVisitor validationVisitor, PersistedObjectService objService, Map<String, Object> fieldsToEdit) Returns whetherusermay edit this User, in addition to the superclass's own check: if this User isplatform-managed, only asystem usermay edit it.booleancheckPassword(String clearTextPassword) Returns whether the given clear-text password matches this User's stored password hash, usinggetHashMethod()and the stored (or, if not set, the login-name-based fallback) salt.@NotNull StringReturnsgetFirstName()andgetLastName()joined with a space, skipping either one if it isnullor empty.static voidcreateOrUpdateSupportUser(PersistedObjectService objService) Internal server method, not for use in logics: creates the built-inpricefx-supportuser, or updates it if it exists.static voidcreateRootUser(PersistedObjectService objService) Internal server method, not for use in logics: creates the built-inrootsystem user.static voidcreateSupportUser(PersistedObjectService objService) Internal server method, not for use in logics: creates the built-inpricefx-supportuser.voidInternal server method, not for use in logics: refreshes the cached user data of this User's partition on all nodes after the current transaction commits.Returns the first of four general-purpose extension fields on this User, with no built-in meaning.Returns the second of four general-purpose extension fields on this User, with no built-in meaning.Returns the third of four general-purpose extension fields on this User, with no built-in meaning.Returns the fourth of four general-purpose extension fields on this User, with no built-in meaning.Returns everyUserGroupthis User belongs to, whether directly assigned (seegetGroups()) or granted via aBusinessRole(seegetBusinessRoles()).Returns the unique names ofgetAllRoles(), that is, every role this User has, whether directly assigned or granted via aBusinessRole.Set<Role> Returns everyRolethis User has, whether directly assigned (seegetRoles()) or granted via aBusinessRole(seegetBusinessRoles()).Set<BusinessRole> Returns theBusinessRoles assigned to this User.Returns this User's Customer access restriction resolved into aFilter, built fromgetCustomerFilterCriteria(), ornullif no restriction is set.Returns this User's Customer access restriction, as a JSON-encoded advanced filter criteria.Returns theUserGroupunique name that the server copies onto the edit-access user-group restriction of a new object when this User creates it, but only if thedefaultGroupsapplication setting enables this for the object's type.Returns theUserGroupunique name that the server copies onto the view-details-access user-group restriction of a new object when this User creates it, but only if thedefaultGroupsapplication setting enables this for the object's type.getEmail()Returns this User's email address.Returns the locale used for notifications to this User, such as emails and notification titles.Returns server/environment metadata attached to this User for an "extended" login response (for example, cluster name, feature-flag context, max form content size).Returns this User's first name.Returns this User's login name qualified by its partition's unique name, formatted as"<partition>/<loginName>".Returns theUserGroups directly assigned to this User, not including groups granted via aBusinessRole.Returns the algorithm used to hash this User's password, or"SHA-1"if none is recorded (accounts created before the hash method was tracked).Returns the date/time this User last logged in, ornullif never.Returns this User's last name.Returns the date/time this User last agreed to the Terms of Use.Returns the version identifier of the Terms of Use this User last agreed to.Returns this User's login name.Returns whether this is a no-session (API-only) account: whentrue, a successful Basic Authentication does not create a browser session (no session cookie or CSRF token is issued), andsetPassword(String)hashes the password with the separately configurable no-session hash method.Returns the date/time after which this User's password is expired and must be changed, ornullif this User hasSSO-onlylogin enabled (an SSO-only account never has a password expiry) or no expiry is set.Returns this User's stored password hash.Returns the salt used to hash this User's password.Set<Permission> Returns every permission granted by this User'sroles(direct or granted via aBusinessRole).Returns whether this User's account is managed by Platform Manager rather than by a partition administrator.Returns this User's Product access restriction, as a JSON-encoded advanced filter criteria.Returns whether this User is a partition administrator contact.Returns whether Two-Factor Authentication (TFA) is required for this User specifically.Returns the unique names of theRoles directly assigned to this User (not including roles granted via aBusinessRole).Set<Role> getRoles()Returns theRoles directly assigned to this User, not including roles granted via aBusinessRole.Returns this User's Seller access restriction resolved into aFilter, built fromgetSellerFilterCriteria(), ornullif no restriction is set.Returns this User's Seller access restriction, as a JSON-encoded advanced filter criteria.String[]Returns the fields that form this User's business key, used to match records on import and update:loginNameonly.Returns this User's Product access restriction resolved into aFilter, built fromgetProductFilterCriteria(), ornullif no restriction is set.Returns whether this User may only log in via Single Sign-On (SSO), not with a password.Returns the unique name of the Wizard Dashboard assigned to this User.booleanhasModuleAccess(ApplicationModule module) Returns whether any of this User'sroles(direct or granted via aBusinessRole) belongs to the given application module.static voidinvalidateUsersOnAllNodes(String partitionName) Internal server method, not for use in logics: refreshes the cached user data of the given partition on all nodes.Returns whether this User's account is active.booleanReturnstrue, so the server records a security audit entry when a User is created, updated or deleted through the standard data commands (seeauditOperation(AuditOperation, User, CommandContext, PersistedObjectService, String)).booleanReturns whethersetLastLogin(LocalDateTime)has recorded this User's first-ever login on this object (that is,getLastLogin()transitioned fromnull).booleanReturns whether this User belongs to the givenUserGroup, whether directly or via aBusinessRole.booleanReturns whether this is the built-inrootsystem user of theSYSTEMpartition.Returns whether this User receives workflow-related email notifications.ReturnsgetLastLogin()formatted as a display string, under the JSON property namelastLogin.voidonSavedOrUpdated(PersistedObjectService objService) Runs the superclass's own post-save logic, then callsemitUserUpdateActionAfterCommit()to invalidate, on all nodes, the cached users, user groups, roles and business roles of this User's partition once the transaction commits.voidonSaveOrUpdate(PersistedObjectService objService) Runs the superclass's own save/update logic, then clearsgetPasswordExpiry()if this User isSSO-only.Returns the stored password expiry formatted as a display string, under the JSON property namepasswordExpiry.voidrenameSoftDeleted(PersistedObjectService objService) Renames this soft-deleted User, viaobjService, so itsgetLoginName()no longer conflicts with another User's login name.voidsetActivated(Boolean activated) Sets whether this User's account is active.voidsetAdditionalInfo1(BigDecimal additionalInfo1) Sets the first of four general-purpose extension fields on this User.voidsetAdditionalInfo2(BigDecimal additionalInfo2) Sets the second of four general-purpose extension fields on this User.voidsetAdditionalInfo3(String additionalInfo3) Sets the third of four general-purpose extension fields on this User.voidsetAdditionalInfo4(String additionalInfo4) Sets the fourth of four general-purpose extension fields on this User.voidsetCustomerFilterCriteria(String customerFilterCriteria) Sets this User's Customer access restriction, as a JSON-encoded advanced filter criteria.voidsetDefaultUserGroupEdit(String defaultUserGroup) Sets theUserGroupunique name that the server copies onto the edit-access user-group restriction of a new object when this User creates it, if thedefaultGroupsapplication setting enables this for the object's type.voidsetDefaultUserGroupViewDetails(String defaultUserViewDetails) Sets theUserGroupunique name that the server copies onto the view-details-access user-group restriction of a new object when this User creates it, if thedefaultGroupsapplication setting enables this for the object's type.voidSets this User's email address, lowercased.voidsetEmailLocale(String emailLocale) Sets the locale used for notifications to this User.voidsetExtendedData(Map<String, Object> extendedData) Sets the server/environment metadata attached to this User for an "extended" login response.voidsetFirstName(String firstName) Sets this User's first name.voidsetLastLogin(LocalDateTime lastLogin) Sets the date/time this User last logged in.voidsetLastName(String lastName) Sets this User's last name.voidsetLastTermsOfUseAgreedDate(LocalDateTime lastTermsOfUseAgreedDate) Sets the date/time this User last agreed to the Terms of Use.voidsetLastTermsOfUseVersionAgreed(String lastTermsOfUseVersionAgreed) Sets the version identifier of the Terms of Use this User last agreed to.voidsetLoginName(String name) Sets this User's login name, lowercased.voidsetNoSession(Boolean noSession) Sets whether this is a no-session (API-only) account.voidsetPassword(String clearTextPassword) Sets this User's password from clear text: generates a new random salt, hashes the password with it using the configured hash method, and records the salt and hash method used.voidsetPasswordExpiry(LocalDateTime passwordExpiry) Sets the date/time after which this User's password is expired and must be changed.voidsetPasswordHash(String passwordHash) Sets this User's stored password hash directly.voidsetPasswordSalt(String passwordSalt) Sets the salt used to hash this User's password directly.voidsetPlatformManaged(Boolean platformManaged) Sets whether this User's account is managed by Platform Manager rather than by a partition administrator.voidsetProductFilterCriteria(String productFilterExpression) Sets this User's Product access restriction, as a JSON-encoded advanced filter criteria.voidsetReceiveAdminEmail(Boolean receiveAdminEmail) Sets whether this User is a partition administrator contact.voidsetRequireTFA(Boolean requireTFA) Sets whether Two-Factor Authentication (TFA) is required for this User specifically.voidsetSellerFilterCriteria(String sellerFilterCriteria) Sets this User's Seller access restriction, as a JSON-encoded advanced filter criteria.voidsetSsoOnly(Boolean ssoOnly) Sets whether this User may only log in via Single Sign-On (SSO), not with a password.voidsetUniqueLoginName(String name) Sets this User's login name to"<name>_<currentTimeMillis>", lowercased, so that it does not collide with an existing login name.voidsetWizardDashboardName(String wizardDashboardName) Sets the unique name of the Wizard Dashboard assigned to this User.voidsetWorkflowEmailingActivated(Boolean workflowEmailingActivated) Sets whether this User receives workflow-related email notifications.static voidupdateSupportUser(PersistedObjectService objService, User supportUser) Internal server method, not for use in logics: setsSUPPORTas the only directly assigned role of the built-inpricefx-supportuser, activates it, and saves it.booleanvalidate(ValidationVisitor validationVisitor, PersistedObjectService objService) Validates thatgetAdditionalInfo3(),getAdditionalInfo4(),getLoginName(),getLastName(),getFirstName()andgetEmail()are all at most 255 characters, in addition to the superclass's own validation, recording a validation error for the first field found too long.Methods inherited from class PartitionedObject
addUniqueConstraint, getLoginNameByUserId, getPartition, setPartition, toStringMethods inherited from class PersistedObject
bumpVersion, canAdd, canDelete, canEdit, canRead, canReadElements, createDate, entityIsHardDeleted, entityIsMassDeletable, entityIsSafeInserted, entityIsSafeInserted, getBulkloadMap, getBusinessKey, getCreateDate, getCreatedBy, getDbColumnNameForField, getDeleteDate, getDeletedBy, getId, getLastUpdateBy, getLastUpdateDate, getSensitiveFields, getTypeCode, getTypedId, getVersion, getVirtualSearchFieldMappings, getVirtualSortFieldMappings, isDeleted, isHardDeleted, isVirtualSearchField, notifyOnBusinessKeyChange, onBusinessKeyChange, onDelete, onRefreshed, setCreateDate, setCreateDateShouldBeIgnored, setCreateDateTime, setCreatedBy, setDeleted, setDeleteDate, setDeletedBy, setId, setLastUpdateBy, setLastUpdateDate, setLastUpdateDateTime, setTypedId, setVersion, userGroupEditBulkloadFilter, userGroupEditBulkloadFilterMethods inherited from class DomainObject
deepCopy, getNewMidnightDate, getNewMidnightDateTime, isMidnight, isMidnight, jsonDeserialize, jsonDeserialize, jsonDeserialize, jsonDeserialize, jsonDeserialize, jsonDeserialize, jsonDeserialize, jsonDeserialize, jsonDeserialize, jsonDeserialize, jsonDeserialize, jsonDeserialize, jsonSerialize, jsonSerialize, jsonSerialize, jsonSerialize, jsonSerialize, jsonSerialize, jsonSerializedSizeOK, jsonSerializeToBytes, jsonSerializeToBytes, setToDayEnd, setToDayEnd, setToMidnight, setToMidnight, setToMidnightAsLocalDateTime, toPropertyMap, truncatedToString
-
Field Details
-
CACHE_REGION_NAME
- See Also:
-
FIELD_ACTIVATED
- See Also:
-
FIELD_EMAIL
- See Also:
-
FIELD_LOGINNAME
- See Also:
-
FIELD_PASSWORD_HASH
- See Also:
-
FIELD_PASSWORD_SALT
- See Also:
-
SYSTEM_USER_NAME
- See Also:
-
SYSTEM_SUPPORT_USER_NAME
- See Also:
-
NEW_PASSWORD_HASH
-
NEW_PASSWORD_NOSESSION_HASH
-
UNKNOWN_HASH
- See Also:
-
-
Constructor Details
-
User
public User()Creates a User that isactivatedand hasworkflow emailingenabled. -
User
public User(Partition partition) Creates a User in the given partition that isactivatedand hasworkflow emailingenabled.- Parameters:
partition- the partition this User belongs to
-
User
public User(Partition partition, String loginName, String firstName, String lastName, String clearTextPassword) Creates a User in the given partition that isactivatedand hasworkflow emailingenabled. The login name is lowercased, and the clear-text password is hashed throughsetPassword(String).- Parameters:
partition- the partition this User belongs tologinName- the login namefirstName- the first namelastName- the last nameclearTextPassword- the password in clear text
-
-
Method Details
-
getSignificantFields
Returns the fields that form this User's business key, used to match records on import and update:loginNameonly.- Overrides:
getSignificantFieldsin classPersistedObject- Returns:
{"loginName"}
-
getFirstName
Returns this User's first name.- Returns:
- the first name
-
setFirstName
Sets this User's first name.- Parameters:
firstName- the first name
-
getLastName
Returns this User's last name.- Returns:
- the last name
-
setLastName
Sets this User's last name.- Parameters:
lastName- the last name
-
computeFullName
ReturnsgetFirstName()andgetLastName()joined with a space, skipping either one if it isnullor empty.- Returns:
- the full name
-
getEmail
Returns this User's email address.- Returns:
- the email address (lowercased when set via
setEmail(String))
-
setEmail
Sets this User's email address, lowercased.- Parameters:
email- the email address
-
getDefaultUserGroupEdit
Returns theUserGroupunique name that the server copies onto the edit-access user-group restriction of a new object when this User creates it, but only if thedefaultGroupsapplication setting enables this for the object's type. Some types, such as Price List and Company Parameters, are disabled unless the setting enables them.- Returns:
- the default edit-access user group's unique name
-
setDefaultUserGroupEdit
Sets theUserGroupunique name that the server copies onto the edit-access user-group restriction of a new object when this User creates it, if thedefaultGroupsapplication setting enables this for the object's type.- Parameters:
defaultUserGroup- the default edit-access user group's unique name
-
getDefaultUserGroupViewDetails
Returns theUserGroupunique name that the server copies onto the view-details-access user-group restriction of a new object when this User creates it, but only if thedefaultGroupsapplication setting enables this for the object's type. Some types, such as Price List and Company Parameters, are disabled unless the setting enables them.- Returns:
- the default view-details-access user group's unique name
-
setDefaultUserGroupViewDetails
Sets theUserGroupunique name that the server copies onto the view-details-access user-group restriction of a new object when this User creates it, if thedefaultGroupsapplication setting enables this for the object's type.- Parameters:
defaultUserViewDetails- the default view-details-access user group's unique name
-
getNoSession
Returns whether this is a no-session (API-only) account: whentrue, a successful Basic Authentication does not create a browser session (no session cookie or CSRF token is issued), andsetPassword(String)hashes the password with the separately configurable no-session hash method.- Returns:
trueif this is a no-session account;falseifnullor not set
-
getRequireTFA
Returns whether Two-Factor Authentication (TFA) is required for this User specifically. TFA can also be enforced for all users by a partition-level setting, sofalsedoes not mean this User can log in without TFA.- Returns:
trueif TFA is required for this User;falseifnullor not set
-
setRequireTFA
Sets whether Two-Factor Authentication (TFA) is required for this User specifically. A partition-level setting can also enforce TFA for all users.- Parameters:
requireTFA-trueto require TFA
-
getSsoOnly
Returns whether this User may only log in via Single Sign-On (SSO), not with a password. Whentrue,getPasswordExpiry()always returnsnull.- Returns:
trueif SSO-only;falseifnullor not set
-
setSsoOnly
Sets whether this User may only log in via Single Sign-On (SSO), not with a password.- Parameters:
ssoOnly-trueto restrict this User to SSO login
-
getReceiveAdminEmail
Returns whether this User is a partition administrator contact. Whentrue, this User receives the emails sent throughPartition.sendAdminEmail, such as failed-job alerts and SAML certificate expiry warnings, and this User's email address is listed among the partition's contact emails in the partition registry. In both cases, only activated, non-deleted users with an email address are included.- Returns:
trueif admin emails are received;falseifnullor not set
-
setReceiveAdminEmail
Sets whether this User is a partition administrator contact.- Parameters:
receiveAdminEmail-trueto receive admin emails- See Also:
-
setNoSession
Sets whether this is a no-session (API-only) account.- Parameters:
noSession-trueto make this a no-session account- See Also:
-
getPlatformManaged
Returns whether this User's account is managed by Platform Manager rather than by a partition administrator. Only thesystem usercan edit a platform-managed account (seecanEdit(User, ValidationVisitor, PersistedObjectService, Map)) or change its password.- Returns:
trueif platform-managed;falseifnullor not set
-
setPlatformManaged
Sets whether this User's account is managed by Platform Manager rather than by a partition administrator.- Parameters:
platformManaged-trueto mark this account as platform-managed
-
passwordExpiry
Returns the stored password expiry formatted as a display string, under the JSON property namepasswordExpiry. This formats the stored value directly, notgetPasswordExpiry(), so the SSO-only rule does not apply: for anSSO-onlyUser whose stored expiry has not yet been cleared on save, this returns a date whilegetPasswordExpiry()returnsnull.- Returns:
- the formatted password expiry date/time, or
nullif there is none
-
getPasswordExpiry
Returns the date/time after which this User's password is expired and must be changed, ornullif this User hasSSO-onlylogin enabled (an SSO-only account never has a password expiry) or no expiry is set.- Returns:
- the password expiry date/time, or
null
-
setPasswordExpiry
Sets the date/time after which this User's password is expired and must be changed.- Parameters:
passwordExpiry- the password expiry date/time
-
getPasswordHash
Returns this User's stored password hash.- Returns:
- the password hash
-
setPasswordHash
Sets this User's stored password hash directly. PrefersetPassword(String), which also generates a new salt and records the hash method used.- Parameters:
passwordHash- the password hash
-
getPasswordSalt
Returns the salt used to hash this User's password.- Returns:
- the password salt
-
setPasswordSalt
Sets the salt used to hash this User's password directly. PrefersetPassword(String), which generates a new random salt itself.- Parameters:
passwordSalt- the password salt
-
isSystemUser
public boolean isSystemUser()Returns whether this is the built-inrootsystem user of theSYSTEMpartition.- Returns:
trueif this is the system user
-
getExtendedData
Returns server/environment metadata attached to this User for an "extended" login response (for example, cluster name, feature-flag context, max form content size). This is not persisted and is only populated by the login command when requested; it is not part of the stored User record.- Returns:
- the extended login metadata, or
nullif not populated
-
setExtendedData
Sets the server/environment metadata attached to this User for an "extended" login response.- Parameters:
extendedData- the extended login metadata
-
getWizardDashboardName
Returns the unique name of the Wizard Dashboard assigned to this User.- Returns:
- the wizard dashboard's unique name
-
setWizardDashboardName
Sets the unique name of the Wizard Dashboard assigned to this User.- Parameters:
wizardDashboardName- the wizard dashboard's unique name
-
setPassword
Sets this User's password from clear text: generates a new random salt, hashes the password with it using the configured hash method, and records the salt and hash method used. No-session accounts (seegetNoSession()) use the separately configurable no-session hash method. Also schedules a cluster-wide user cache invalidation after the transaction commits (seeemitUserUpdateActionAfterCommit()). Does not save the User. Anullpassword is a no-op.- Parameters:
clearTextPassword- the new clear-text password;nullis ignored
-
checkPassword
Returns whether the given clear-text password matches this User's stored password hash, usinggetHashMethod()and the stored (or, if not set, the login-name-based fallback) salt.- Parameters:
clearTextPassword- the clear-text password to check- Returns:
trueif it matches the stored password hash
-
getHashMethod
Returns the algorithm used to hash this User's password, or"SHA-1"if none is recorded (accounts created before the hash method was tracked).- Returns:
- the password hash method
-
getRoles
Returns theRoles directly assigned to this User, not including roles granted via aBusinessRole. SeegetAllRoles()for the combined set.- Returns:
- the directly assigned roles, or an empty set if none were assigned
-
getRoleNames
Returns the unique names of theRoles directly assigned to this User (not including roles granted via aBusinessRole).Do not use this in code to check a User's roles: it exists only for JSON serialization. Use
AuthUtil.userHasRole(Role.WF_ADMIN, currentUser)-style checks instead.- Returns:
- the directly assigned roles' unique names
-
getAllRoleNames
Returns the unique names ofgetAllRoles(), that is, every role this User has, whether directly assigned or granted via aBusinessRole.Do not use this in code to check a User's roles: it exists only for JSON serialization. Use
AuthUtil.userHasRole(Role.WF_ADMIN, currentUser)-style checks instead.- Returns:
- all of this User's roles' unique names
-
getAllRoles
Returns everyRolethis User has, whether directly assigned (seegetRoles()) or granted via aBusinessRole(seegetBusinessRoles()).- Returns:
- all of this User's roles; never
null, empty if none
-
getGroups
Returns theUserGroups directly assigned to this User, not including groups granted via aBusinessRole. SeegetAllGroups()for the combined set.- Returns:
- the directly assigned user groups, or an empty set if none were assigned
-
getAllGroups
Returns everyUserGroupthis User belongs to, whether directly assigned (seegetGroups()) or granted via aBusinessRole(seegetBusinessRoles()).- Returns:
- all of this User's user groups; never
null, empty if none
-
getBusinessRoles
Returns theBusinessRoles assigned to this User. Each Business Role can in turn grant additional roles and user groups, reflected ingetAllRoles()andgetAllGroups().- Returns:
- the assigned business roles, or an empty set if none were assigned
-
isActivated
Returns whether this User's account is active. An inactive User cannot log in. New Users are activated by default.- Returns:
trueif activated;falseifnullor not set
-
setActivated
Sets whether this User's account is active.- Parameters:
activated-trueto activate this account
-
isWorkflowEmailingActivated
Returns whether this User receives workflow-related email notifications. Enabled by default for new Users.- Returns:
trueif workflow emailing is activated;falseifnullor not set
-
setWorkflowEmailingActivated
Sets whether this User receives workflow-related email notifications.- Parameters:
workflowEmailingActivated-trueto activate workflow emailing
-
getLastLogin
Returns the date/time this User last logged in, ornullif never.- Returns:
- the last login date/time
-
lastUpdateDate
ReturnsgetLastLogin()formatted as a display string, under the JSON property namelastLogin. Overrides the superclass's generic "last update date" to report the last login instead.- Overrides:
lastUpdateDatein classPersistedObject- Returns:
- the formatted last login date/time, or
nullif never logged in
-
setLastLogin
Sets the date/time this User last logged in. Transitioning from no previous login (that is,getLastLogin()wasnull) to a non-null value marksisFirstLogin()astrue.- Parameters:
lastLogin- the last login date/time
-
isFirstLogin
public boolean isFirstLogin()Returns whethersetLastLogin(LocalDateTime)has recorded this User's first-ever login on this object (that is,getLastLogin()transitioned fromnull). The flag is transient, not persisted, and is not reset afterwards.- Returns:
trueif a first login was recorded on this object
-
getFQLoginName
Returns this User's login name qualified by its partition's unique name, formatted as"<partition>/<loginName>".- Returns:
- the partition-qualified login name
-
getLoginName
Returns this User's login name.- Returns:
- the login name (lowercased when set via
setLoginName(String))
-
setLoginName
Sets this User's login name, lowercased.- Parameters:
name- the login name
-
setUniqueLoginName
Sets this User's login name to"<name>_<currentTimeMillis>", lowercased, so that it does not collide with an existing login name. It is used in two places: to rename a soft-deleted User whose login name blocks saving another User with the same login name (seerenameSoftDeleted(PersistedObjectService)), and to build the login name of a copy when a User is copied.- Parameters:
name- the base login name
-
getAdditionalInfo1
Returns the first of four general-purpose extension fields on this User, with no built-in meaning. Available in a logic asapi.user("additionalInfo1").- Returns:
- the first extension field's value
-
setAdditionalInfo1
Sets the first of four general-purpose extension fields on this User.- Parameters:
additionalInfo1- the first extension field's value
-
getAdditionalInfo2
Returns the second of four general-purpose extension fields on this User, with no built-in meaning. Available in a logic asapi.user("additionalInfo2").- Returns:
- the second extension field's value
-
setAdditionalInfo2
Sets the second of four general-purpose extension fields on this User.- Parameters:
additionalInfo2- the second extension field's value
-
getAdditionalInfo3
Returns the third of four general-purpose extension fields on this User, with no built-in meaning. Available in a logic asapi.user("additionalInfo3").- Returns:
- the third extension field's value
-
setAdditionalInfo3
Sets the third of four general-purpose extension fields on this User.- Parameters:
additionalInfo3- the third extension field's value
-
getAdditionalInfo4
Returns the fourth of four general-purpose extension fields on this User, with no built-in meaning. Available in a logic asapi.user("additionalInfo4").- Returns:
- the fourth extension field's value
-
setAdditionalInfo4
Sets the fourth of four general-purpose extension fields on this User.- Parameters:
additionalInfo4- the fourth extension field's value
-
getEmailLocale
Returns the locale used for notifications to this User, such as emails and notification titles. It is also passed to the Single Sign-On (SSO) login flow.- Returns:
- the email locale
-
setEmailLocale
Sets the locale used for notifications to this User.- Parameters:
emailLocale- the email locale
-
getProductFilterCriteria
Returns this User's Product access restriction, as a JSON-encoded advanced filter criteria. SeegetSkuFilter()for the resolvedFilter.- Returns:
- the Product filter criteria, as JSON
-
setProductFilterCriteria
Sets this User's Product access restriction, as a JSON-encoded advanced filter criteria.- Parameters:
productFilterExpression- the Product filter criteria, as JSON
-
getCustomerFilterCriteria
Returns this User's Customer access restriction, as a JSON-encoded advanced filter criteria. SeegetCustomerFilter()for the resolvedFilter.- Returns:
- the Customer filter criteria, as JSON
-
setCustomerFilterCriteria
Sets this User's Customer access restriction, as a JSON-encoded advanced filter criteria.- Parameters:
customerFilterCriteria- the Customer filter criteria, as JSON
-
getSellerFilterCriteria
Returns this User's Seller access restriction, as a JSON-encoded advanced filter criteria. SeegetSellerFilter()for the resolvedFilter.- Returns:
- the Seller filter criteria, as JSON
-
setSellerFilterCriteria
Sets this User's Seller access restriction, as a JSON-encoded advanced filter criteria.- Parameters:
sellerFilterCriteria- the Seller filter criteria, as JSON
-
getLastTermsOfUseVersionAgreed
Returns the version identifier of the Terms of Use this User last agreed to.- Returns:
- the agreed Terms of Use version
-
setLastTermsOfUseVersionAgreed
Sets the version identifier of the Terms of Use this User last agreed to.- Parameters:
lastTermsOfUseVersionAgreed- the agreed Terms of Use version
-
getLastTermsOfUseAgreedDate
Returns the date/time this User last agreed to the Terms of Use.- Returns:
- the Terms of Use agreement date/time
-
setLastTermsOfUseAgreedDate
Sets the date/time this User last agreed to the Terms of Use.- Parameters:
lastTermsOfUseAgreedDate- the Terms of Use agreement date/time
-
addRelevantFilter
public void addRelevantFilter(Search search) Adds this User's access restriction filter tosearch, if one applies. Which ofgetSkuFilter(),getCustomerFilter()orgetSellerFilter()is added, if any, is determined by whethersearch's search class joins to Product, Customer, or Seller master data; if none does,searchis left unchanged.- Parameters:
search- the search to restrict
-
getSkuFilter
Returns this User's Product access restriction resolved into aFilter, built fromgetProductFilterCriteria(), ornullif no restriction is set.- Returns:
- the resolved Product filter, or
null
-
getCustomerFilter
Returns this User's Customer access restriction resolved into aFilter, built fromgetCustomerFilterCriteria(), ornullif no restriction is set.- Returns:
- the resolved Customer filter, or
null
-
getSellerFilter
Returns this User's Seller access restriction resolved into aFilter, built fromgetSellerFilterCriteria(), ornullif no restriction is set.- Returns:
- the resolved Seller filter, or
null
-
hasModuleAccess
public boolean hasModuleAccess(ApplicationModule module) Returns whether any of this User'sroles(direct or granted via aBusinessRole) belongs to the given application module.- Parameters:
module- the application module to check- Returns:
trueif this User has access tomodulevia at least one role
-
auditOperation
public void auditOperation(AuditOperation operation, User byUser, CommandContext context, PersistedObjectService objService, String details) Records a security-relevant operation performed on this User (for example, an edit) as aSecurityAuditTrailentry.- Overrides:
auditOperationin classPersistedObject- Parameters:
operation- the operation performedbyUser- the user who performed itcontext- the request context the operation was performed inobjService- used to persist the audit trail entrydetails- additional details about the operation
-
isAudited
public boolean isAudited()Returnstrue, so the server records a security audit entry when a User is created, updated or deleted through the standard data commands (seeauditOperation(AuditOperation, User, CommandContext, PersistedObjectService, String)).- Overrides:
isAuditedin classPersistedObject- Returns:
- always
true
-
isInGroup
Returns whether this User belongs to the givenUserGroup, whether directly or via aBusinessRole.- Parameters:
userGroup- the user group to check- Returns:
trueif this User belongs touserGroup
-
renameSoftDeleted
public void renameSoftDeleted(PersistedObjectService objService) Renames this soft-deleted User, viaobjService, so itsgetLoginName()no longer conflicts with another User's login name. Called when this User's login name would otherwise block saving (creating or updating) another User with the same login name; seesetUniqueLoginName(String). This User must be soft-deleted; otherwise, the rename is not done and an error is logged.- Specified by:
renameSoftDeletedin interfaceRenameSoftDeletedInNameConflict- Parameters:
objService- used to perform the rename
-
validate
public boolean validate(ValidationVisitor validationVisitor, PersistedObjectService objService) Validates thatgetAdditionalInfo3(),getAdditionalInfo4(),getLoginName(),getLastName(),getFirstName()andgetEmail()are all at most 255 characters, in addition to the superclass's own validation, recording a validation error for the first field found too long.- Overrides:
validatein classPartitionedObject- Parameters:
validationVisitor- collects validation errors; may benullobjService- used by the superclass's own validation- Returns:
trueif all fields are within length limits and the superclass validation also passed;falseotherwise
-
canEdit
public boolean canEdit(User user, ValidationVisitor validationVisitor, PersistedObjectService objService, Map<String, Object> fieldsToEdit) Returns whetherusermay edit this User, in addition to the superclass's own check: if this User isplatform-managed, only asystem usermay edit it.- Overrides:
canEditin classPersistedObject- Parameters:
user- the user attempting the editvalidationVisitor- collects a validation error if edit is denied; may benullobjService- used by the superclass's own checkfieldsToEdit- the fields being edited- Returns:
trueifusermay edit this User
-
onSaveOrUpdate
public void onSaveOrUpdate(PersistedObjectService objService) Runs the superclass's own save/update logic, then clearsgetPasswordExpiry()if this User isSSO-only.- Overrides:
onSaveOrUpdatein classPersistedObject- Parameters:
objService- the persistence context this save/update runs in
-
onSavedOrUpdated
public void onSavedOrUpdated(PersistedObjectService objService) Runs the superclass's own post-save logic, then callsemitUserUpdateActionAfterCommit()to invalidate, on all nodes, the cached users, user groups, roles and business roles of this User's partition once the transaction commits.- Overrides:
onSavedOrUpdatedin classPersistedObject- Parameters:
objService- the persistence context this save/update ran in
-
emitUserUpdateActionAfterCommit
public void emitUserUpdateActionAfterCommit()Internal server method, not for use in logics: refreshes the cached user data of this User's partition on all nodes after the current transaction commits. -
invalidateUsersOnAllNodes
Internal server method, not for use in logics: refreshes the cached user data of the given partition on all nodes.- Parameters:
partitionName- the unique name of the partition- Throws:
ClusterException- if the request could not be sent
-
getPermissions
Returns every permission granted by this User'sroles(direct or granted via aBusinessRole).- Returns:
- this User's permissions
-
createRootUser
public static void createRootUser(PersistedObjectService objService) Internal server method, not for use in logics: creates the built-inrootsystem user.- Parameters:
objService- the persistence service
-
createOrUpdateSupportUser
public static void createOrUpdateSupportUser(PersistedObjectService objService) Internal server method, not for use in logics: creates the built-inpricefx-supportuser, or updates it if it exists.- Parameters:
objService- the persistence service
-
createSupportUser
public static void createSupportUser(PersistedObjectService objService) Internal server method, not for use in logics: creates the built-inpricefx-supportuser.- Parameters:
objService- the persistence service
-
updateSupportUser
Internal server method, not for use in logics: setsSUPPORTas the only directly assigned role of the built-inpricefx-supportuser, activates it, and saves it.- Parameters:
objService- the persistence servicesupportUser- the support user
-