Package ch.threema.apitool
Class PublicKeyStore
java.lang.Object
ch.threema.apitool.PublicKeyStore
Stores and caches public keys for Threema users. Extend this class to provide your own storage
implementation, e.g. in a file or database.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract byte[]fetchPublicKey(String threemaId) Fetch the public key for the given Threema ID from the store.final byte[]getPublicKey(String threemaId) Get the public key for a given Threema ID.protected abstract voidSave the public key for a given Threema ID in the store.final voidsetPublicKey(String threemaId, byte[] publicKey) Store the public key for a given Threema ID in the cache, and the underlying store.
-
Constructor Details
-
PublicKeyStore
public PublicKeyStore()
-
-
Method Details
-
getPublicKey
Get the public key for a given Threema ID. The cache is checked first; if it is not found in the cache, fetchPublicKey() is called.- Parameters:
threemaId- The Threema ID whose public key should be obtained- Returns:
- The public key, or null if not found.
-
setPublicKey
Store the public key for a given Threema ID in the cache, and the underlying store.- Parameters:
threemaId- The Threema ID whose public key should be storedpublicKey- The corresponding public key.
-
fetchPublicKey
Fetch the public key for the given Threema ID from the store. Override to provide your own implementation to read from the store.- Parameters:
threemaId- The Threema ID whose public key should be obtained- Returns:
- The public key, or null if not found.
-
save
Save the public key for a given Threema ID in the store. Override to provide your own implementation to write to the store.- Parameters:
threemaId- The Threema ID whose public key should be storedpublicKey- The corresponding public key.
-