Class ServerIdentity
- java.lang.Object
-
- org.apache.sshd.server.config.keys.ServerIdentity
-
public final class ServerIdentity extends java.lang.ObjectLoads server identity key files - e.g.,/etc/ssh/ssh_host_rsa_key- See Also:
SecurityUtils.getKeyPairResourceParser()
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringHOST_CERT_CONFIG_PROPstatic java.lang.StringHOST_KEY_CONFIG_PROPThe server's keys configuration multi-valuestatic java.lang.StringID_FILE_PREFIXstatic java.lang.StringID_FILE_SUFFIXstatic java.util.function.Function<java.lang.String,java.lang.String>ID_GENERATOR
-
Constructor Summary
Constructors Modifier Constructor Description privateServerIdentity()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.Map<java.lang.String,java.nio.file.Path>findCertificates(java.util.Properties props, java.nio.file.LinkOption... options)static java.util.Map<java.lang.String,java.nio.file.Path>findIdentities(java.util.Properties props, java.nio.file.LinkOption... options)static java.lang.StringgetIdentityFileName(java.lang.String type)static java.lang.StringgetIdentityFileName(NamedResource r)static java.lang.StringgetIdentityType(java.lang.String name)private static java.util.Map<java.lang.String,java.nio.file.Path>getLocations(java.lang.String configPropKey, java.util.Properties props, java.nio.file.LinkOption... options)static java.util.Map<java.lang.String,java.security.KeyPair>loadIdentities(java.util.Properties props, java.nio.file.LinkOption... options)static KeyPairProviderloadKeyPairProvider(java.util.Properties props, boolean supportedOnly, java.nio.file.LinkOption... options)static <S extends SshServer>
SsetKeyPairProvider(S server, java.util.Properties props, boolean supportedOnly)Sets the server'sKeyPairProviderwith the loaded identities - if any
-
-
-
Field Detail
-
ID_FILE_PREFIX
public static final java.lang.String ID_FILE_PREFIX
- See Also:
- Constant Field Values
-
ID_FILE_SUFFIX
public static final java.lang.String ID_FILE_SUFFIX
- See Also:
- Constant Field Values
-
HOST_KEY_CONFIG_PROP
public static final java.lang.String HOST_KEY_CONFIG_PROP
The server's keys configuration multi-value- See Also:
- Constant Field Values
-
HOST_CERT_CONFIG_PROP
public static final java.lang.String HOST_CERT_CONFIG_PROP
- See Also:
- Constant Field Values
-
ID_GENERATOR
public static final java.util.function.Function<java.lang.String,java.lang.String> ID_GENERATOR
-
-
Method Detail
-
setKeyPairProvider
public static <S extends SshServer> S setKeyPairProvider(S server, java.util.Properties props, boolean supportedOnly) throws java.io.IOException, java.security.GeneralSecurityException
Sets the server'sKeyPairProviderwith the loaded identities - if any- Type Parameters:
S- The generic server type- Parameters:
server- TheSshServerto configureprops- ThePropertiesholding the server's configuration - ignored ifnull/emptysupportedOnly- Iftruethen ignore identities that are not supported internally- Returns:
- The updated server
- Throws:
java.io.IOException- If failed to access the file systemjava.security.GeneralSecurityException- If failed to load the keys- See Also:
loadKeyPairProvider(Properties, boolean, LinkOption...)
-
loadKeyPairProvider
public static KeyPairProvider loadKeyPairProvider(java.util.Properties props, boolean supportedOnly, java.nio.file.LinkOption... options) throws java.io.IOException, java.security.GeneralSecurityException
- Parameters:
props- ThePropertiesholding the server's configuration - ignored ifnull/emptysupportedOnly- Iftruethen ignore identities that are not supported internallyoptions- TheLinkOptions to use when checking files existence- Returns:
- A
KeyPairfor the identities -nullif no identities available (e.g., after filtering unsupported ones) - Throws:
java.io.IOException- If failed to access the file systemjava.security.GeneralSecurityException- If failed to load the keys- See Also:
loadIdentities(Properties, LinkOption...),IdentityUtils.createKeyPairProvider(Map, boolean)
-
loadIdentities
public static java.util.Map<java.lang.String,java.security.KeyPair> loadIdentities(java.util.Properties props, java.nio.file.LinkOption... options) throws java.io.IOException, java.security.GeneralSecurityException- Parameters:
props- ThePropertiesholding the server's configuration - ignored ifnull/emptyoptions- TheLinkOptions to use when checking files existence- Returns:
- A
Mapof the identities where key=identity type (case insensitive), value=theKeyPairof the identity - Throws:
java.io.IOException- If failed to access the file systemjava.security.GeneralSecurityException- If failed to load the keys- See Also:
findIdentities(Properties, LinkOption...)
-
findIdentities
public static java.util.Map<java.lang.String,java.nio.file.Path> findIdentities(java.util.Properties props, java.nio.file.LinkOption... options) throws java.io.IOException- Parameters:
props- ThePropertiesholding the server's configuration - ignored ifnull/emptyoptions- TheLinkOptions to use when checking files existence- Returns:
- A
Mapof the found identities where key=the identity type (case insensitive) and value=thePathof the file holding the specific type key - Throws:
java.io.IOException- If failed to access the file system- See Also:
getIdentityType(String),HOST_KEY_CONFIG_PROP,ConfigFileReaderSupport.readConfigFile(Path, java.nio.file.OpenOption...)
-
findCertificates
public static java.util.Map<java.lang.String,java.nio.file.Path> findCertificates(java.util.Properties props, java.nio.file.LinkOption... options) throws java.io.IOException- Parameters:
props- ThePropertiesholding the server's configuration - ignored ifnull/emptyoptions- TheLinkOptions to use when checking files existence- Returns:
- A
Mapof the found certificates where key=the identity type (case insensitive) and value=thePathof the file holding the specific type key - Throws:
java.io.IOException- If failed to access the file system- See Also:
getIdentityType(String),HOST_CERT_CONFIG_PROP,ConfigFileReaderSupport.readConfigFile(Path, java.nio.file.OpenOption...)
-
getLocations
private static java.util.Map<java.lang.String,java.nio.file.Path> getLocations(java.lang.String configPropKey, java.util.Properties props, java.nio.file.LinkOption... options) throws java.io.IOException- Throws:
java.io.IOException
-
getIdentityType
public static java.lang.String getIdentityType(java.lang.String name)
- Parameters:
name- The file name - ignored ifnull/empty- Returns:
- The identity type -
nullif cannot determine it - e.g., does not start/end with theID_FILE_PREFIX/ID_FILE_SUFFIX
-
getIdentityFileName
public static java.lang.String getIdentityFileName(NamedResource r)
-
getIdentityFileName
public static java.lang.String getIdentityFileName(java.lang.String type)
- Parameters:
type- The identity type - e.g.,rsa- ignored ifnull/empty- Returns:
- The matching file name for the identity -
nullif no name - See Also:
ID_FILE_PREFIX,ID_FILE_SUFFIX,IdentityUtils.getIdentityFileName(String, String, String)
-
-