Class IdentityUtils
- java.lang.Object
-
- org.apache.sshd.common.config.keys.IdentityUtils
-
public final class IdentityUtils extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
IdentityUtils.LazyDefaultUserHomeFolderHolder
-
Constructor Summary
Constructors Modifier Constructor Description private
IdentityUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static KeyPairProvider
createKeyPairProvider(java.util.Map<java.lang.String,java.security.KeyPair> ids, boolean supportedOnly)
static java.lang.String
getIdentityFileName(java.lang.String prefix, java.lang.String type, java.lang.String suffix)
static java.nio.file.Path
getUserHomeFolder()
static java.util.NavigableMap<java.lang.String,java.security.KeyPair>
loadIdentities(SessionContext session, java.util.Map<java.lang.String,? extends java.nio.file.Path> paths, FilePasswordProvider provider, java.nio.file.OpenOption... options)
-
-
-
Method Detail
-
getUserHomeFolder
public static java.nio.file.Path getUserHomeFolder()
- Returns:
- The
Path
to the currently running user home
-
getIdentityFileName
public static java.lang.String getIdentityFileName(java.lang.String prefix, java.lang.String type, java.lang.String suffix)
- Parameters:
prefix
- The file name prefix - ignored ifnull
/emptytype
- The identity type - ignored ifnull
/emptysuffix
- The file name suffix - ignored ifnull
/empty- Returns:
- The identity file name or
null
if no name
-
createKeyPairProvider
public static KeyPairProvider createKeyPairProvider(java.util.Map<java.lang.String,java.security.KeyPair> ids, boolean supportedOnly)
- Parameters:
ids
- AMap
of the loaded identities where key=the identity type, value=the matchingKeyPair
- ignored ifnull
/emptysupportedOnly
- Iftrue
then ignore identities that are not supported internally- Returns:
- A
KeyPair
for the identities -null
if no identities available (e.g., after filtering unsupported ones) - See Also:
BuiltinIdentities
-
loadIdentities
public static java.util.NavigableMap<java.lang.String,java.security.KeyPair> loadIdentities(SessionContext session, java.util.Map<java.lang.String,? extends java.nio.file.Path> paths, FilePasswordProvider provider, java.nio.file.OpenOption... options) throws java.io.IOException, java.security.GeneralSecurityException
- Parameters:
session
- TheSessionContext
for invoking this load command - may benull
if not invoked within a session context (e.g., offline tool or session unknown).paths
- AMap
of the identities where key=identity type (case insensitive), value=thePath
of file with the identity keyprovider
- 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
- TheOpenOption
s to use when reading the key data- Returns:
- A
NavigableMap
of the identities where key=identity type (case insensitive), value=theKeyPair
of the identity - Throws:
java.io.IOException
- If failed to access the file systemjava.security.GeneralSecurityException
- If failed to load the keys
-
-