Class AuthorizedKeysAuthenticator

    • Field Detail

      • STD_AUTHORIZED_KEYS_FILENAME

        public static final java.lang.String STD_AUTHORIZED_KEYS_FILENAME
        Standard OpenSSH authorized keys file name
        See Also:
        Constant Field Values
      • delegateHolder

        private final java.util.concurrent.atomic.AtomicReference<PublickeyAuthenticator> delegateHolder
    • Constructor Detail

      • AuthorizedKeysAuthenticator

        public AuthorizedKeysAuthenticator​(java.nio.file.Path file)
      • AuthorizedKeysAuthenticator

        public AuthorizedKeysAuthenticator​(java.nio.file.Path file,
                                           java.nio.file.LinkOption... options)
    • Method Detail

      • authenticate

        public boolean authenticate​(java.lang.String username,
                                    java.security.PublicKey key,
                                    ServerSession session)
        Description copied from interface: PublickeyAuthenticator
        Check the validity of a public key.
        Specified by:
        authenticate in interface PublickeyAuthenticator
        Parameters:
        username - the username
        key - the key
        session - the server session
        Returns:
        a boolean indicating if authentication succeeded or not
      • isValidUsername

        protected boolean isValidUsername​(java.lang.String username,
                                          ServerSession session)
      • resolvePublickeyAuthenticator

        protected PublickeyAuthenticator resolvePublickeyAuthenticator​(java.lang.String username,
                                                                       ServerSession session)
                                                                throws java.io.IOException,
                                                                       java.security.GeneralSecurityException
        Throws:
        java.io.IOException
        java.security.GeneralSecurityException
      • createDelegateAuthenticator

        protected PublickeyAuthenticator createDelegateAuthenticator​(java.lang.String username,
                                                                     ServerSession session,
                                                                     java.nio.file.Path path,
                                                                     java.util.Collection<AuthorizedKeyEntry> entries,
                                                                     PublicKeyEntryResolver fallbackResolver)
                                                              throws java.io.IOException,
                                                                     java.security.GeneralSecurityException
        Throws:
        java.io.IOException
        java.security.GeneralSecurityException
      • reloadAuthorizedKeys

        protected java.util.Collection<AuthorizedKeyEntry> reloadAuthorizedKeys​(java.nio.file.Path path,
                                                                                java.lang.String username,
                                                                                ServerSession session)
                                                                         throws java.io.IOException,
                                                                                java.security.GeneralSecurityException
        Throws:
        java.io.IOException
        java.security.GeneralSecurityException
      • getDefaultAuthorizedKeysFile

        public static java.nio.file.Path getDefaultAuthorizedKeysFile()
        Returns:
        The default Path location of the OpenSSH authorized keys file
      • readDefaultAuthorizedKeys

        public static java.util.List<AuthorizedKeyEntry> readDefaultAuthorizedKeys​(java.nio.file.OpenOption... options)
                                                                            throws java.io.IOException
        Reads read the contents of the default OpenSSH authorized_keys file
        Parameters:
        options - The OpenOptions to use when reading the file
        Returns:
        A List of all the AuthorizedKeyEntry-ies found there - or empty if file does not exist
        Throws:
        java.io.IOException - If failed to read keys from file