Class User
java.lang.Object
io.goobi.viewer.model.security.user.AbstractLicensee
io.goobi.viewer.model.security.user.User
- All Implemented Interfaces:
ILicensee,HttpSessionBindingListener,Serializable,Comparable<User>,EventListener
@Entity
public class User
extends AbstractLicensee
implements HttpSessionBindingListener, Serializable, Comparable<User>
Represents a registered viewer user with authentication credentials, roles, and associated licences.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringConstantATTRIBUTE_LOGINS="logins".static final intConstantAVATAR_DEFAULT_SIZE=140. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAuthentication check for regular (i.e. non-OpenID) accounts.voidbackupFields.canSatisfyAllAccessConditions(Set<String> requiredAccessConditions, String privilegeName, String pi) Checks whether the user can satisfy at least one of the given access conditions with a license that contains the given privilege name.intvoidbooleanGetter for the fieldactivationKey.getAllowedCategories(List<CMSCategory> allCategories) getAllowedCategories.getAllowedSubthemeDiscriminatorValues(List<String> rawValues) getAllowedSubthemeDiscriminatorValues.getAllowedTemplates(List<CMSPageTemplate> allTemplates) getAllowedTemplates.Returns a list of all groups with this user's involvement (either as owner or member).Used by the crowdsourcing module.getAvatarUrl(int size) Used by the crowdsourcing module.getAvatarUrl(int size, HttpServletRequest request) get the url for the avatar.getAvatarUrl(HttpServletRequest request) Getter for the fieldcomments.getCopy()Getter for the fieldcopy.Returns the name best suited for displaying (depending on which values are available).getEmail()Getter for the fieldemail.Getter for the fieldfirstName.getId()Getter for the fieldid.static LongGets theidof a user from a URI.getIdAsURI.Getter for the fieldlastLogin.Getter for the fieldlastName.getName()getName.Getter for the fieldnickName.Getter for the fieldopenIdAccounts.Getter for the fieldpasswordHash.intgetRank()getRank.longgetScore()Getter for the fieldscore.Getter for the fieldtranskribusSession.getUserGroupMemberships.Returns a list of UserGroups of which this user is the owner.Returns a list of UserGroups of which this user is a member.inthashCode()booleanbooleanhasPriviledgeForAllTemplates.booleanhasPrivilegeForAllCategories.booleanhasPrivilegeForAllSubthemeDiscriminatorValues.booleanhasPrivilegesForTemplate(CMSPageTemplate template) hasPrivilegesForTemplate.booleanisActive()isActive.booleanbooleanbooleanisCmsAdmin.booleanbooleanisGroupMember(UserGroup group) isGroupMember.booleanisHasCmsPrivilege(String privilege) isHasCmsPrivilege.booleanisHasPrivilege(String licenseType, String privilege) isHasPrivilege.booleanChecks whether this user has the permission to delete all ocr-content of one page in crowdsourcing.booleanChecks whether this user has the permission to set the representative image for the currently open record.booleanisOpenIdUser.booleanisSuperuser.booleanisSuspended.static voidmain.voidraiseScore(int amount) raiseScore.voidsetActivationKey(String activationKey) Setter for the fieldactivationKey.voidsetActive(boolean active) Setter for the fieldactive.voidsetAgreedToTermsOfUse(boolean agreedToTermsOfUse) voidsetAvatarFile(Part uploadedFile) voidsetAvatarType(UserAvatarOption avatarType) protected voidsetBCrypt.voidsetComments(String comments) Setter for the fieldcomments.voidSetter for the fieldcopy.voidSetter for the fieldemail.voidsetFirstName(String firstName) Setter for the fieldfirstName.voidSetter for the fieldid.voidsetLastLogin(LocalDateTime lastLogin) Setter for the fieldlastLogin.voidsetLastName(String lastName) Setter for the fieldlastName.voidsetLocalAvatarUpdated(Long localAvatarUpdated) booleansetNewPassword(String password) Generates salt and a password hash for the given password string.voidsetNickName(String nickName) Setter for the fieldnickName.voidsetOpenIdAccounts(List<String> openIdAccounts) Setter for the fieldopenIdAccounts.voidsetPasswordHash(String passwordHash) Setter for the fieldpasswordHash.voidsetScore(long score) Setter for the fieldscore.voidsetSuperuser(boolean superuser) Setter for the fieldsuperuser.voidsetSuspended(boolean suspended) Setter for the fieldsuspended.voidsetTranskribusSession(TranskribusSession transkribusSession) Setter for the fieldtranskribusSession.voidsetUserProperties(Map<String, String> userProperties) toString()voidvoidMethods inherited from class io.goobi.viewer.model.security.user.AbstractLicensee
getAccessPermissionFromMap, getLicenses, hasLicense
-
Field Details
-
ATTRIBUTE_LOGINS
ConstantATTRIBUTE_LOGINS="logins".- See Also:
-
AVATAR_DEFAULT_SIZE
public static final int AVATAR_DEFAULT_SIZEConstantAVATAR_DEFAULT_SIZE=140.- See Also:
-
-
Constructor Details
-
User
public User()Empty constructor. -
User
- Parameters:
nickname- the display nickname to assign to this user
-
User
Cloning constructor.- Parameters:
blueprint- User to clone
-
-
Method Details
-
hashCode
public int hashCode() -
equals
-
getDisplayName
Returns the name best suited for displaying (depending on which values are available).- Returns:
- the display name of this user (nickname, email, or a default label depending on available values)
-
getUserGroupOwnerships
Returns a list of UserGroups of which this user is the owner.- Returns:
- a list of user groups owned by this user
- Throws:
DAOException- if any.
-
getUserGroupMemberships
getUserGroupMemberships.- Returns:
- a list of user role entries representing this user's group memberships
- Throws:
DAOException- if any.
-
getUserGroupsWithMembership
Returns a list of UserGroups of which this user is a member.- Returns:
- a list of user groups in which this user holds a membership
- Throws:
DAOException- if any.
-
isGroupMember
isGroupMember.- Parameters:
group- the user group to check membership in- Returns:
- true if this user is a member of the given group, false otherwise
- Throws:
DAOException- if any.
-
getAllUserGroups
Returns a list of all groups with this user's involvement (either as owner or member).- Returns:
- a list of all user groups this user is associated with as owner or member
- Throws:
DAOException- if any.
-
canSatisfyAllAccessConditions
public AccessPermission canSatisfyAllAccessConditions(Set<String> requiredAccessConditions, String privilegeName, String pi) throws PresentationException, IndexUnreachableException, DAOException Checks whether the user can satisfy at least one of the given access conditions with a license that contains the given privilege name. If one of the conditions is OPENACCESS, true is always returned. Superusers always get access.- Parameters:
requiredAccessConditions- set of access condition names to satisfyprivilegeName- the privilege to check against each conditionpi- persistent identifier of the record being accessed- Returns:
AccessPermission- Throws:
PresentationException- if any.IndexUnreachableException- if any.DAOException- if any.
-
isHasCmsPrivilege
public boolean isHasCmsPrivilege(String privilege) throws PresentationException, IndexUnreachableException, DAOException isHasCmsPrivilege.- Parameters:
privilege- the CMS privilege name to check- Returns:
- boolean
- Throws:
PresentationException- if any.IndexUnreachableException- if any.DAOException- if any.
-
isHasPrivilege
public boolean isHasPrivilege(String licenseType, String privilege) throws PresentationException, IndexUnreachableException, DAOException isHasPrivilege.- Parameters:
licenseType- the license type name to checkprivilege- the privilege name to check- Returns:
- boolean
- Throws:
PresentationException- if any.IndexUnreachableException- if any.DAOException- if any.
-
isMaySetRepresentativeImage
public boolean isMaySetRepresentativeImage() throws IndexUnreachableException, PresentationException, DAOExceptionChecks whether this user has the permission to set the representative image for the currently open record. TODO For some reason this method is called 8x in a row.- Returns:
- boolean
- Throws:
IndexUnreachableException- if any.PresentationException- if any.DAOException- if any.
-
isMayDeleteCrowdsourcingFulltext
public boolean isMayDeleteCrowdsourcingFulltext() throws IndexUnreachableException, PresentationException, DAOExceptionChecks whether this user has the permission to delete all ocr-content of one page in crowdsourcing.- Returns:
- true if this user is allowed to delete OCR page content for the current record, false otherwise
- Throws:
IndexUnreachableException- if any.PresentationException- if any.DAOException- if any.
-
isCmsCreator
public boolean isCmsCreator()- Returns:
- true if there are CMS pages or campaigns created by this user; false otherwise
-
getAvatarUrl
get the url for the avatar. If useGravatar is active, returnGravatarUserAvatar.getGravatarUrl(int size). Otherwise build a resource url to 'resources/images/backend/thumbnail_goobi_person.svg' from the request or the JSF-Context if no request is provided- Parameters:
size- the desired avatar image size in pixelsrequest- the HTTP request used to build resource URLs; may be null- Returns:
- Avatar URL
-
getAvatarUrl
Used by the crowdsourcing module.- Returns:
getAvatarUrl(int size, HttpServletRequest request)with size=AVATAR_DEFAULT_SIZEand request=null
-
getAvatarUrl
- Parameters:
request- the HTTP request used to build resource URLs- Returns:
getAvatarUrl(int size, HttpServletRequest request)with size=AVATAR_DEFAULT_SIZE
-
getAvatarUrl
Used by the crowdsourcing module.- Parameters:
size- the desired avatar image size in pixels- Returns:
getAvatarUrl(int size, HttpServletRequest request)with request=null
-
setNewPassword
Generates salt and a password hash for the given password string.- Parameters:
password- the plain-text password to hash and store- Returns:
- true if the password was set successfully (i.e. the given password is not blank), false otherwise
-
auth
Authentication check for regular (i.e. non-OpenID) accounts.- Parameters:
email- the email address to look uppassword- the plain-text password to verify- Returns:
- The user, if successful.
- Throws:
AuthenticationException- if any.DAOException- if any.
-
hasPriviledgeForAllTemplates
public boolean hasPriviledgeForAllTemplates()hasPriviledgeForAllTemplates.- Returns:
- true if this user has access to all CMS page templates (as superuser or via an unrestricted CMS admin license), false otherwise
-
hasPrivilegesForTemplate
hasPrivilegesForTemplate.- Parameters:
template- the CMS page template to check privileges for- Returns:
- true exactly if the user is not restricted to certain cmsTemplates or if the given templateId is among the allowed templates for the user of a usergroup she is in
-
getAllowedTemplates
getAllowedTemplates.- Parameters:
allTemplates- full list of available CMS page templates- Returns:
- a list of CMS page templates this user is permitted to use
-
hasPrivilegeForAllCategories
public boolean hasPrivilegeForAllCategories()hasPrivilegeForAllCategories.- Returns:
- true if this user has access to all CMS categories (as superuser or via an unrestricted CMS admin license), false otherwise
-
getAllowedCategories
getAllowedCategories.- Parameters:
allCategories- full list of available CMS categories- Returns:
- a list of CMS categories this user is permitted to assign
-
hasPrivilegeForAllSubthemeDiscriminatorValues
public boolean hasPrivilegeForAllSubthemeDiscriminatorValues()hasPrivilegeForAllSubthemeDiscriminatorValues.- Returns:
- true if this user has access to all CMS subtheme discriminator values (as superuser or via an unrestricted CMS admin license), false otherwise
-
getAllowedSubthemeDiscriminatorValues
getAllowedSubthemeDiscriminatorValues.- Parameters:
rawValues- All possible values- Returns:
- filtered list of allowed values
-
getId
Getter for the fieldid.- Returns:
- the database identifier of this user
-
setId
Setter for the fieldid.- Parameters:
id- the database identifier to set
-
getPasswordHash
Getter for the fieldpasswordHash.- Returns:
- the hashed password of this user
-
setPasswordHash
Setter for the fieldpasswordHash.- Parameters:
passwordHash- the hashed password to set
-
getActivationKey
Getter for the fieldactivationKey.- Returns:
- the account activation key sent by email
-
setActivationKey
Setter for the fieldactivationKey.- Parameters:
activationKey- the account activation key sent by email to set
-
getLastLogin
Getter for the fieldlastLogin.- Returns:
- the timestamp of the most recent login
-
setLastLogin
Setter for the fieldlastLogin.- Parameters:
lastLogin- the timestamp of the most recent login to set
-
isActive
public boolean isActive()isActive.- Returns:
- true if the user account is active; false otherwise
-
setActive
public void setActive(boolean active) Setter for the fieldactive.- Parameters:
active- true if the user account is active; false otherwise
-
isSuspended
public boolean isSuspended()isSuspended.- Returns:
- true if the user account is suspended; false otherwise
-
setSuspended
public void setSuspended(boolean suspended) Setter for the fieldsuspended.- Parameters:
suspended- true if the user account is suspended; false otherwise
-
getNickName
Getter for the fieldnickName.- Returns:
- the display nickname of this user
-
setNickName
Setter for the fieldnickName.- Parameters:
nickName- the display nickname of the user to set
-
getLastName
Getter for the fieldlastName.- Returns:
- the last name of this user
-
setLastName
Setter for the fieldlastName.- Parameters:
lastName- the last name of the user to set
-
getFirstName
Getter for the fieldfirstName.- Returns:
- the first name of this user
-
setFirstName
Setter for the fieldfirstName.- Parameters:
firstName- the first name of the user to set
-
getOpenIdAccounts
Getter for the fieldopenIdAccounts.- Returns:
- the list of OpenID account identifiers linked to this user
-
setOpenIdAccounts
Setter for the fieldopenIdAccounts.- Parameters:
openIdAccounts- the list of OpenID account identifiers linked to this user to set
-
setEmail
Setter for the fieldemail.- Parameters:
email- the email address of the user to set
-
getEmail
Getter for the fieldemail.- Returns:
- the email address of this user
-
getComments
Getter for the fieldcomments.- Returns:
- administrative comments about this user account
-
setComments
Setter for the fieldcomments.- Parameters:
comments- administrative comments about the user account to set
-
getScore
public long getScore()Getter for the fieldscore.- Returns:
- the contribution score of this user
-
setScore
public void setScore(long score) Setter for the fieldscore.- Parameters:
score- the user's contribution score to set
-
isAnonymous
public boolean isAnonymous()- Returns:
- true if user email address equals the configured anonymous user address; false otherwise
-
raiseScore
raiseScore.- Parameters:
amount- points to add to the user score- Throws:
DAOException- if any.
-
getRank
public int getRank()getRank.- Returns:
- a int.
-
getUserProperties
-
setUserProperties
-
isSuperuser
public boolean isSuperuser()isSuperuser.- Returns:
- true if this user has superuser privileges; false otherwise
-
isCmsAdmin
public boolean isCmsAdmin()isCmsAdmin.- Returns:
- true if user is superuser or has CMS-specific privileges
-
setSuperuser
public void setSuperuser(boolean superuser) Setter for the fieldsuperuser.- Parameters:
superuser- true if the user should have superuser privileges; false otherwise
-
isOpenIdUser
public boolean isOpenIdUser()isOpenIdUser.- Returns:
- true if this user has at least one linked OpenID account, false otherwise
-
getCopy
Getter for the fieldcopy.- Returns:
- the unsaved copy of this user instance
-
setCopy
Setter for the fieldcopy.- Parameters:
copy- the user instance representing an unsaved copy of this user to set
-
getTranskribusSession
Getter for the fieldtranskribusSession.- Returns:
- the active Transkribus session for this user
-
setTranskribusSession
Setter for the fieldtranskribusSession.- Parameters:
transkribusSession- the active Transkribus session for this user to set
-
getName
getName.Required by the ILicensee interface.
-
getAccessType
- Specified by:
getAccessTypein interfaceILicensee- Returns:
- AccessType corresponding to the licensee's class
-
valueBound
- Specified by:
valueBoundin interfaceHttpSessionBindingListener
-
valueUnbound
- Specified by:
valueUnboundin interfaceHttpSessionBindingListener
-
backupFields
public void backupFields()backupFields. -
toString
-
setBCrypt
setBCrypt.- Parameters:
bcrypt- the BCrypt instance to use for password hashing
-
getId
Gets theidof a user from a URI.- Parameters:
idAsURI- URI containing the user ID in its path- Returns:
- the numeric user ID extracted from the URI, or null if not found
-
getIdAsURI
getIdAsURI.- Returns:
- the REST API URI for this user, constructed from the user ID
-
setAgreedToTermsOfUse
public void setAgreedToTermsOfUse(boolean agreedToTermsOfUse) -
isAgreedToTermsOfUse
public boolean isAgreedToTermsOfUse() -
getAvatarType
-
setAvatarType
-
hasLocalAvatarImage
public boolean hasLocalAvatarImage() -
setAvatarFile
- Throws:
IOException
-
deleteAvatarFile
- Throws:
IOException
-
getLocalAvatarUpdated
-
setLocalAvatarUpdated
-
getBackendDisplayName
-
compareTo
- Specified by:
compareToin interfaceComparable<User>
-
main
main.- Parameters:
args- command-line arguments (unused)
-