Top Description Fields Constructors Methods
org.apache.sshd.server.config.keys

public final Class ServerIdentity

extends Object
Class Inheritance
Imports
java.io.File, .IOException, java.nio.file.Files, .LinkOption, .Path, java.security.GeneralSecurityException, .KeyPair, java.util.Collections, .Map, .Properties, .TreeMap, java.util.function.Function, org.apache.sshd.common.NamedResource, org.apache.sshd.common.config.keys.IdentityUtils, org.apache.sshd.common.keyprovider.KeyPairProvider, org.apache.sshd.common.util.GenericUtils, .MapEntryUtils, .ValidateUtils, org.apache.sshd.common.util.io.IoUtils, org.apache.sshd.server.SshServer

Loads server identity key files - e.g., /etc/ssh/ssh_host_rsa_key
Author
Apache MINA SSHD Project
See Also
org.apache.sshd.common.util.security.SecurityUtils#getKeyPairResourceParser()

Field Summary

Modifier and TypeField and Description
public static final String
public static final String
HOST_KEY_CONFIG_PROP

The server's keys configuration multi-value

public static final String
public static final String
public static final Function<String, String>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Map<String, Path>

Returns:

A Map of the found certificates where key=the identity type (case insensitive) and value=the Path of the file holding the specific type key
findCertificates
(Properties
The Properties holding the server's configuration - ignored if null/empty
props
,
LinkOption...
The LinkOptions to use when checking files existence
options
)

public static Map<String, Path>

Returns:

A Map of the found identities where key=the identity type (case insensitive) and value=the Path of the file holding the specific type key
findIdentities
(Properties
The Properties holding the server's configuration - ignored if null/empty
props
,
LinkOption...
The LinkOptions to use when checking files existence
options
)

public static String
public static String

Returns:

The matching file name for the identity - null if no name
getIdentityFileName
(String
The identity type - e.g., rsa - ignored if null/empty
type
)

public static String

Returns:

The identity type - null if cannot determine it - e.g., does not start/end with the ID_FILE_PREFIX/ID_FILE_SUFFIX
getIdentityType
(String
The file name - ignored if null/empty
name
)

private static Map<String, Path>
getLocations(String configPropKey, Properties props, LinkOption... options)

public static Map<String, KeyPair>

Returns:

A Map of the identities where key=identity type (case insensitive), value=the KeyPair of the identity
loadIdentities
(Properties
The Properties holding the server's configuration - ignored if null/empty
props
,
LinkOption...
The LinkOptions to use when checking files existence
options
)

public static KeyPairProvider

Returns:

A KeyPair for the identities - null if no identities available (e.g., after filtering unsupported ones)
loadKeyPairProvider
(Properties
The Properties holding the server's configuration - ignored if null/empty
props
,
boolean
If true then ignore identities that are not supported internally
supportedOnly
,
LinkOption...
The LinkOptions to use when checking files existence
options
)

public static <
The generic server type
S extends SshServer
>
S

Returns:

The updated server
setKeyPairProvider
(S
The SshServer to configure
server
,
Properties
The Properties holding the server's configuration - ignored if null/empty
props
,
boolean
If true then ignore identities that are not supported internally
supportedOnly
)

Sets the server's KeyPairProvider with the loaded identities - if any

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

HOST_CERT_CONFIG_PROPback to summary
public static final String HOST_CERT_CONFIG_PROP
HOST_KEY_CONFIG_PROPback to summary
public static final String HOST_KEY_CONFIG_PROP

The server's keys configuration multi-value

ID_FILE_PREFIXback to summary
public static final String ID_FILE_PREFIX
ID_FILE_SUFFIXback to summary
public static final String ID_FILE_SUFFIX
ID_GENERATORback to summary
public static final Function<String, String> ID_GENERATOR

Constructor Detail

ServerIdentityback to summary
private ServerIdentity()

Method Detail

findCertificatesback to summary
public static Map<String, Path> findCertificates(Properties props, LinkOption... options) throws IOException
Parameters
props:Properties

The Properties holding the server's configuration - ignored if null/empty

options:LinkOption[]

The LinkOptions to use when checking files existence

Returns:Map<String, Path>

A Map of the found certificates where key=the identity type (case insensitive) and value=the Path of the file holding the specific type key

Exceptions
IOException:
If failed to access the file system
See Also
getIdentityType(String), HOST_CERT_CONFIG_PROP, org.apache.sshd.common.config.ConfigFileReaderSupport#readConfigFile(Path, java.nio.file.OpenOption...)
findIdentitiesback to summary
public static Map<String, Path> findIdentities(Properties props, LinkOption... options) throws IOException
Parameters
props:Properties

The Properties holding the server's configuration - ignored if null/empty

options:LinkOption[]

The LinkOptions to use when checking files existence

Returns:Map<String, Path>

A Map of the found identities where key=the identity type (case insensitive) and value=the Path of the file holding the specific type key

Exceptions
IOException:
If failed to access the file system
See Also
getIdentityType(String), HOST_KEY_CONFIG_PROP, org.apache.sshd.common.config.ConfigFileReaderSupport#readConfigFile(Path, java.nio.file.OpenOption...)
getIdentityFileNameback to summary
public static String getIdentityFileName(NamedResource r)
getIdentityFileNameback to summary
public static String getIdentityFileName(String type)
Parameters
type:String

The identity type - e.g., rsa - ignored if null/empty

Returns:String

The matching file name for the identity - null if no name

See Also
ID_FILE_PREFIX, ID_FILE_SUFFIX, IdentityUtils#getIdentityFileName(String, String, String)
getIdentityTypeback to summary
public static String getIdentityType(String name)
Parameters
name:String

The file name - ignored if null/empty

Returns:String

The identity type - null if cannot determine it - e.g., does not start/end with the ID_FILE_PREFIX/ID_FILE_SUFFIX

getLocationsback to summary
private static Map<String, Path> getLocations(String configPropKey, Properties props, LinkOption... options) throws IOException
loadIdentitiesback to summary
public static Map<String, KeyPair> loadIdentities(Properties props, LinkOption... options) throws IOException, GeneralSecurityException
Parameters
props:Properties

The Properties holding the server's configuration - ignored if null/empty

options:LinkOption[]

The LinkOptions to use when checking files existence

Returns:Map<String, KeyPair>

A Map of the identities where key=identity type (case insensitive), value=the KeyPair of the identity

Exceptions
IOException:
If failed to access the file system
GeneralSecurityException:
If failed to load the keys
See Also
findIdentities(Properties, LinkOption...)
loadKeyPairProviderback to summary
public static KeyPairProvider loadKeyPairProvider(Properties props, boolean supportedOnly, LinkOption... options) throws IOException, GeneralSecurityException
Parameters
props:Properties

The Properties holding the server's configuration - ignored if null/empty

supportedOnly:boolean

If true then ignore identities that are not supported internally

options:LinkOption[]

The LinkOptions to use when checking files existence

Returns:KeyPairProvider

A KeyPair for the identities - null if no identities available (e.g., after filtering unsupported ones)

Exceptions
IOException:
If failed to access the file system
GeneralSecurityException:
If failed to load the keys
See Also
loadIdentities(Properties, LinkOption...), IdentityUtils#createKeyPairProvider(Map, boolean)
setKeyPairProviderback to summary
public static <S extends SshServer> S setKeyPairProvider(S server, Properties props, boolean supportedOnly) throws IOException, GeneralSecurityException

Sets the server's KeyPairProvider with the loaded identities - if any

Parameters
<S>
The generic server type
server:S

The SshServer to configure

props:Properties

The Properties holding the server's configuration - ignored if null/empty

supportedOnly:boolean

If true then ignore identities that are not supported internally

Returns:S

The updated server

Exceptions
IOException:
If failed to access the file system
GeneralSecurityException:
If failed to load the keys
See Also
loadKeyPairProvider(Properties, boolean, LinkOption...)