Package com.logicaldoc.core.security.dao
Class HibernateDeviceDAO
- java.lang.Object
-
- com.logicaldoc.core.HibernatePersistentObjectDAO<Device>
-
- com.logicaldoc.core.security.dao.HibernateDeviceDAO
-
- All Implemented Interfaces:
PersistentObjectDAO<Device>
,DeviceDAO
public class HibernateDeviceDAO extends HibernatePersistentObjectDAO<Device> implements DeviceDAO
An Hibernate based implementation ofDeviceDAO
- Since:
- 8.5.3
- Author:
- Marco Meschieri - LogicalDOC
-
-
Field Summary
-
Fields inherited from interface com.logicaldoc.core.PersistentObjectDAO
ENTITY
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cleanOldDevices(int ttl)
This method deletes all the devices lastly used before the given days since now.void
delete(long deviceId, int code)
This method deletes an entity and you can give a deletion codeDevice
findByDevice(Device device)
Finds the device that corresponds to the given oneDevice
findByDeviceId(String deviceId)
Gets the device by it's alternate key:Device.getDeviceId()
List<Device>
findByUserId(long userId)
Finds the devices of a specific userList<Device>
findTrustedDevices(long userId)
Retrieves all the devices trusted by a given userboolean
isTrustedDevice(String username, javax.servlet.http.HttpServletRequest request)
Checks if the current request's device is trusted by the uservoid
setUserDAO(UserDAO userDAO)
void
store(Device entity)
This method persists the entity objectDevice
trustDevice(User user, Device requestDevice)
Trusts a device for a user-
Methods inherited from class com.logicaldoc.core.HibernatePersistentObjectDAO
bulkUpdate, bulkUpdate, delete, deleteAll, deleteAll, findAll, findAll, findAllIds, findAllIds, findById, findById, findByObjectQuery, findByObjectQuery, findByQuery, findByQuery, findByWhere, findByWhere, findByWhere, findIdsByWhere, findIdsByWhere, getDbms, getSessionFactory, initialize, isOracle, jdbcUpdate, jdbcUpdate, query, queryForInt, queryForList, queryForList, queryForLong, 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, bulkUpdate, delete, deleteAll, deleteAll, findAll, findAll, findAllIds, findAllIds, findById, findById, findByObjectQuery, findByObjectQuery, findByQuery, findByQuery, findByWhere, findByWhere, findByWhere, findIdsByWhere, findIdsByWhere, getDbms, initialize, isOracle, jdbcUpdate, jdbcUpdate, query, queryForInt, queryForList, queryForList, queryForLong, queryForLong, queryForObject, queryForRowSet, queryForString
-
-
-
-
Method Detail
-
findByDeviceId
public Device findByDeviceId(String deviceId)
Description copied from interface:DeviceDAO
Gets the device by it's alternate key:Device.getDeviceId()
- Specified by:
findByDeviceId
in interfaceDeviceDAO
- Parameters:
deviceId
- identifier of the device- Returns:
- the found device
-
findTrustedDevices
public List<Device> findTrustedDevices(long userId)
Description copied from interface:DeviceDAO
Retrieves all the devices trusted by a given user- Specified by:
findTrustedDevices
in interfaceDeviceDAO
- Parameters:
userId
- the user to consider- Returns:
- the list of devices ordered by descending last login date
-
findByUserId
public List<Device> findByUserId(long userId)
Description copied from interface:DeviceDAO
Finds the devices of a specific user- Specified by:
findByUserId
in interfaceDeviceDAO
- Parameters:
userId
- identifier of the user- Returns:
- the list of devices ordered by descending last login date
-
trustDevice
public Device trustDevice(User user, Device requestDevice) throws PersistenceException
Description copied from interface:DeviceDAO
Trusts a device for a user- Specified by:
trustDevice
in interfaceDeviceDAO
- Parameters:
user
- the current userrequestDevice
- the device to trust- Returns:
- the trusted device
- Throws:
PersistenceException
- an error happened in the database
-
cleanOldDevices
public void cleanOldDevices(int ttl)
Description copied from interface:DeviceDAO
This method deletes all the devices lastly used before the given days since now. Ifttl
is 0 or -1, the cancellation is not made.- Specified by:
cleanOldDevices
in interfaceDeviceDAO
- Parameters:
ttl
- The maximum number of days over which the device is considered old
-
store
public void store(Device entity) throws PersistenceException
Description copied from interface:PersistentObjectDAO
This method persists the entity object- Specified by:
store
in interfacePersistentObjectDAO<Device>
- Overrides:
store
in classHibernatePersistentObjectDAO<Device>
- Parameters:
entity
- entity to be stored- Throws:
PersistenceException
- raised in case of errors in the database
-
isTrustedDevice
public boolean isTrustedDevice(String username, javax.servlet.http.HttpServletRequest request)
Description copied from interface:DeviceDAO
Checks if the current request's device is trusted by the user- Specified by:
isTrustedDevice
in interfaceDeviceDAO
- Parameters:
username
- username of the current userrequest
- the current request- Returns:
- true only if the request's device is trusted by the user
-
findByDevice
public Device findByDevice(Device device)
Description copied from interface:DeviceDAO
Finds the device that corresponds to the given one- Specified by:
findByDevice
in interfaceDeviceDAO
- Parameters:
device
- the device to take as model- Returns:
- the found device
-
delete
public void delete(long deviceId, 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 interfacePersistentObjectDAO<Device>
- Overrides:
delete
in classHibernatePersistentObjectDAO<Device>
- Parameters:
deviceId
- ID of the entity which should be deletedcode
- Deletion code- Throws:
PersistenceException
- raised in case of errors in the database
-
setUserDAO
public void setUserDAO(UserDAO userDAO)
-
-