Package com.logicaldoc.core.security.apikey

# Interface ApiKeyDAO

All Superinterfaces:
  `PersistentObjectDAO<ApiKey>`

All Known Implementing Classes:
  `HibernateApiKeyDAO`

public interface ApiKeyDAO extends PersistentObjectDAO<ApiKey>
DAO for `ApiKey` handling.

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
`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
`static ApiKeyDAO`
`get()`
Gets the object available in the application context

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

`bulkUpdate, count, count, count, delete, 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, store`

## Method Details

### get

static ApiKeyDAO get()
Gets the object available in the application context

Returns:
  the instance of this object in the application context

### findByName

ApiKey findByName(String name, long userId) throws PersistenceException
Finds the user's ApiKey with a given name

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

ApiKey findByKey(String key) throws PersistenceException, NoSuchAlgorithmException
Finds the ApiKey by the unique key

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

### findByUser

List<ApiKey> findByUser(long userId) throws PersistenceException
Finds the user's ApiKeys for a given user

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