Class AsymmetricKeyPreCalculator
- All Implemented Interfaces:
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.
- See Also:
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptioncall()static voidCommandline handler to pre-populate the key cache.static StringGets the currently set filename for key pre-calculation.static intGet the number of maximum threads used for cache pre-calculation.static AsymmetricKeygetPrecomputedAsymmetricKey(AlgorithmParameter parameters) retrieves a precomputed key from the cache.voidCommand line helper to list cached items.voidCommand line helper to remove a cached item type from the cache.voidremoveCacheElement(int index) Remove a the specified item type from the cache.static StringsetCacheFileName(String name) Set name of cache file.voidCommand line helper to set the maximum cache size of a cached item.voidsetCacheSize(int index, int size) Set the maximum cache size of a cached item.static intsetNumThreads(int newNumThreads) Set the maximum number of working threads for the cache pre-calculator.
-
Field Details
-
DEFAULT_CACHE_FILENAME
- See Also:
-
serialVersionUID
public static final long serialVersionUID- See Also:
-
-
Method Details
-
getPrecomputedAsymmetricKey
retrieves a precomputed key from the cache.
- Parameters:
parameters- the parameters reflecting the requested key- Returns:
- the requested key
-
setNumThreads
public static int setNumThreads(int newNumThreads) Set the maximum number of working threads for the cache pre-calculator.
- Parameters:
newNumThreads- the number of threads used for pre-calculation- Returns:
- the previously set number of threads
-
getNumThreads
public static int getNumThreads()Get the number of maximum threads used for cache pre-calculation.
- Returns:
- the currently set number of threads
-
getCacheFileName
Gets the currently set filename for key pre-calculation.
- Returns:
- the currently set filename
-
setCacheFileName
Set name of cache file.
If set to null the pre-calculator is disabled.
- Parameters:
name- file name of the cache file- Returns:
- String representing the previously set name
- Throws:
IllegalThreadStateException- if the previous thread has not yet shutdown but a new thread was tried to be started
-
fillCache
public static void fillCache()Commandline handler to pre-populate the key cache.
-
call
- Specified by:
callin interfaceCallable<Integer>- Throws:
IOException
-
setCacheSize
Command line helper to set the maximum cache size of a cached item.
- Throws:
IOException- if the specified file is not fond or there was an error when reading
-
setCacheSize
Set the maximum cache size of a cached item.
- Parameters:
index- the index of the cached itemsize- the size to be set- Throws:
IOException- if the specified file is not fond or there was an error when reading
-
removeCacheElement
Command line helper to remove a cached item type from the cache.
- Throws:
IOException- if the specified file is not fond or there was an error when reading
-
removeCacheElement
Remove a the specified item type from the cache.
- Parameters:
index- the index of the element to be removed- Throws:
IOException- if the specified file is not fond or there was an error when reading
-
listCache
Command line helper to list cached items.
- Throws:
IOException- if the specified file is not fond or there was an error when reading
-