Class ClientIdentity
java.lang.Object
org.apache.sshd.client.config.keys.ClientIdentity
Provides keys loading capability from the user's keys folder - e.g.,
id_rsa
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
getIdentityFileName
(String type) static String
static String
getIdentityType
(String name) loadDefaultIdentities
(boolean strict, FilePasswordProvider provider, LinkOption... options) loadDefaultIdentities
(Path dir, boolean strict, FilePasswordProvider provider, LinkOption... options) static KeyPairProvider
loadDefaultKeyPairProvider
(boolean strict, boolean supportedOnly, FilePasswordProvider provider, LinkOption... options) static KeyPairProvider
loadDefaultKeyPairProvider
(Path dir, boolean strict, boolean supportedOnly, FilePasswordProvider provider, LinkOption... options) loadIdentities
(SessionContext session, Path dir, boolean strict, Collection<String> types, Function<? super String, String> idGenerator, FilePasswordProvider provider, LinkOption... options) Scans a folder and loads all available identity filesscanIdentitiesFolder
(Path dir, boolean strict, Collection<String> types, Function<? super String, String> idGenerator, LinkOption... options) Scans a folder for possible identity files
-
Field Details
-
ID_FILE_PREFIX
- See Also:
-
ID_FILE_SUFFIX
- See Also:
-
ID_GENERATOR
-
-
Constructor Details
-
ClientIdentity
private ClientIdentity()
-
-
Method Details
-
getIdentityType
- Parameters:
name
- The file name - ignored ifnull
/empty- Returns:
- The identity type -
null
if cannot determine it - e.g., does not start with theID_FILE_PREFIX
-
getIdentityFileName
-
getIdentityFileName
- Parameters:
type
- The identity type - e.g.,rsa
- ignored ifnull
/empty- Returns:
- The matching file name for the identity -
null
if no name - See Also:
-
loadDefaultKeyPairProvider
public static KeyPairProvider loadDefaultKeyPairProvider(boolean strict, boolean supportedOnly, FilePasswordProvider provider, LinkOption... options) throws IOException, GeneralSecurityException - Parameters:
strict
- Iftrue
then files that do not have the required access rights are excluded from considerationsupportedOnly
- Iftrue
then ignore identities that are not supported internallyprovider
- AFilePasswordProvider
- may benull
if the loaded keys are guaranteed not to be encrypted. The argument toFilePasswordProvider#getPassword
is the path of the file whose key is to be loadedoptions
- TheLinkOption
s to apply when checking for existence- Returns:
- A
KeyPair
for the identities -null
if no identities available (e.g., after filtering unsupported ones or strict permissions) - Throws:
IOException
- If failed to access the file systemGeneralSecurityException
- If failed to load the keys- See Also:
-
loadDefaultKeyPairProvider
public static KeyPairProvider loadDefaultKeyPairProvider(Path dir, boolean strict, boolean supportedOnly, FilePasswordProvider provider, LinkOption... options) throws IOException, GeneralSecurityException - Parameters:
dir
- The folder to scan for the built-in identitiesstrict
- Iftrue
then files that do not have the required access rights are excluded from considerationsupportedOnly
- Iftrue
then ignore identities that are not supported internallyprovider
- AFilePasswordProvider
- may benull
if the loaded keys are guaranteed not to be encrypted. The argument toFilePasswordProvider#getPassword
is the path of the file whose key is to be loadedoptions
- TheLinkOption
s to apply when checking for existence- Returns:
- A
KeyPair
for the identities -null
if no identities available (e.g., after filtering unsupported ones or strict permissions) - Throws:
IOException
- If failed to access the file systemGeneralSecurityException
- If failed to load the keys- See Also:
-
loadDefaultIdentities
public static Map<String,KeyPair> loadDefaultIdentities(boolean strict, FilePasswordProvider provider, LinkOption... options) throws IOException, GeneralSecurityException - Parameters:
strict
- Iftrue
then files that do not have the required access rights are excluded from considerationprovider
- AFilePasswordProvider
- may benull
if the loaded keys are guaranteed not to be encrypted. The argument toFilePasswordProvider#getPassword
is the path of the file whose key is to be loadedoptions
- TheLinkOption
s to apply when checking for existence- Returns:
- A
Map
of the found files where key=identity type (case insensitive), value=theKeyPair
of the identity - Throws:
IOException
- If failed to access the file systemGeneralSecurityException
- If failed to load the keys- See Also:
-
loadDefaultIdentities
public static Map<String,KeyPair> loadDefaultIdentities(Path dir, boolean strict, FilePasswordProvider provider, LinkOption... options) throws IOException, GeneralSecurityException - Parameters:
dir
- The folder to scan for the built-in identitiesstrict
- Iftrue
then files that do not have the required access rights are excluded from considerationprovider
- AFilePasswordProvider
- may benull
if the loaded keys are guaranteed not to be encrypted. The argument toFilePasswordProvider#getPassword
is the path of the file whose key is to be loadedoptions
- TheLinkOption
s to apply when checking for existence- Returns:
- A
Map
of the found files where key=identity type (case insensitive), value=theKeyPair
of the identity - Throws:
IOException
- If failed to access the file systemGeneralSecurityException
- If failed to load the keys- See Also:
-
loadIdentities
public static Map<String,KeyPair> loadIdentities(SessionContext session, Path dir, boolean strict, Collection<String> types, Function<? super String, String> idGenerator, FilePasswordProvider provider, LinkOption... options) throws IOException, GeneralSecurityExceptionScans a folder and loads all available identity files- Parameters:
session
- TheSessionContext
for invoking this load command - may benull
if not invoked within a session context (e.g., offline tool or session unknown).dir
- ThePath
of the folder to scan - ignored if not existsstrict
- Iftrue
then files that do not have the required access rights are excluded from considerationtypes
- The identity types - ignored ifnull
/emptyidGenerator
- AFunction
to derive the file name holding the specified typeprovider
- AFilePasswordProvider
- may benull
if the loaded keys are guaranteed not to be encrypted. The argument toFilePasswordProvider#getPassword
is the path of the file whose key is to be loadedoptions
- TheLinkOption
s to apply when checking for existence- Returns:
- A
Map
of the found files where key=identity type (case insensitive), value=theKeyPair
of the identity - Throws:
IOException
- If failed to access the file systemGeneralSecurityException
- If failed to load the keys
-
scanIdentitiesFolder
public static Map<String,Path> scanIdentitiesFolder(Path dir, boolean strict, Collection<String> types, Function<? super String, String> idGenerator, LinkOption... options) throws IOExceptionScans a folder for possible identity files- Parameters:
dir
- ThePath
of the folder to scan - ignored if not existsstrict
- Iftrue
then files that do not have the required access rights are excluded from considerationtypes
- The identity types - ignored ifnull
/emptyidGenerator
- AFunction
to derive the file name holding the specified typeoptions
- TheLinkOption
s to apply when checking for existence- Returns:
- A
Map
of the found files where key=identity type (case insensitive), value=thePath
of the file holding the key - Throws:
IOException
- If failed to access the file system- See Also:
-