Class AuthorizedKeyEntriesPublickeyAuthenticator
- java.lang.Object
-
- org.apache.sshd.common.util.logging.AbstractLoggingBean
-
- org.apache.sshd.server.auth.pubkey.AuthorizedKeyEntriesPublickeyAuthenticator
-
- All Implemented Interfaces:
PublickeyAuthenticator
public class AuthorizedKeyEntriesPublickeyAuthenticator extends AbstractLoggingBean implements PublickeyAuthenticator
Checks against aCollectionofAuthorizedKeyEntrys Records the matched entry under a session attribute.
-
-
Field Summary
Fields Modifier and Type Field Description static AttributeRepository.AttributeKey<AuthorizedKeyEntry>AUTHORIZED_KEYprivate java.lang.Objectidprivate java.util.Map<AuthorizedKeyEntry,java.security.PublicKey>resolvedKeys-
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
-
Constructor Summary
Constructors Constructor Description AuthorizedKeyEntriesPublickeyAuthenticator(java.lang.Object id, ServerSession session, java.util.Collection<? extends AuthorizedKeyEntry> entries, PublicKeyEntryResolver fallbackResolver)
-
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.java.lang.ObjectgetId()protected booleanmatchesExpiryTime(java.lang.String username, ServerSession session, java.lang.String expiryTime)protected booleanmatchesFrom(java.lang.String username, ServerSession session, java.lang.String from)protected booleanmatchesLoginOptions(AuthorizedKeyEntry entry, java.lang.String username, ServerSession session)protected booleanmatchesPrincipals(AuthorizedKeyEntry entry, java.lang.String username, OpenSshCertificate cert, ServerSession session)protected java.time.InstantparseExpiryTime(java.lang.String expiryTime)protected java.net.InetSocketAddressresolveClientAddress(ServerSession session)java.lang.StringtoString()
-
-
-
Field Detail
-
AUTHORIZED_KEY
public static final AttributeRepository.AttributeKey<AuthorizedKeyEntry> AUTHORIZED_KEY
-
resolvedKeys
private java.util.Map<AuthorizedKeyEntry,java.security.PublicKey> resolvedKeys
-
id
private java.lang.Object id
-
-
Constructor Detail
-
AuthorizedKeyEntriesPublickeyAuthenticator
public AuthorizedKeyEntriesPublickeyAuthenticator(java.lang.Object id, ServerSession session, java.util.Collection<? extends AuthorizedKeyEntry> entries, PublicKeyEntryResolver fallbackResolver) throws java.io.IOException, java.security.GeneralSecurityException- Throws:
java.io.IOExceptionjava.security.GeneralSecurityException
-
-
Method Detail
-
getId
public java.lang.Object getId()
- Returns:
- Some kind of mnemonic identifier for the authenticator - used also in
toString()
-
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
-
matchesLoginOptions
protected boolean matchesLoginOptions(AuthorizedKeyEntry entry, java.lang.String username, ServerSession session)
-
matchesExpiryTime
protected boolean matchesExpiryTime(java.lang.String username, ServerSession session, java.lang.String expiryTime)
-
parseExpiryTime
protected java.time.Instant parseExpiryTime(java.lang.String expiryTime)
-
matchesFrom
protected boolean matchesFrom(java.lang.String username, ServerSession session, java.lang.String from)
-
resolveClientAddress
protected java.net.InetSocketAddress resolveClientAddress(ServerSession session)
-
matchesPrincipals
protected boolean matchesPrincipals(AuthorizedKeyEntry entry, java.lang.String username, OpenSshCertificate cert, ServerSession session)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-