Class HibernateUserDAO

java.lang.Object
com.logicaldoc.core.HibernatePersistentObjectDAO<User>
com.logicaldoc.core.security.dao.HibernateUserDAO
All Implemented Interfaces:
PersistentObjectDAO<User>, UserDAO

public class HibernateUserDAO extends HibernatePersistentObjectDAO<User> implements UserDAO
Hibernate implementation of UserDAO
Since:
3.0
Author:
Marco Meschieri - LogicalDOC
  • Method Details

    • ignoreCaseLogin

      public static boolean ignoreCaseLogin()
    • findByName

      public List<User> findByName(String name)
      Description copied from interface: UserDAO
      This method finds an User by name.
      Specified by:
      findByName in interface UserDAO
      Parameters:
      name - The name of wanted User.
      Returns:
      Collection of selected users.
    • findByUsername

      public User findByUsername(String username)
      Description copied from interface: UserDAO
      This method finds an User by its username. The search is case sensitive.
      Specified by:
      findByUsername in interface UserDAO
      Parameters:
      username - username of wanted User.
      Returns:
      Wanted User or null if user doesn't exist.
    • findByUsernameIgnoreCase

      public User findByUsernameIgnoreCase(String username)
      Description copied from interface: UserDAO
      This method finds an User by its username. The search is case insensitive.
      Specified by:
      findByUsernameIgnoreCase in interface UserDAO
      Parameters:
      username - username of wanted User.
      Returns:
      Wanted User or null if user doesn't exist.
    • findByLikeUsername

      public List<User> findByLikeUsername(String username)
      Description copied from interface: UserDAO
      This method finds an User by username.
      Specified by:
      findByLikeUsername in interface UserDAO
      Parameters:
      username - The username of wanted User.
      Returns:
      Collection of selected users.
      See Also:
    • findByUsernameAndName

      public List<User> findByUsernameAndName(String username, String name)
      Description copied from interface: UserDAO
      This method finds an User by username and name.
      Specified by:
      findByUsernameAndName in interface UserDAO
      Parameters:
      username - The username of wanted user
      name - The name of wanted user
      Returns:
      Collection of selected users
    • store

      public void store(User user) throws PasswordAlreadyUsedException, PersistenceException
      Description copied from interface: PersistentObjectDAO
      This method persists the entity object
      Specified by:
      store in interface PersistentObjectDAO<User>
      Overrides:
      store in class HibernatePersistentObjectDAO<User>
      Parameters:
      user - entity to be stored
      Throws:
      PersistenceException - raised in case of errors in the database
      PasswordAlreadyUsedException
    • store

      public void store(User user, UserHistory transaction) throws PasswordAlreadyUsedException, PersistenceException
      Description copied from interface: UserDAO
      This method persists the user object and insert a new user history entry.
      Specified by:
      store in interface UserDAO
      Parameters:
      user - the user to store
      transaction - entry to log the event
      Throws:
      PersistenceException - error at database level
      PasswordAlreadyUsedException
    • isPasswordExpired

      public boolean isPasswordExpired(String username)
      Description copied from interface: UserDAO
      Is password expired.
      Specified by:
      isPasswordExpired in interface UserDAO
      Parameters:
      username - Username of the User to be validated.
      Returns:
      True if the password is expired
    • isInactive

      public boolean isInactive(String username)
      Description copied from interface: UserDAO
      Checks if a user is inactive, that is a user without interactions in the last X days after it has last enabled. We look at the User.getMaxInactivity() first en then we fallback to the general parameter security.user.maxinactivity
      Specified by:
      isInactive in interface UserDAO
      Parameters:
      username - identifier of the user
      Returns:
      the last interaction time
    • count

      public int count(Long tenantId)
      Description copied from interface: UserDAO
      Counts the total number of standard users
      Specified by:
      count in interface UserDAO
      Parameters:
      tenantId - identifier of the tenant
      Returns:
      total number of guest users
    • countGuests

      public int countGuests(Long tenantId)
      Description copied from interface: UserDAO
      Counts the total number of guest users
      Specified by:
      countGuests in interface UserDAO
      Parameters:
      tenantId - identifier of the tenant
      Returns:
      total number of guest users
    • delete

      public void delete(long userId, int code) throws PersistenceException
      Description copied from interface: PersistentObjectDAO
      This method deletes an entity and you can give a deletion code
      Specified by:
      delete in interface PersistentObjectDAO<User>
      Overrides:
      delete in class HibernatePersistentObjectDAO<User>
      Parameters:
      userId - ID of the entity which should be deleted
      code - Deletion code
      Throws:
      PersistenceException - raised in case of errors in the database
    • delete

      public void delete(long userId, UserHistory transaction) throws PersistenceException
      Description copied from interface: UserDAO
      This method deletes the user object and insert a new user history entry.
      Specified by:
      delete in interface UserDAO
      Parameters:
      userId - The id of the user to delete
      transaction - entry to log the event
      Throws:
      PersistenceException - error at database level
    • getUserHistoryDAO

      public UserHistoryDAO getUserHistoryDAO()
    • setUserHistoryDAO

      public void setUserHistoryDAO(UserHistoryDAO userHistoryDAO)
    • setUserListenerManager

      public void setUserListenerManager(UserListenerManager userListenerManager)
    • getUserListenerManager

      public UserListenerManager getUserListenerManager()
    • initialize

      public void initialize(User user)
      Description copied from class: HibernatePersistentObjectDAO
      Doesn't do anything by default
      Specified by:
      initialize in interface PersistentObjectDAO<User>
      Overrides:
      initialize in class HibernatePersistentObjectDAO<User>
      Parameters:
      user - The entity to be initialised
    • findUserSettings

      public Map<String,Generic> findUserSettings(long userId, String namePrefix)
      Description copied from interface: UserDAO
      Retrieves the settings for a user. The settings are stored as Generics of type usersetting.
      Specified by:
      findUserSettings in interface UserDAO
      Parameters:
      userId - Identifier of the user
      namePrefix - Name prefix of the property (optional)
      Returns:
      The map setting_name-generic
    • setGenericDAO

      public void setGenericDAO(GenericDAO genericDAO)
    • findAdminUser

      public User findAdminUser(String tenantName)
      Description copied from interface: UserDAO
      Retrieve the administrator for the given tenant. The general rule is that the administrator's username is:
      1. admin if the tenant is default
      2. adminTenantname in all other cases
      Specified by:
      findAdminUser in interface UserDAO
      Parameters:
      tenantName - name of the tenant
      Returns:
      the user to administrate the tenant
    • findByGroup

      public Set<User> findByGroup(long groupId)
      Description copied from interface: UserDAO
      Retrieves the users belonging to a given group.
      Specified by:
      findByGroup in interface UserDAO
      Parameters:
      groupId - Identifier of the group
      Returns:
      the set of groups
    • findById

      public User findById(long id) throws PersistenceException
      Description copied from interface: PersistentObjectDAO
      This method finds an entity by ID
      Specified by:
      findById in interface PersistentObjectDAO<User>
      Overrides:
      findById in class HibernatePersistentObjectDAO<User>
      Parameters:
      id - ID of the entity
      Returns:
      Entity with given ID
      Throws:
      PersistenceException - raised in case of errors in the database
    • getUser

      public User getUser(String username)
      Description copied from interface: UserDAO
      Depending on the global setting, it invokes findByUsername or findByUsernameIgnoreCase
      Specified by:
      getUser in interface UserDAO
      Parameters:
      username - The username of the user
      Returns:
      The found user
    • setPasswordHistoryDAO

      public void setPasswordHistoryDAO(PasswordHistoryDAO passwordHistoryDAO)
    • setConfig

      public void setConfig(ContextProperties config)