Class ServerIdentity

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String HOST_KEY_CONFIG_PROP
      The server's keys configuration multi-value
      static java.lang.String ID_FILE_PREFIX  
      static java.lang.String ID_FILE_SUFFIX  
      static java.util.function.Function<java.lang.String,​java.lang.String> ID_GENERATOR  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private ServerIdentity()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Map<java.lang.String,​java.nio.file.Path> findIdentities​(java.util.Properties props, java.nio.file.LinkOption... options)  
      static java.lang.String getIdentityFileName​(java.lang.String type)  
      static java.lang.String getIdentityFileName​(NamedResource r)  
      static java.lang.String getIdentityType​(java.lang.String name)  
      static java.util.Map<java.lang.String,​java.security.KeyPair> loadIdentities​(java.util.Properties props, java.nio.file.LinkOption... options)  
      static KeyPairProvider loadKeyPairProvider​(java.util.Properties props, boolean supportedOnly, java.nio.file.LinkOption... options)  
      static <S extends SshServer>
      S
      setKeyPairProvider​(S server, java.util.Properties props, boolean supportedOnly)
      Sets the server's KeyPairProvider with the loaded identities - if any
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • 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
      • ID_GENERATOR

        public static final java.util.function.Function<java.lang.String,​java.lang.String> ID_GENERATOR
    • Constructor Detail

      • ServerIdentity

        private ServerIdentity()
    • 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's KeyPairProvider with the loaded identities - if any
        Type Parameters:
        S - The generic server type
        Parameters:
        server - The SshServer to configure
        props - The Properties holding the server's configuration - ignored if null/empty
        supportedOnly - If true then ignore identities that are not supported internally
        Returns:
        The updated server
        Throws:
        java.io.IOException - If failed to access the file system
        java.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 - The Properties holding the server's configuration - ignored if null/empty
        supportedOnly - If true then ignore identities that are not supported internally
        options - The LinkOptions to use when checking files existence
        Returns:
        A KeyPair for the identities - null if no identities available (e.g., after filtering unsupported ones)
        Throws:
        java.io.IOException - If failed to access the file system
        java.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 - The Properties holding the server's configuration - ignored if null/empty
        options - The LinkOptions to use when checking files existence
        Returns:
        A Map of the identities where key=identity type (case insensitive), value=the KeyPair of the identity
        Throws:
        java.io.IOException - If failed to access the file system
        java.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 - The Properties holding the server's configuration - ignored if null/empty
        options - The LinkOptions to use when checking files existence
        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
        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...)
      • getIdentityType

        public static java.lang.String getIdentityType​(java.lang.String name)
        Parameters:
        name - The file name - ignored if null/empty
        Returns:
        The identity type - null if cannot determine it - e.g., does not start/end with the ID_FILE_PREFIX/ID_FILE_SUFFIX
      • getIdentityFileName

        public static java.lang.String getIdentityFileName​(NamedResource r)