Class HibernateUserDAO
java.lang.Object
com.logicaldoc.core.HibernatePersistentObjectDAO<User>
com.logicaldoc.core.security.user.HibernateUserDAO
- All Implemented Interfaces:
PersistentObjectDAO<User>,UserDAO
@Repository("userDAO")
public class HibernateUserDAO
extends HibernatePersistentObjectDAO<User>
implements UserDAO
Hibernate implementation of
UserDAO- Since:
- 3.0
- Author:
- Marco Meschieri - LogicalDOC
-
Field Summary
Fields inherited from interface com.logicaldoc.core.PersistentObjectDAO
ENTITY -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckPasswordCompliance(User user) Checks if the user's password complies the current quality criteriaintCounts the total number of standard usersintcountGuests(Long tenantId) Counts the total number of guest usersvoiddelete(long userId, int code) This method deletes an entity and you can give a deletion codevoiddelete(long userId, UserHistory transaction) This method deletes the user object and insert a new user history entry.findAdminUser(String tenantName) Retrieve the administrator for the given tenant.findByGroup(long groupId) Retrieves the users belonging to a given group.findById(long id) This method finds an entity by IDfindByLikeUsername(String username) This method finds an User by username.findByName(String name) This method finds an User by name.findByUsername(String username) This method finds an User by its username.findByUsernameAndName(String username, String name) This method finds an User by username and name.findByUsernameIgnoreCase(String username) This method finds an User by its username.findUserSettings(long userId, String namePrefix) Retrieves the settings for a user.Depending on the global setting, it invokes findByUsername or findByUsernameIgnoreCasestatic booleanvoidinitialize(User user) Doesn't do anything by defaultbooleanisInactive(String username) Checks if a user is inactive, that is a user without interactions in the last X days after it has last enabled.booleanisPasswordExpired(String username) Is password expired.voidsetConfig(ContextProperties config) voidsetGenericDAO(GenericDAO genericDAO) voidsetPasswordHistoryDAO(PasswordHistoryDAO passwordHistoryDAO) voidsetUserHistoryDAO(UserHistoryDAO userHistoryDAO) voidsetUserListenerManager(UserListenerManager userListenerManager) voidThis method persists the entity objectvoidstore(User user, UserHistory transaction) This method persists the user object and insert a new user history entry.Methods inherited from class com.logicaldoc.core.HibernatePersistentObjectDAO
bulkUpdate, delete, deleteAll, deleteAll, evict, evict, findAll, findAll, findAllIds, findAllIds, findById, findByObjectQuery, findByQuery, findByQuery, findByWhere, findByWhere, findIdsByWhere, findIdsByWhere, getDatabaseMetadata, getDbms, isMySQL, isOracle, jdbcUpdate, jdbcUpdate, query, query, queryForDouble, queryForDouble, queryForInt, queryForInt, queryForList, queryForList, queryForList, queryForLong, queryForLong, queryForObject, queryForObject, queryForResultSet, queryForString, queryForString, setSessionFactoryMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.logicaldoc.core.PersistentObjectDAO
bulkUpdate, delete, deleteAll, deleteAll, evict, evict, findAll, findAll, findAllIds, findAllIds, findById, findByObjectQuery, findByQuery, findByQuery, findByWhere, findByWhere, findIdsByWhere, findIdsByWhere, getDatabaseMetadata, getDbms, isMySQL, isOracle, jdbcUpdate, jdbcUpdate, query, query, queryForDouble, queryForDouble, queryForInt, queryForInt, queryForList, queryForList, queryForList, queryForLong, queryForLong, queryForObject, queryForObject, queryForResultSet, queryForString, queryForString
-
Method Details
-
ignoreCaseLogin
public static boolean ignoreCaseLogin() -
findByName
Description copied from interface:UserDAOThis method finds an User by name.- Specified by:
findByNamein interfaceUserDAO- Parameters:
name- The name of wanted User.- Returns:
- Collection of selected users.
- Throws:
PersistenceException- Error in the database
-
findByUsername
Description copied from interface:UserDAOThis method finds an User by its username. The search is case sensitive.- Specified by:
findByUsernamein interfaceUserDAO- Parameters:
username- username of wanted User.- Returns:
- Wanted User or null if user doesn't exist.
- Throws:
PersistenceException- Error in the data layer
-
findByUsernameIgnoreCase
Description copied from interface:UserDAOThis method finds an User by its username. The search is case insensitive.- Specified by:
findByUsernameIgnoreCasein interfaceUserDAO- Parameters:
username- username of wanted User.- Returns:
- Wanted User or null if user doesn't exist.
- Throws:
PersistenceException- Error in the data layer
-
findByLikeUsername
Description copied from interface:UserDAOThis method finds an User by username.- Specified by:
findByLikeUsernamein interfaceUserDAO- Parameters:
username- The username of wanted User.- Returns:
- Collection of selected users.
- Throws:
PersistenceException- Error in the database
-
findByUsernameAndName
Description copied from interface:UserDAOThis method finds an User by username and name.- Specified by:
findByUsernameAndNamein interfaceUserDAO- Parameters:
username- The username of wanted username- The name of wanted user- Returns:
- Collection of selected users
- Throws:
PersistenceException- Error in the database
-
checkPasswordCompliance
Description copied from interface:UserDAOChecks if the user's password complies the current quality criteria- Specified by:
checkPasswordCompliancein interfaceUserDAO- Parameters:
user- The user to check- Throws:
PasswordWeakException- Raised when the password does not comply with the quality criteriaPersistenceException- Error in the database
-
store
Description copied from interface:PersistentObjectDAOThis method persists the entity object- Specified by:
storein interfacePersistentObjectDAO<User>- Overrides:
storein classHibernatePersistentObjectDAO<User>- Parameters:
user- entity to be stored- Throws:
PersistenceException- raised in case of errors in the databasePasswordAlreadyUsedException
-
store
public void store(User user, UserHistory transaction) throws PasswordAlreadyUsedException, PersistenceException Description copied from interface:UserDAOThis method persists the user object and insert a new user history entry.- Specified by:
storein interfaceUserDAO- Parameters:
user- the user to storetransaction- entry to log the event- Throws:
PersistenceException- error at database levelPasswordAlreadyUsedException
-
isPasswordExpired
Description copied from interface:UserDAOIs password expired.- Specified by:
isPasswordExpiredin interfaceUserDAO- Parameters:
username- Username of the User to be validated.- Returns:
- True if the password is expired
-
isInactive
Description copied from interface:UserDAOChecks if a user is inactive, that is a user without interactions in the last X days after it has last enabled. We look at theUser.getMaxInactivity()first and then we fallback to the general parameter security.user.maxinactivity- Specified by:
isInactivein interfaceUserDAO- Parameters:
username- identifier of the user- Returns:
- the last interaction time
- Throws:
PersistenceException- Error in the database
-
count
Description copied from interface:UserDAOCounts the total number of standard users- Specified by:
countin interfaceUserDAO- Parameters:
tenantId- identifier of the tenant- Returns:
- total number of guest users
- Throws:
PersistenceException- Error in the database
-
countGuests
Description copied from interface:UserDAOCounts the total number of guest users- Specified by:
countGuestsin interfaceUserDAO- Parameters:
tenantId- identifier of the tenant- Returns:
- total number of guest users
- Throws:
PersistenceException- Error in the database
-
delete
Description copied from interface:PersistentObjectDAOThis method deletes an entity and you can give a deletion code- Specified by:
deletein interfacePersistentObjectDAO<User>- Overrides:
deletein classHibernatePersistentObjectDAO<User>- Parameters:
userId- ID of the entity which should be deletedcode- Deletion code- Throws:
PersistenceException- raised in case of errors in the database
-
delete
Description copied from interface:UserDAOThis method deletes the user object and insert a new user history entry.- Specified by:
deletein interfaceUserDAO- Parameters:
userId- The id of the user to deletetransaction- entry to log the event- Throws:
PersistenceException- error at database level
-
getUserHistoryDAO
-
setUserHistoryDAO
-
setUserListenerManager
-
getUserListenerManager
-
initialize
Description copied from class:HibernatePersistentObjectDAODoesn't do anything by default- Specified by:
initializein interfacePersistentObjectDAO<User>- Overrides:
initializein classHibernatePersistentObjectDAO<User>- Parameters:
user- The entity to be initialised- Throws:
PersistenceException- Error in the database
-
findUserSettings
public Map<String,Generic> findUserSettings(long userId, String namePrefix) throws PersistenceException Description copied from interface:UserDAORetrieves the settings for a user. The settings are stored as Generics of type usersetting.- Specified by:
findUserSettingsin interfaceUserDAO- Parameters:
userId- Identifier of the usernamePrefix- Name prefix of the property (optional)- Returns:
- The map setting_name-generic
- Throws:
PersistenceException- Error in the database
-
setGenericDAO
-
findAdminUser
Description copied from interface:UserDAORetrieve the administrator for the given tenant. The general rule is that the administrator's username is:- admin if the tenant is default
- adminTenantname in all other cases
- Specified by:
findAdminUserin interfaceUserDAO- Parameters:
tenantName- name of the tenant- Returns:
- the user to administrate the tenant
- Throws:
PersistenceException- Error in the database
-
findByGroup
Description copied from interface:UserDAORetrieves the users belonging to a given group.- Specified by:
findByGroupin interfaceUserDAO- Parameters:
groupId- Identifier of the group- Returns:
- the set of groups
- Throws:
PersistenceException- Error in the database
-
findById
Description copied from interface:PersistentObjectDAOThis method finds an entity by ID- Specified by:
findByIdin interfacePersistentObjectDAO<User>- Overrides:
findByIdin classHibernatePersistentObjectDAO<User>- Parameters:
id- ID of the entity- Returns:
- Entity with given ID
- Throws:
PersistenceException- raised in case of errors in the database
-
getUser
Description copied from interface:UserDAODepending on the global setting, it invokes findByUsername or findByUsernameIgnoreCase- Specified by:
getUserin interfaceUserDAO- Parameters:
username- The username of the user- Returns:
- The found user
- Throws:
PersistenceException- Error in the data layer
-
setPasswordHistoryDAO
-
setConfig
-