Class FileWatcherKeyPairResourceLoader
- java.lang.Object
-
- org.apache.sshd.common.util.logging.AbstractLoggingBean
-
- org.apache.sshd.common.util.io.ModifiableFileWatcher
-
- org.apache.sshd.common.config.keys.loader.FileWatcherKeyPairResourceLoader
-
- All Implemented Interfaces:
KeyPairResourceLoader
public class FileWatcherKeyPairResourceLoader extends ModifiableFileWatcher implements KeyPairResourceLoader
Tracks a file containingKeyPair
-s an re-loads it whenever a change has been sensed in the monitored file (if it exists)- Author:
- Apache MINA SSHD Project
-
-
Field Summary
Fields Modifier and Type Field Description protected AtomicReference<Collection<KeyPair>>
keysHolder
-
Fields inherited from class org.apache.sshd.common.util.io.ModifiableFileWatcher
options, STRICTLY_PROHIBITED_FILE_PERMISSION
-
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
Fields inherited from interface org.apache.sshd.common.config.keys.loader.KeyPairResourceLoader
EMPTY, MAX_CIPHER_NAME_LENGTH, MAX_KEY_COMMENT_LENGTH, MAX_KEY_TYPE_NAME_LENGTH, MAX_PRIVATE_KEY_DATA_SIZE, MAX_PUBLIC_KEY_DATA_SIZE
-
-
Constructor Summary
Constructors Constructor Description FileWatcherKeyPairResourceLoader(Path file, KeyPairResourceLoader delegateLoader)
FileWatcherKeyPairResourceLoader(Path file, KeyPairResourceLoader delegateLoader, LinkOption... options)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description KeyPairResourceLoader
getKeyPairResourceLoader()
Collection<KeyPair>
loadKeyPairs(SessionContext session, NamedResource resourceKey, FilePasswordProvider passwordProvider, List<String> lines)
Loads key pairs from the given resource text linesprotected Collection<KeyPair>
reloadKeyPairs(SessionContext session, NamedResource resourceKey, FilePasswordProvider passwordProvider, List<String> lines)
void
setKeyPairResourceLoader(KeyPairResourceLoader loader)
-
Methods inherited from class org.apache.sshd.common.util.io.ModifiableFileWatcher
checkReloadRequired, exists, getPath, lastModified, resetReloadAttributes, size, toPathResource, toPathResource, toString, updateReloadAttributes, validateStrictConfigFilePermissions
-
Methods inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warn
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.sshd.common.config.keys.loader.KeyPairResourceLoader
loadKeyPairs, loadKeyPairs, loadKeyPairs, loadKeyPairs, loadKeyPairs, loadKeyPairs, loadKeyPairs, loadKeyPairs, loadKeyPairs, loadKeyPairs, loadKeyPairs
-
-
-
-
Field Detail
-
keysHolder
protected final AtomicReference<Collection<KeyPair>> keysHolder
-
-
Constructor Detail
-
FileWatcherKeyPairResourceLoader
public FileWatcherKeyPairResourceLoader(Path file, KeyPairResourceLoader delegateLoader)
-
FileWatcherKeyPairResourceLoader
public FileWatcherKeyPairResourceLoader(Path file, KeyPairResourceLoader delegateLoader, LinkOption... options)
-
-
Method Detail
-
getKeyPairResourceLoader
public KeyPairResourceLoader getKeyPairResourceLoader()
-
setKeyPairResourceLoader
public void setKeyPairResourceLoader(KeyPairResourceLoader loader)
-
loadKeyPairs
public Collection<KeyPair> loadKeyPairs(SessionContext session, NamedResource resourceKey, FilePasswordProvider passwordProvider, List<String> lines) throws IOException, GeneralSecurityException
Description copied from interface:KeyPairResourceLoader
Loads key pairs from the given resource text lines- Specified by:
loadKeyPairs
in interfaceKeyPairResourceLoader
- Parameters:
session
- TheSessionContext
for invoking this load command - may benull
if not invoked within a session context (e.g., offline tool or session unknown).resourceKey
- A hint as to the origin of the text linespasswordProvider
- TheFilePasswordProvider
to use in case the data is encrypted - may benull
if no encrypted data is expectedlines
- TheList
of lines as read from the resource- Returns:
- The extracted
KeyPair
s - may benull
/empty if none. Note: the resource loader may decide to skip unknown lines if more than one key pair type is encoded in it - Throws:
IOException
- If failed to process the linesGeneralSecurityException
- If failed to generate the keys from the parsed data
-
reloadKeyPairs
protected Collection<KeyPair> reloadKeyPairs(SessionContext session, NamedResource resourceKey, FilePasswordProvider passwordProvider, List<String> lines) throws IOException, GeneralSecurityException
- Throws:
IOException
GeneralSecurityException
-
-