Package com.logicaldoc.core.security.dao
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 ofUserDAO
- Since:
- 3.0
- Author:
- Marco Meschieri - LogicalDOC
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
count(Long tenantId)
Counts the total number of standard usersint
countGuests(Long tenantId)
Counts the total number of guest usersboolean
delete(long userId, int code)
This method deletes an entity and you can give a deletion codeboolean
delete(long userId, UserHistory transaction)
This method deletes the user object and insert a new user history entry.User
findAdminUser(String tenantName)
Retrieve the administrator for the given tenant.Set<User>
findByGroup(long groupId)
Retrieves the users belonging to a given group.User
findById(long id)
This method finds an entity by IDList<User>
findByLikeUsername(String username)
This method finds an User by username.List<User>
findByName(String name)
This method finds an User by name.User
findByUsername(String username)
This method finds an User by its username.List<User>
findByUsernameAndName(String username, String name)
This method finds an User by username and name.User
findByUsernameIgnoreCase(String username)
This method finds an User by its username.Map<String,Generic>
findUserSettings(long userId, String namePrefix)
Retrieves the settings for a user.int
getPasswordTtl()
User
getUser(String username)
Depending on the global setting, it invokes findByUsername or findByUsernameIgnoreCaseUserHistoryDAO
getUserHistoryDAO()
UserListenerManager
getUserListenerManager()
static boolean
ignoreCaseLogin()
void
initialize(User user)
Doesn't do anything by defaultboolean
isPasswordExpired(String username)
Is password expired.void
setConfig(ContextProperties config)
void
setGenericDAO(GenericDAO genericDAO)
void
setUserHistoryDAO(UserHistoryDAO userHistoryDAO)
void
setUserListenerManager(UserListenerManager userListenerManager)
boolean
store(User user)
This method persists the entity objectboolean
store(User user, UserHistory transaction)
This method persists the user object and insert a new user history entry.boolean
validateUser(String username)
Validates an username only (the password content is not inspectged.boolean
validateUser(String username, String password)
Validates an username and a password-
Methods inherited from class com.logicaldoc.core.HibernatePersistentObjectDAO
bulkUpdate, delete, deleteAll, deleteAll, findAll, findAll, findAllIds, findAllIds, findById, findByObjectQuery, findByQuery, findByWhere, findByWhere, findIdsByWhere, findIdsByWhere, getDbms, getSessionFactory, isOracle, jdbcUpdate, jdbcUpdate, query, queryForInt, queryForList, queryForList, queryForLong, queryForObject, queryForRowSet, queryForString, setSessionFactory
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.logicaldoc.core.PersistentObjectDAO
bulkUpdate, delete, deleteAll, deleteAll, findAll, findAll, findAllIds, findAllIds, findById, findByObjectQuery, findByQuery, findByWhere, findByWhere, findIdsByWhere, findIdsByWhere, getDbms, isOracle, jdbcUpdate, jdbcUpdate, query, queryForInt, queryForList, queryForList, queryForLong, queryForObject, queryForRowSet, queryForString
-
-
-
-
Method Detail
-
ignoreCaseLogin
public static boolean ignoreCaseLogin()
-
delete
public boolean delete(long userId, int code)
Description copied from interface:PersistentObjectDAO
This method deletes an entity and you can give a deletion code- Specified by:
delete
in interfacePersistentObjectDAO<User>
- Overrides:
delete
in classHibernatePersistentObjectDAO<User>
- Parameters:
userId
- ID of the entity which should be deletedcode
- Deletion code- Returns:
- if the record has been successfully deleted
-
findByName
public List<User> findByName(String name)
Description copied from interface:UserDAO
This method finds an User by name.- Specified by:
findByName
in interfaceUserDAO
- 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 interfaceUserDAO
- 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 interfaceUserDAO
- 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 interfaceUserDAO
- Parameters:
username
- The username of wanted User.- Returns:
- Collection of selected users.
- See Also:
UserDAO.findByUsername(java.lang.String)
-
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 interfaceUserDAO
- Parameters:
username
- The username of wanted username
- The name of wanted user- Returns:
- Collection of selected users
-
store
public boolean store(User user)
Description copied from interface:PersistentObjectDAO
This method persists the entity object- Specified by:
store
in interfacePersistentObjectDAO<User>
- Overrides:
store
in classHibernatePersistentObjectDAO<User>
- Parameters:
user
- entity to be stored- Returns:
- True if successfully stored in a database
-
store
public boolean store(User user, UserHistory transaction)
Description copied from interface:UserDAO
This method persists the user object and insert a new user history entry.
-
validateUser
public boolean validateUser(String username, String password)
Description copied from interface:UserDAO
Validates an username and a password- Specified by:
validateUser
in interfaceUserDAO
- Parameters:
username
- Username of the User to be validatedpassword
- Password of the User to be validated- Returns:
- True if User is valid and authenticated.
- See Also:
UserDAO.validateUser(java.lang.String, java.lang.String)
-
validateUser
public boolean validateUser(String username)
Description copied from interface:UserDAO
Validates an username only (the password content is not inspectged.- Specified by:
validateUser
in interfaceUserDAO
- Parameters:
username
- Username of the User to be validated.- Returns:
- True if User is valid.
-
getPasswordTtl
public int getPasswordTtl()
-
isPasswordExpired
public boolean isPasswordExpired(String username)
Description copied from interface:UserDAO
Is password expired.- Specified by:
isPasswordExpired
in interfaceUserDAO
- Parameters:
username
- Username of the User to be validate.- Returns:
- True if the password is expired
-
count
public int count(Long tenantId)
Description copied from interface:UserDAO
Counts the total number of standard users
-
countGuests
public int countGuests(Long tenantId)
Description copied from interface:UserDAO
Counts the total number of guest users- Specified by:
countGuests
in interfaceUserDAO
- Parameters:
tenantId
- identifier of the tenant- Returns:
- total number of guest users
-
delete
public boolean delete(long userId, UserHistory transaction)
Description copied from interface:UserDAO
This method deletes the user object and insert a new user history entry.
-
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 interfacePersistentObjectDAO<User>
- Overrides:
initialize
in classHibernatePersistentObjectDAO<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 interfaceUserDAO
- Parameters:
userId
- Identifier of the usernamePrefix
- 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:- admin if the tenant is default
- adminTenantname in all other cases
- Specified by:
findAdminUser
in interfaceUserDAO
- Parameters:
tenantName
- name of the tenant- Returns:
- the user to administrate the tenant
-
setConfig
public void setConfig(ContextProperties config)
-
findByGroup
public Set<User> findByGroup(long groupId)
Description copied from interface:UserDAO
Retrieves the users belonging to a given group.- Specified by:
findByGroup
in interfaceUserDAO
- Parameters:
groupId
- Identifier of the group- Returns:
- the set of groups
-
findById
public User findById(long id)
Description copied from interface:PersistentObjectDAO
This method finds an entity by ID- Specified by:
findById
in interfacePersistentObjectDAO<User>
- Overrides:
findById
in classHibernatePersistentObjectDAO<User>
- Parameters:
id
- ID of the entity- Returns:
- Entity with given ID
-
-