Class 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.
    Author:
    Gerd Behrmann (behrmann@ndgf.org)
    • 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 size bits. 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.