Interface PublickeyAuthenticator
-
- All Known Implementing Classes:
AcceptAllPublickeyAuthenticator,AuthorizedKeyEntriesPublickeyAuthenticator,AuthorizedKeysAuthenticator,CachingPublicKeyAuthenticator,DefaultAuthorizedKeysAuthenticator,KeySetPublickeyAuthenticator,RejectAllPublickeyAuthenticator,StaticPublickeyAuthenticator
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface PublickeyAuthenticatorThePublickeyAuthenticatoris used on the server side to authenticate user public keys.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanauthenticate(java.lang.String username, java.security.PublicKey key, ServerSession session)Checks whether the givenPublicKeyis allowed to be used for authenticating user "username" in a session.static PublickeyAuthenticatorfromAuthorizedEntries(java.lang.Object id, ServerSession session, java.util.Collection<? extends AuthorizedKeyEntry> entries, PublicKeyEntryResolver fallbackResolver)
-
-
-
Method Detail
-
authenticate
boolean authenticate(java.lang.String username, java.security.PublicKey key, ServerSession session) throws AsyncAuthExceptionChecks whether the givenPublicKeyis allowed to be used for authenticating user "username" in a session.Note that the
keymay be aOpenSshCertificate. A typical implementation for a certificate would check that the certificate's CA key is known to be trusted as a certificate authority, and that the given user name is listed in the certificate's principals.- Parameters:
username- the usernamekey- the keysession- the server session- Returns:
trueif the key may be used;falseotherwise- Throws:
AsyncAuthException- If the authentication is performed asynchronously
-
fromAuthorizedEntries
static PublickeyAuthenticator fromAuthorizedEntries(java.lang.Object id, ServerSession session, java.util.Collection<? extends AuthorizedKeyEntry> entries, PublicKeyEntryResolver fallbackResolver) throws java.io.IOException, java.security.GeneralSecurityException
- Parameters:
id- Some kind of mnemonic identifier for the authenticator - used also intoString()session- TheServerSessionthat triggered this call - may benullif invoked by offline tool (e.g., unit test) or session context unknown to caller.entries- The entries to parse - ignored ifnull/emptyfallbackResolver- The public key resolver to use if none of the default registered ones works- Returns:
- A wrapper with all the parsed keys
- Throws:
java.io.IOException- If failed to parse the keys datajava.security.GeneralSecurityException- If failed to generate the relevant keys from the parsed data
-
-