All Implemented Interfaces:
ILicensee, Serializable, Comparable<User>, EventListener, javax.servlet.http.HttpSessionBindingListener

@Entity public class User extends AbstractLicensee implements javax.servlet.http.HttpSessionBindingListener, Serializable, Comparable<User>

User class.

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 -
    • 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:
      a String object.
    • getDisplayNameEscaped

      @Deprecated(since="2023.11") public String getDisplayNameEscaped()
      Deprecated.
      Returns:
      HTML-escapted value of getDisplayName()
    • getUserGroupOwnerships

      public List<UserGroup> getUserGroupOwnerships() throws DAOException
      Returns a list of UserGroups of which this user is the owner.
      Returns:
      a List object.
      Throws:
      DAOException - if any.
    • getUserGroupMemberships

      public List<UserRole> getUserGroupMemberships() throws DAOException

      getUserGroupMemberships.

      Returns:
      a List object.
      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 object.
      Throws:
      DAOException - if any.
    • isGroupMember

      public boolean isGroupMember(UserGroup group) throws DAOException

      isGroupMember.

      Parameters:
      group - a UserGroup object.
      Returns:
      a boolean.
      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 object.
      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 - a Set object.
      privilegeName - a String object.
      pi - a String object.
      Returns:
      AccessPermission
      Throws:
      PresentationException - if any.
      IndexUnreachableException - if any.
      DAOException - if any.
    • addLicense

      public boolean addLicense(License license)
      Adds the given license to this ILicensee.
      Specified by:
      addLicense in interface ILicensee
      Parameters:
      license - a License object.
      Returns:
      a boolean.
    • removeLicense

      public boolean removeLicense(License license)
      Removes the given license from this ILicensee.
      Specified by:
      removeLicense in interface ILicensee
      Parameters:
      license - a License object.
      Returns:
      a boolean.
    • isHasCmsPrivilege

      public boolean isHasCmsPrivilege(String privilege) throws PresentationException, IndexUnreachableException, DAOException

      isHasCmsPrivilege.

      Parameters:
      privilege - a String object.
      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 - a String object.
      privilege - a String object.
      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:
      a boolean.
      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, javax.servlet.http.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 -
      request -
      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(javax.servlet.http.HttpServletRequest request)
      Parameters:
      request -
      Returns:
      getAvatarUrl(int size, HttpServletRequest request) with size=AVATAR_DEFAULT_SIZE
    • getAvatarUrl

      public String getAvatarUrl(int size)
      Used by the crowdsourcing module.
      Parameters:
      size - a int.
      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 - a String object.
      Returns:
      a boolean.
    • auth

      public User auth(String email, String password) throws AuthenticationException, DAOException
      Authentication check for regular (i.e. non-OpenID) accounts.
      Parameters:
      email - a String object.
      password - a String object.
      Returns:
      The user, if successful.
      Throws:
      AuthenticationException - if any.
      DAOException - if any.
    • hasPriviledgeForAllTemplates

      public boolean hasPriviledgeForAllTemplates()

      hasPriviledgeForAllTemplates.

      Returns:
      a boolean.
    • hasPrivilegesForTemplate

      public boolean hasPrivilegesForTemplate(CMSPageTemplate template)

      hasPrivilegesForTemplate.

      Parameters:
      template -
      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 - a List object.
      Returns:
      a List object.
    • hasPrivilegeForAllCategories

      public boolean hasPrivilegeForAllCategories()

      hasPrivilegeForAllCategories.

      Returns:
      a boolean.
    • getAllowedCategories

      public List<CMSCategory> getAllowedCategories(List<CMSCategory> allCategories)

      getAllowedCategories.

      Parameters:
      allCategories - a List object.
      Returns:
      a List object.
    • hasPrivilegeForAllSubthemeDiscriminatorValues

      public boolean hasPrivilegeForAllSubthemeDiscriminatorValues()

      hasPrivilegeForAllSubthemeDiscriminatorValues.

      Returns:
      a boolean.
    • 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 id
    • setId

      public void setId(Long id)

      Setter for the field id.

      Parameters:
      id - the id to set
    • getPasswordHash

      public String getPasswordHash()

      Getter for the field passwordHash.

      Returns:
      the passwordHash
    • setPasswordHash

      public void setPasswordHash(String passwordHash)

      Setter for the field passwordHash.

      Parameters:
      passwordHash - the passwordHash to set
    • getActivationKey

      public String getActivationKey()

      Getter for the field activationKey.

      Returns:
      the activationKey
    • setActivationKey

      public void setActivationKey(String activationKey)

      Setter for the field activationKey.

      Parameters:
      activationKey - the activationKey to set
    • getLastLogin

      public LocalDateTime getLastLogin()

      Getter for the field lastLogin.

      Returns:
      the lastLogin
    • setLastLogin

      public void setLastLogin(LocalDateTime lastLogin)

      Setter for the field lastLogin.

      Parameters:
      lastLogin - the lastLogin to set
    • isActive

      public boolean isActive()

      isActive.

      Returns:
      the active
    • setActive

      public void setActive(boolean active)

      Setter for the field active.

      Parameters:
      active - the active to set
    • isSuspended

      public boolean isSuspended()

      isSuspended.

      Returns:
      the suspended
    • setSuspended

      public void setSuspended(boolean suspended)

      Setter for the field suspended.

      Parameters:
      suspended - the suspended to set
    • getNickName

      public String getNickName()

      Getter for the field nickName.

      Returns:
      the nickName
    • setNickName

      public void setNickName(String nickName)

      Setter for the field nickName.

      Parameters:
      nickName - the nickName to set
    • getLastName

      public String getLastName()

      Getter for the field lastName.

      Returns:
      the lastName
    • setLastName

      public void setLastName(String lastName)

      Setter for the field lastName.

      Parameters:
      lastName - the lastName to set
    • getFirstName

      public String getFirstName()

      Getter for the field firstName.

      Returns:
      the firstName
    • setFirstName

      public void setFirstName(String firstName)

      Setter for the field firstName.

      Parameters:
      firstName - the firstName to set
    • getOpenIdAccounts

      public List<String> getOpenIdAccounts()

      Getter for the field openIdAccounts.

      Returns:
      the openIdAccounts
    • setOpenIdAccounts

      public void setOpenIdAccounts(List<String> openIdAccounts)

      Setter for the field openIdAccounts.

      Parameters:
      openIdAccounts - the openIdAccounts to set
    • setEmail

      public void setEmail(String email)

      Setter for the field email.

      Parameters:
      email - the email to set
    • getEmail

      public String getEmail()

      Getter for the field email.

      Returns:
      the email
    • getComments

      public String getComments()

      Getter for the field comments.

      Returns:
      the comments
    • setComments

      public void setComments(String comments)

      Setter for the field comments.

      Parameters:
      comments - the comments to set
    • getScore

      public long getScore()

      Getter for the field score.

      Returns:
      the score
    • setScore

      public void setScore(long score)

      Setter for the field score.

      Parameters:
      score - the 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 - a int.
      Throws:
      DAOException - if any.
    • getRank

      public int getRank()

      getRank.

      Returns:
      a int.
    • getLicenses

      public List<License> getLicenses()

      getLicenses.

      Specified by:
      getLicenses in interface ILicensee
      Returns:
      a List object.
    • setLicenses

      public void setLicenses(List<License> licenses)

      Setter for the field licenses.

      Parameters:
      licenses - the licenses to set
    • getUserProperties

      public Map<String,String> getUserProperties()
      Returns:
      the userProperties
    • setUserProperties

      public void setUserProperties(Map<String,String> userProperties)
      Parameters:
      userProperties - the userProperties to set
    • isSuperuser

      public boolean isSuperuser()

      isSuperuser.

      Returns:
      the superuser
    • 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 - the superuser to set
    • isOpenIdUser

      public boolean isOpenIdUser()

      isOpenIdUser.

      Returns:
      a boolean.
    • getCopy

      public User getCopy()

      Getter for the field copy.

      Returns:
      the copy
    • setCopy

      public void setCopy(User copy)

      Setter for the field copy.

      Parameters:
      copy - the copy to set
    • getTranskribusSession

      public TranskribusSession getTranskribusSession()

      Getter for the field transkribusSession.

      Returns:
      the transkribusSession
    • setTranskribusSession

      public void setTranskribusSession(TranskribusSession transkribusSession)

      Setter for the field transkribusSession.

      Parameters:
      transkribusSession - the transkribusSession to set
    • getName

      public String getName()

      getName.

      Required by the ILicensee interface.
      Specified by:
      getName in interface ILicensee
      Returns:
      a String object.
    • valueBound

      public void valueBound(javax.servlet.http.HttpSessionBindingEvent event)
      Specified by:
      valueBound in interface javax.servlet.http.HttpSessionBindingListener
    • valueUnbound

      public void valueUnbound(javax.servlet.http.HttpSessionBindingEvent event)
      Specified by:
      valueUnbound in interface javax.servlet.http.HttpSessionBindingListener
    • backupFields

      public void backupFields()

      backupFields.

    • toString

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

      protected void setBCrypt(BCrypt bcrypt)

      setBCrypt.

      Parameters:
      bcrypt - a BCrypt object.
    • getId

      public static Long getId(URI idAsURI)
      Get the id of a user from a URI
      Parameters:
      idAsURI - a URI object.
      Returns:
      a Long object.
    • getIdAsURI

      public URI getIdAsURI()

      getIdAsURI.

      Returns:
      a URI object.
    • setAgreedToTermsOfUse

      public void setAgreedToTermsOfUse(boolean agreedToTermsOfUse)
      Parameters:
      agreedToTermsOfUse - the agreedToTermsOfUse to set
    • isAgreedToTermsOfUse

      public boolean isAgreedToTermsOfUse()
      Returns:
      the agreedToTermsOfUse
    • getAvatarType

      public UserAvatarOption getAvatarType()
      Returns:
      the avatarType
    • setAvatarType

      public void setAvatarType(UserAvatarOption avatarType)
      Parameters:
      avatarType - the avatarType to set
    • hasLocalAvatarImage

      public boolean hasLocalAvatarImage()
    • setAvatarFile

      public void setAvatarFile(javax.servlet.http.Part uploadedFile) throws IOException
      Throws:
      IOException
    • deleteAvatarFile

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

      public Long getLocalAvatarUpdated()
      Returns:
      the localAvatarUpdated
    • setLocalAvatarUpdated

      public void setLocalAvatarUpdated(Long localAvatarUpdated)
      Parameters:
      localAvatarUpdated - the localAvatarUpdated to set
    • 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 - an array of String objects.