Package com.logicaldoc.core.security.apikey

# Class HibernateApiKeyDAO

java.lang.Object
com.logicaldoc.core.HibernatePersistentObjectDAO<ApiKey>
com.logicaldoc.core.security.apikey.HibernateApiKeyDAO

All Implemented Interfaces:
  `PersistentObjectDAO<ApiKey>`, `ApiKeyDAO`

@Repository("apiKeyDAO") public class HibernateApiKeyDAO extends HibernatePersistentObjectDAO<ApiKey> implements ApiKeyDAO
Hibernate implementation of `ApiKeyDAO`

Since:
  8.9.4
Author:
  Marco Meschieri - LogicalDOC

## Field Summary

### Fields inherited from interface com.logicaldoc.core.PersistentObjectDAO

`ENTITY`

## Method Summary

Modifier and Type
Method
Description
`void`
`delete(long id, int code)`
This method deletes an entity and you can give a deletion code
`ApiKey`
`findByKey(String key)`
Finds the ApiKey by the unique key
`ApiKey`
`findByName(String name, long userId)`
Finds the user's ApiKey with a given name
`List<ApiKey>`
`findByUser(long userId)`
Finds the user's ApiKeys for a given user
`void`
`store(ApiKey apiKey)`
This method persists the entity object

### Methods inherited from class com.logicaldoc.core.HibernatePersistentObjectDAO

`bulkUpdate, count, deleteAll, evict, evict, findById, findByObjectQuery, findByQuery, findByQuery, findByWhere, findIdsByWhere, getDatabaseMetadata, initialize, jdbcUpdate, jdbcUpdate, query, queryForDouble, queryForDouble, queryForInt, queryForInt, queryForList, queryForList, queryForList, queryForLong, queryForLong, queryForObject, queryForObject, queryForResultSet, queryForString, 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, count, count, count, delete, deleteAll, deleteAll, evict, evict, findAll, findAll, findAllIds, findAllIds, findById, findById, findByObjectQuery, findByQuery, findByQuery, findByWhere, findByWhere, findIdsByWhere, findIdsByWhere, getDatabaseMetadata, getDbms, initialize, initialize, isMariaDB, isMySQL, isOracle, isPostgreSQL, isSQLServer, jdbcUpdate, jdbcUpdate, query, query, queryForDouble, queryForDouble, queryForInt, queryForInt, queryForList, queryForList, queryForList, queryForLong, queryForLong, queryForObject, queryForObject, queryForResultSet, queryForString, queryForString`

## Method Details

### store

public void store(ApiKey apiKey) throws PersistenceException
Description copied from interface: `PersistentObjectDAO`
This method persists the entity object

Specified by:
  `store` in interface `PersistentObjectDAO<ApiKey>`
Overrides:
  `store` in class `HibernatePersistentObjectDAO<ApiKey>`
Parameters:
  `apiKey` - entity to be stored
Throws:
  `PersistenceException` - raised in case of errors in the database

### findByName

public ApiKey findByName(String name, long userId) throws PersistenceException
Description copied from interface: `ApiKeyDAO`
Finds the user's ApiKey with a given name

Specified by:
  `findByName` in interface `ApiKeyDAO`
Parameters:
  `name` - the name of the ApiKey
  `userId` - the identifier of the user
Returns:
  The unique matching ApiKey
Throws:
  `PersistenceException` - Error in the database

### findByKey

public ApiKey findByKey(String key) throws PersistenceException, NoSuchAlgorithmException
Description copied from interface: `ApiKeyDAO`
Finds the ApiKey by the unique key

Specified by:
  `findByKey` in interface `ApiKeyDAO`
Parameters:
  `key` - the key to find
Returns:
  The unique matching ApiKey
Throws:
  `PersistenceException` - Error in the database
  `NoSuchAlgorithmException` - Error when encripting the key

### findByUser

public List<ApiKey> findByUser(long userId) throws PersistenceException
Description copied from interface: `ApiKeyDAO`
Finds the user's ApiKeys for a given user

Specified by:
  `findByUser` in interface `ApiKeyDAO`
Parameters:
  `userId` - the identifier of the user
Returns:
  The list of api keys ordered by name
Throws:
  `PersistenceException` - Error in the database

### delete

public void delete(long id, 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<ApiKey>`
Overrides:
  `delete` in class `HibernatePersistentObjectDAO<ApiKey>`
Parameters:
  `id` - ID of the entity which should be deleted
  `code` - Deletion code
Throws:
  `PersistenceException` - raised in case of errors in the database