Class ClientIdentityFileWatcher
java.lang.Object
org.apache.sshd.common.util.logging.AbstractLoggingBean
org.apache.sshd.common.util.io.ModifiableFileWatcher
org.apache.sshd.client.config.keys.ClientIdentityFileWatcher
- All Implemented Interfaces:
ClientIdentityLoaderHolder
,ClientIdentityProvider
,FilePasswordProviderHolder
public class ClientIdentityFileWatcher
extends ModifiableFileWatcher
implements ClientIdentityProvider, ClientIdentityLoaderHolder, FilePasswordProviderHolder
A
ClientIdentityProvider
that watches a given key file re-loading its contents if it is ever modified,
deleted or (re-)created-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AtomicReference<Iterable<KeyPair>>
private final ClientIdentityLoaderHolder
private final FilePasswordProviderHolder
private final boolean
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
-
Constructor Summary
ConstructorsConstructorDescriptionClientIdentityFileWatcher
(Path path, ClientIdentityLoaderHolder loader, FilePasswordProviderHolder provider) ClientIdentityFileWatcher
(Path path, ClientIdentityLoaderHolder loader, FilePasswordProviderHolder provider, boolean strict) ClientIdentityFileWatcher
(Path path, ClientIdentityLoader loader, FilePasswordProvider provider) ClientIdentityFileWatcher
(Path path, ClientIdentityLoader loader, FilePasswordProvider provider, boolean strict) -
Method Summary
Modifier and TypeMethodDescriptiongetClientIdentities
(SessionContext session) Provides aKeyPair
representing the client identityboolean
isStrict()
reloadClientIdentities
(SessionContext session, Path path) Methods inherited from class org.apache.sshd.common.util.io.ModifiableFileWatcher
checkReloadRequired, exists, getPath, lastModified, resetReloadAttributes, size, toPathResource, toPathResource, toString, updateReloadAttributes, validateStrictConfigFilePermissions
-
Field Details
-
identitiesHolder
-
loaderHolder
-
providerHolder
-
strict
private final boolean strict
-
-
Constructor Details
-
ClientIdentityFileWatcher
public ClientIdentityFileWatcher(Path path, ClientIdentityLoader loader, FilePasswordProvider provider) -
ClientIdentityFileWatcher
public ClientIdentityFileWatcher(Path path, ClientIdentityLoader loader, FilePasswordProvider provider, boolean strict) -
ClientIdentityFileWatcher
public ClientIdentityFileWatcher(Path path, ClientIdentityLoaderHolder loader, FilePasswordProviderHolder provider) -
ClientIdentityFileWatcher
public ClientIdentityFileWatcher(Path path, ClientIdentityLoaderHolder loader, FilePasswordProviderHolder provider, boolean strict)
-
-
Method Details
-
isStrict
public boolean isStrict() -
getClientIdentityLoader
- Specified by:
getClientIdentityLoader
in interfaceClientIdentityLoaderHolder
- Returns:
- The
ClientIdentityLoader
to use in order to load client key pair identities - nevernull
-
getFilePasswordProvider
- Specified by:
getFilePasswordProvider
in interfaceFilePasswordProviderHolder
- Returns:
- The
FilePasswordProvider
to use if need to load encrypted identities keys - nevernull
- See Also:
-
getClientIdentities
public Iterable<KeyPair> getClientIdentities(SessionContext session) throws IOException, GeneralSecurityException Description copied from interface:ClientIdentityProvider
Provides aKeyPair
representing the client identity- Specified by:
getClientIdentities
in interfaceClientIdentityProvider
- Parameters:
session
- TheSessionContext
for invoking this load command - may benull
if not invoked within a session context (e.g., offline tool).- Returns:
- The client identities - may be
null
/empty if no currently available identity from this provider. Note: the provider may return a different value every time this method is called - e.g., if it is (re-)loading contents from a file. - Throws:
IOException
- If failed to load the identityGeneralSecurityException
- If failed to parse the identity
-
reloadClientIdentities
protected Iterable<KeyPair> reloadClientIdentities(SessionContext session, Path path) throws IOException, GeneralSecurityException - Throws:
IOException
GeneralSecurityException
-