Class JGitKeyCache

  • All Implemented Interfaces:
    KeyCache

    public class JGitKeyCache
    extends java.lang.Object
    implements KeyCache
    A simple KeyCache. JGit uses one such cache in its SshdSessionFactory to avoid loading keys multiple times.
    Since:
    5.2
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.concurrent.atomic.AtomicReference<java.util.Map<java.nio.file.Path,​java.security.KeyPair>> cache  
    • Constructor Summary

      Constructors 
      Constructor Description
      JGitKeyCache()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Removes all KeyPair from this cache and destroys their private keys.
      java.security.KeyPair get​(java.nio.file.Path path, java.util.function.Function<? super java.nio.file.Path,​? extends java.security.KeyPair> loader)
      Obtains a KeyPair from the cache.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • cache

        private java.util.concurrent.atomic.AtomicReference<java.util.Map<java.nio.file.Path,​java.security.KeyPair>> cache
    • Constructor Detail

      • JGitKeyCache

        public JGitKeyCache()
    • Method Detail

      • get

        public java.security.KeyPair get​(java.nio.file.Path path,
                                         java.util.function.Function<? super java.nio.file.Path,​? extends java.security.KeyPair> loader)
        Description copied from interface: KeyCache
        Obtains a KeyPair from the cache. Implementations must be thread-safe.
        Specified by:
        get in interface KeyCache
        Parameters:
        path - of the key
        loader - to load the key if it isn't present in the cache yet
        Returns:
        the KeyPair, or null if not present and could not be loaded
      • close

        public void close()
        Description copied from interface: KeyCache
        Removes all KeyPair from this cache and destroys their private keys. This cache instance must not be used anymore thereafter.
        Specified by:
        close in interface KeyCache