Class JdbcApiKeyRepository
java.lang.Object
com.codename1.backend.security.apikey.JdbcApiKeyRepository
- All Implemented Interfaces:
ApiKeyRepository
API keys kept in the server's database, in the cn1_api_key table of
SecuritySchema. Only a key's hash is
stored; the key itself is shown once, by ApiKeyGenerator, and never again.
@Bean
ApiKeyRepository apiKeys(DataSource dataSource) {
return new JdbcApiKeyRepository(dataSource);
}
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanForgets the key with this id altogether.findByHash(String hash) The key with this hash, or null.findByOwner(String owner) The keys of one owner, oldest first.booleanRevokes the key with this id.voidStores a new key.voidThe clock a key's creation time is read from; for tests.
-
Constructor Details
-
JdbcApiKeyRepository
-
-
Method Details
-
setClock
The clock a key's creation time is read from; for tests. -
findByHash
Description copied from interface:ApiKeyRepositoryThe key with this hash, or null. A revoked key is returned like any other; refusing it is the caller's.- Specified by:
findByHashin interfaceApiKeyRepository- Parameters:
hash- the lowercase hexadecimal SHA-256 of a presented key
-
save
Stores a new key. A scope may not contain a space.- Throws:
IOException
-
revoke
Revokes the key with this id.- Returns:
- whether this call revoked it: false when there is no such key, or it was revoked already
- Throws:
IOException
-
delete
Forgets the key with this id altogether.- Throws:
IOException
-
findByOwner
The keys of one owner, oldest first.- Throws:
IOException
-