public class AsymmetricKeyPreCalculator extends Object implements Serializable, Callable<Integer>
This is a class to precalculate keys.
It is disabled by default. Enable it by setting a caching file Name. To disable set the name to null.
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_CACHE_FILENAME |
static long |
serialVersionUID |
Modifier and Type | Method and Description |
---|---|
Integer |
call() |
static void |
fillCache()
Commandline handler to pre-populate the key cache.
|
static String |
getCacheFileName()
Gets the currently set filename for key pre-calculation.
|
static int |
getNumThreads()
Get the number of maximum threads used for cache pre-calculation.
|
static AsymmetricKey |
getPrecomputedAsymmetricKey(AlgorithmParameter parameters)
retrieves a precomputed key from the cache.
|
void |
listCache()
Command line helper to list cached items.
|
void |
removeCacheElement()
Command line helper to remove a cached item type from the cache.
|
void |
removeCacheElement(int index)
Remove a the specified item type from the cache.
|
static String |
setCacheFileName(String name)
Set name of cache file.
|
void |
setCacheSize()
Command line helper to set the maximum cache size of a cached item.
|
void |
setCacheSize(int index,
int size)
Set the maximum cache size of a cached item.
|
static int |
setNumThreads(int newNumThreads)
Set the maximum number of working threads for the cache pre-calculator.
|
public static final String DEFAULT_CACHE_FILENAME
public static final long serialVersionUID
public static AsymmetricKey getPrecomputedAsymmetricKey(AlgorithmParameter parameters)
retrieves a precomputed key from the cache.
parameters
- the parameters reflecting the requested keypublic static int setNumThreads(int newNumThreads)
Set the maximum number of working threads for the cache pre-calculator.
newNumThreads
- the number of threads used for pre-calculationpublic static int getNumThreads()
Get the number of maximum threads used for cache pre-calculation.
public static String getCacheFileName()
Gets the currently set filename for key pre-calculation.
public static String setCacheFileName(String name)
Set name of cache file.
If set to null the pre-calculator is disabled.
name
- file name of the cache fileIllegalThreadStateException
- if the previous thread has not yet shutdown but a new
thread was tried to be startedpublic static void fillCache()
Commandline handler to pre-populate the key cache.
public Integer call() throws IOException
call
in interface Callable<Integer>
IOException
public void setCacheSize() throws IOException
Command line helper to set the maximum cache size of a cached item.
IOException
- if the specified file is not fond or there was an error when readingpublic void setCacheSize(int index, int size) throws IOException
Set the maximum cache size of a cached item.
index
- the index of the cached itemsize
- the size to be setIOException
- if the specified file is not fond or there was an error when readingpublic void removeCacheElement() throws IOException
Command line helper to remove a cached item type from the cache.
IOException
- if the specified file is not fond or there was an error when readingpublic void removeCacheElement(int index) throws IOException
Remove a the specified item type from the cache.
index
- the index of the element to be removedIOException
- if the specified file is not fond or there was an error when readingpublic void listCache() throws IOException
Command line helper to list cached items.
IOException
- if the specified file is not fond or there was an error when readingCopyright © 2023. All rights reserved.