Class CachingPublicKeyAuthenticator
- java.lang.Object
-
- org.apache.sshd.common.util.logging.AbstractLoggingBean
-
- org.apache.sshd.server.auth.pubkey.CachingPublicKeyAuthenticator
-
- All Implemented Interfaces:
PublickeyAuthenticator
public class CachingPublicKeyAuthenticator extends AbstractLoggingBean implements PublickeyAuthenticator
Caches the result per session - compensates forOpenSSHbehavior where it sends 2 requests with the same key (seeSSHD-300).
-
-
Field Summary
Fields Modifier and Type Field Description protected PublickeyAuthenticatorauthenticatorstatic AttributeRepository.AttributeKey<java.util.Map<java.security.PublicKey,java.lang.Boolean>>CACHE_ATTRIBUTETheAttributeKeyused to store the cached authentication results on the session instance-
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
-
Constructor Summary
Constructors Constructor Description CachingPublicKeyAuthenticator(PublickeyAuthenticator authenticator)
-
Method Summary
All Methods Instance Methods Concrete 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.protected java.util.Map<java.security.PublicKey,java.lang.Boolean>resolveCachedResults(java.lang.String username, java.security.PublicKey key, ServerSession session)
-
-
-
Field Detail
-
CACHE_ATTRIBUTE
public static final AttributeRepository.AttributeKey<java.util.Map<java.security.PublicKey,java.lang.Boolean>> CACHE_ATTRIBUTE
TheAttributeKeyused to store the cached authentication results on the session instance
-
authenticator
protected final PublickeyAuthenticator authenticator
-
-
Constructor Detail
-
CachingPublicKeyAuthenticator
public CachingPublicKeyAuthenticator(PublickeyAuthenticator authenticator)
-
-
Method Detail
-
authenticate
public boolean authenticate(java.lang.String username, java.security.PublicKey key, ServerSession session)Description copied from interface:PublickeyAuthenticatorChecks 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.- Specified by:
authenticatein interfacePublickeyAuthenticator- Parameters:
username- the usernamekey- the keysession- the server session- Returns:
trueif the key may be used;falseotherwise
-
resolveCachedResults
protected java.util.Map<java.security.PublicKey,java.lang.Boolean> resolveCachedResults(java.lang.String username, java.security.PublicKey key, ServerSession session)
-
-