All Implemented Interfaces:
ILicensee, HttpSessionBindingListener, Serializable, Comparable<User>, EventListener

Represents a registered viewer user with authentication credentials, roles, and associated licences.
See Also:
  • Field Details

    • ATTRIBUTE_LOGINS

      public static final String ATTRIBUTE_LOGINS
      Constant ATTRIBUTE_LOGINS="logins".
      See Also:
    • AVATAR_DEFAULT_SIZE

      public static final int AVATAR_DEFAULT_SIZE
      Constant AVATAR_DEFAULT_SIZE=140.
      See Also:
  • Constructor Details

    • User

      public User()
      Empty constructor.
    • User

      public User(String nickname)
      Parameters:
      nickname - the display nickname to assign to this user
    • User

      public User(User blueprint)
      Cloning constructor.
      Parameters:
      blueprint - User to clone
  • Method Details

    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • getDisplayName

      public String 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

      public List<UserGroup> getUserGroupOwnerships() throws DAOException
      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

      public List<UserRole> getUserGroupMemberships() throws DAOException
      getUserGroupMemberships.
      Returns:
      a list of user role entries representing this user's group memberships
      Throws:
      DAOException - if any.
    • getUserGroupsWithMembership

      public List<UserGroup> getUserGroupsWithMembership() throws DAOException
      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

      public boolean isGroupMember(UserGroup group) throws DAOException
      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

      public List<UserGroup> 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 satisfy
      privilegeName - the privilege to check against each condition
      pi - 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 check
      privilege - the privilege name to check
      Returns:
      boolean
      Throws:
      PresentationException - if any.
      IndexUnreachableException - if any.
      DAOException - if any.
    • isMaySetRepresentativeImage

      public boolean isMaySetRepresentativeImage() throws IndexUnreachableException, PresentationException, DAOException
      Checks 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, DAOException
      Checks 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

      public String getAvatarUrl(int size, HttpServletRequest request)
      get the url for the avatar. If useGravatar is active, return GravatarUserAvatar.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 pixels
      request - the HTTP request used to build resource URLs; may be null
      Returns:
      Avatar URL
    • getAvatarUrl

      public String getAvatarUrl()
      Used by the crowdsourcing module.
      Returns:
      getAvatarUrl(int size, HttpServletRequest request) with size=AVATAR_DEFAULT_SIZE and request=null
    • getAvatarUrl

      public String getAvatarUrl(HttpServletRequest request)
      Parameters:
      request - the HTTP request used to build resource URLs
      Returns:
      getAvatarUrl(int size, HttpServletRequest request) with size=AVATAR_DEFAULT_SIZE
    • getAvatarUrl

      public String getAvatarUrl(int size)
      Used by the crowdsourcing module.
      Parameters:
      size - the desired avatar image size in pixels
      Returns:
      getAvatarUrl(int size, HttpServletRequest request) with request=null
    • setNewPassword

      public boolean setNewPassword(String password)
      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

      public User auth(String email, String password) throws AuthenticationException, DAOException
      Authentication check for regular (i.e. non-OpenID) accounts.
      Parameters:
      email - the email address to look up
      password - 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

      public boolean hasPrivilegesForTemplate(CMSPageTemplate template)
      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

      public List<CMSPageTemplate> getAllowedTemplates(List<CMSPageTemplate> allTemplates)
      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

      public List<CMSCategory> getAllowedCategories(List<CMSCategory> allCategories)
      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

      public List<String> getAllowedSubthemeDiscriminatorValues(List<String> rawValues)
      getAllowedSubthemeDiscriminatorValues.
      Parameters:
      rawValues - All possible values
      Returns:
      filtered list of allowed values
    • getId

      public Long getId()
      Getter for the field id.
      Returns:
      the database identifier of this user
    • setId

      public void setId(Long id)
      Setter for the field id.
      Parameters:
      id - the database identifier to set
    • getPasswordHash

      public String getPasswordHash()
      Getter for the field passwordHash.
      Returns:
      the hashed password of this user
    • setPasswordHash

      public void setPasswordHash(String passwordHash)
      Setter for the field passwordHash.
      Parameters:
      passwordHash - the hashed password to set
    • getActivationKey

      public String getActivationKey()
      Getter for the field activationKey.
      Returns:
      the account activation key sent by email
    • setActivationKey

      public void setActivationKey(String activationKey)
      Setter for the field activationKey.
      Parameters:
      activationKey - the account activation key sent by email to set
    • getLastLogin

      public LocalDateTime getLastLogin()
      Getter for the field lastLogin.
      Returns:
      the timestamp of the most recent login
    • setLastLogin

      public void setLastLogin(LocalDateTime lastLogin)
      Setter for the field lastLogin.
      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 field active.
      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 field suspended.
      Parameters:
      suspended - true if the user account is suspended; false otherwise
    • getNickName

      public String getNickName()
      Getter for the field nickName.
      Returns:
      the display nickname of this user
    • setNickName

      public void setNickName(String nickName)
      Setter for the field nickName.
      Parameters:
      nickName - the display nickname of the user to set
    • getLastName

      public String getLastName()
      Getter for the field lastName.
      Returns:
      the last name of this user
    • setLastName

      public void setLastName(String lastName)
      Setter for the field lastName.
      Parameters:
      lastName - the last name of the user to set
    • getFirstName

      public String getFirstName()
      Getter for the field firstName.
      Returns:
      the first name of this user
    • setFirstName

      public void setFirstName(String firstName)
      Setter for the field firstName.
      Parameters:
      firstName - the first name of the user to set
    • getOpenIdAccounts

      public List<String> getOpenIdAccounts()
      Getter for the field openIdAccounts.
      Returns:
      the list of OpenID account identifiers linked to this user
    • setOpenIdAccounts

      public void setOpenIdAccounts(List<String> openIdAccounts)
      Setter for the field openIdAccounts.
      Parameters:
      openIdAccounts - the list of OpenID account identifiers linked to this user to set
    • setEmail

      public void setEmail(String email)
      Setter for the field email.
      Parameters:
      email - the email address of the user to set
    • getEmail

      public String getEmail()
      Getter for the field email.
      Returns:
      the email address of this user
    • getComments

      public String getComments()
      Getter for the field comments.
      Returns:
      administrative comments about this user account
    • setComments

      public void setComments(String comments)
      Setter for the field comments.
      Parameters:
      comments - administrative comments about the user account to set
    • getScore

      public long getScore()
      Getter for the field score.
      Returns:
      the contribution score of this user
    • setScore

      public void setScore(long score)
      Setter for the field score.
      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

      public void raiseScore(int amount) throws DAOException
      raiseScore.
      Parameters:
      amount - points to add to the user score
      Throws:
      DAOException - if any.
    • getRank

      public int getRank()
      getRank.
      Returns:
      a int.
    • getUserProperties

      public Map<String,String> getUserProperties()
    • setUserProperties

      public void setUserProperties(Map<String,String> userProperties)
    • 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 field superuser.
      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

      public User getCopy()
      Getter for the field copy.
      Returns:
      the unsaved copy of this user instance
    • setCopy

      public void setCopy(User copy)
      Setter for the field copy.
      Parameters:
      copy - the user instance representing an unsaved copy of this user to set
    • getTranskribusSession

      public TranskribusSession getTranskribusSession()
      Getter for the field transkribusSession.
      Returns:
      the active Transkribus session for this user
    • setTranskribusSession

      public void setTranskribusSession(TranskribusSession transkribusSession)
      Setter for the field transkribusSession.
      Parameters:
      transkribusSession - the active Transkribus session for this user to set
    • getName

      public String getName()
      getName.

      Required by the ILicensee interface.

      Specified by:
      getName in interface ILicensee
      Returns:
      the name of this licensee
    • getAccessType

      public License.AccessType getAccessType()
      Specified by:
      getAccessType in interface ILicensee
      Returns:
      AccessType corresponding to the licensee's class
    • valueBound

      public void valueBound(HttpSessionBindingEvent event)
      Specified by:
      valueBound in interface HttpSessionBindingListener
    • valueUnbound

      public void valueUnbound(HttpSessionBindingEvent event)
      Specified by:
      valueUnbound in interface HttpSessionBindingListener
    • backupFields

      public void backupFields()
      backupFields.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • setBCrypt

      protected void setBCrypt(BCrypt bcrypt)
      setBCrypt.
      Parameters:
      bcrypt - the BCrypt instance to use for password hashing
    • getId

      public static Long getId(URI idAsURI)
      Gets the id of 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

      public URI 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

      public UserAvatarOption getAvatarType()
    • setAvatarType

      public void setAvatarType(UserAvatarOption avatarType)
    • hasLocalAvatarImage

      public boolean hasLocalAvatarImage()
    • setAvatarFile

      public void setAvatarFile(Part uploadedFile) throws IOException
      Throws:
      IOException
    • deleteAvatarFile

      public void deleteAvatarFile() throws IOException
      Throws:
      IOException
    • getLocalAvatarUpdated

      public Long getLocalAvatarUpdated()
    • setLocalAvatarUpdated

      public void setLocalAvatarUpdated(Long localAvatarUpdated)
    • getBackendDisplayName

      public String getBackendDisplayName()
    • compareTo

      public int compareTo(User other)
      Specified by:
      compareTo in interface Comparable<User>
    • main

      public static void main(String[] args)
      main.
      Parameters:
      args - command-line arguments (unused)