Package org.globus.gsi.gssapi
Class KeyPairCache
- java.lang.Object
-
- org.globus.gsi.gssapi.KeyPairCache
-
public class KeyPairCache extends java.lang.Object
Simple cache for key pairs. The cache is used to avoid excessive CPU consumption from key pair generation. In particular for purposes of delegation, reusing a key pair is safe.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
KeyPairCache.KeyPairCacheEntry
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
algorithm
static java.lang.String
DEFAULT_ALGORITHM
static java.lang.String
DEFAULT_PROVIDER
private java.util.Map
entries
Hash table of cache entries.private static KeyPairCache
keyPairCache
private long
lifetime
private static org.apache.commons.logging.Log
logger
private java.lang.String
provider
-
Constructor Summary
Constructors Modifier Constructor Description private
KeyPairCache(java.lang.String algorithm, java.lang.String provider, long lifetime)
Creates a KeyPairCache object for the specified algorithm, as supplied from the specified provider.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.security.KeyPair
getKeyPair(int bits)
Returns a key pair of sizebits
.static KeyPairCache
getKeyPairCache()
static KeyPairCache
getKeyPairCache(java.lang.String algorithm, java.lang.String provider, long lifetime)
-
-
-
Field Detail
-
logger
private static org.apache.commons.logging.Log logger
-
DEFAULT_ALGORITHM
public static final java.lang.String DEFAULT_ALGORITHM
- See Also:
- Constant Field Values
-
DEFAULT_PROVIDER
public static final java.lang.String DEFAULT_PROVIDER
- See Also:
- Constant Field Values
-
algorithm
private final java.lang.String algorithm
-
provider
private final java.lang.String provider
-
lifetime
private final long lifetime
-
keyPairCache
private static KeyPairCache keyPairCache
-
entries
private final java.util.Map entries
Hash table of cache entries. The use ofHashtable
is significant, since we rely on access to the table being synchronized.
-
-
Constructor Detail
-
KeyPairCache
private KeyPairCache(java.lang.String algorithm, java.lang.String provider, long lifetime)
Creates a KeyPairCache object for the specified algorithm, as supplied from the specified provider.- Parameters:
algorithm
- the standard string name of the algorithm. See Appendix A in the Java Cryptography Architecture API Specification & Reference for information about standard algorithm names.provider
- the string name of the provider.lifetime
- the lifetime of the cache in milliseconds.
-
-
Method Detail
-
getKeyPairCache
public static KeyPairCache getKeyPairCache()
-
getKeyPairCache
public static KeyPairCache getKeyPairCache(java.lang.String algorithm, java.lang.String provider, long lifetime)
-
getKeyPair
public java.security.KeyPair getKeyPair(int bits) throws java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException
Returns a key pair of sizebits
. The same key pair may be returned several times within a period of the cache lifetime. If lifetime was set to zero or less than zero, no keys are cached.- Parameters:
bits
- the keysize. This is an algorithm-specific metric, such as modulus length, specified in number of bits.- Throws:
java.security.NoSuchAlgorithmException
- if the algorithm is not available in the environment.java.security.NoSuchProviderException
- if the provider is not available in the environment.
-
-