com.ls.security
Class PublicKeyCache

java.lang.Object
  |
  +--com.ls.security.PublicKeyCache

public class PublicKeyCache
extends Object

Helper class for the living systems PKI public key caching. The whole functionality is realized static, so there is no need to instantiate a PublicKeyCache object and every component within the Virtual Machine can take advantage from the caching.

Version:
$Revision: 1.5 $
Author:
Last modified by $Author: JBogenschuetz $

Field Summary
protected static Map publicKeyCache
          Contains a usrId or platformId (IP, Port, larsId) as key and byte-array containing the user's or platform's publicKey-certificate.
 
Constructor Summary
PublicKeyCache()
           
 
Method Summary
static void cacheAdd(Map newPublicKeys)
          Adds several public key certificates to the cache.
static void cacheAdd(String keyID, byte[] publicKeyCertificate)
          Adds a public key certificate with the given keyID as key to the cache.
static boolean cacheCheck(String keyID)
          checks if the given keyID exists in the cache
static void cacheClear()
          empties the cache
static byte[] cacheGet(String keyID)
          Gets the publicKeyCertificate with the given keyID from the cache
static HashMap cacheGetAll()
          Gets all publicKeyCertificates stored in the cache.
static void cacheRemove(String keyID)
          removes the public key certificate of the given key from cache
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

publicKeyCache

protected static Map publicKeyCache
Contains a usrId or platformId (IP, Port, larsId) as key and byte-array containing the user's or platform's publicKey-certificate.

Access to this cache needs to be synchronized!

Constructor Detail

PublicKeyCache

public PublicKeyCache()
Method Detail

cacheAdd

public static void cacheAdd(String keyID,
                            byte[] publicKeyCertificate)
                     throws IllegalArgumentException
Adds a public key certificate with the given keyID as key to the cache. An entry with a identical key is overwritten.
Parameters:
keyID - the id to specifiy the public key certificate
publicKeyCertificate - the public key certificate to store in the cache
Throws:
IllegalArgumentException - If keyID or publicKeyCertificate is null

cacheAdd

public static void cacheAdd(Map newPublicKeys)
                     throws IllegalArgumentException
Adds several public key certificates to the cache. The given Map has to have the keys (keyID) as String and values (public key certificate) as byte[], else a IllegalArgumentException is thrown and the adding of following entries isn't done! Entries with identical keys are overwritten.
Parameters:
newPublicKeys - contains the public key certificates to add
Throws:
IllegalArgumentException - If the map hasn't got the correct structure

cacheCheck

public static boolean cacheCheck(String keyID)
checks if the given keyID exists in the cache
Parameters:
keyID - the id to specifiy the public key certificate
Returns:
true if it exists, else false

cacheGet

public static byte[] cacheGet(String keyID)
                       throws IllegalArgumentException
Gets the publicKeyCertificate with the given keyID from the cache
Parameters:
keyID - the id of the wanted public key certificate
Returns:
byte array which contain publicKey
Throws:
IllegalArgumentException - If the keyID doesn't exist in the cache

cacheGetAll

public static HashMap cacheGetAll()
Gets all publicKeyCertificates stored in the cache.
Returns:
HashMap which contains all public key certificates

cacheClear

public static void cacheClear()
empties the cache

cacheRemove

public static void cacheRemove(String keyID)
removes the public key certificate of the given key from cache
Parameters:
keyID - id to remove