public class UserAuthPublicKey extends AbstractUserAuth implements SignatureFactoriesManager
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String |
chosenAlgorithm |
protected PublicKeyIdentity |
current |
protected java.util.Deque<java.lang.String> |
currentAlgorithms |
protected java.util.List<NamedFactory<Signature>> |
factories |
static AttributeRepository.AttributeKey<java.lang.String> |
IDENTITY_AGENT
Is set on a
ClientSession when it is created; contains the value of the IdentityAgent SSH config
setting. |
protected java.util.Iterator<PublicKeyIdentity> |
keys |
static java.lang.String |
NAME |
static AttributeRepository.AttributeKey<java.lang.Boolean> |
USE_DEFAULT_IDENTITIES
Is set on a
ClientSession when it is created; if Boolean.FALSE, no default identities shall be
used. |
logBY_NAME_COMPARATOR, NAME_EXTRACTOR| Constructor and Description |
|---|
UserAuthPublicKey() |
UserAuthPublicKey(java.util.List<NamedFactory<Signature>> factories) |
| Modifier and Type | Method and Description |
|---|---|
protected byte[] |
appendSignature(ClientSession session,
java.lang.String service,
java.lang.String name,
java.lang.String username,
java.lang.String algo,
java.security.PublicKey key,
java.security.PublicKey serverKey,
Buffer buffer) |
protected java.util.Iterator<PublicKeyIdentity> |
createPublicKeyIterator(ClientSession session,
SignatureFactoriesManager manager) |
void |
destroy()
Called to release any allocated resources
|
protected java.lang.String |
getDefaultSignatureAlgorithm(ClientSession session,
java.lang.String service,
PublicKeyIdentity identity,
java.security.KeyPair keyPair,
java.lang.String keyType)
Determines a signature algorithm name to use for the authentication request if none could be determined from the
installed signature factories.
|
java.util.List<NamedFactory<Signature>> |
getSignatureFactories() |
void |
init(ClientSession session,
java.lang.String service) |
protected boolean |
processAuthDataRequest(ClientSession session,
java.lang.String service,
Buffer buffer) |
protected void |
releaseKeys() |
protected PublicKeyIdentity |
resolveAttemptedPublicKeyIdentity(ClientSession session,
java.lang.String service) |
protected PublicKeyIdentity |
resolveAttemptedPublicKeyIdentity(ClientSession session,
java.lang.String service,
PublicKeyAuthenticationReporter reporter) |
protected boolean |
sendAuthDataRequest(ClientSession session,
java.lang.String service) |
void |
setSignatureFactories(java.util.List<NamedFactory<Signature>> factories) |
void |
signalAuthMethodFailure(ClientSession session,
java.lang.String service,
boolean partial,
java.util.List<java.lang.String> serverMethods,
Buffer buffer)
Signals reception of
SSH_MSG_USERAUTH_FAILURE message |
void |
signalAuthMethodSuccess(ClientSession session,
java.lang.String service,
Buffer buffer)
Signal reception of
SSH_MSG_USERAUTH_SUCCESS message |
getClientSession, getName, getService, getSession, process, toStringdebug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warnclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetSignatureFactories, resolveSignatureFactories, setSignatureFactoriesNameList, setSignatureFactoriesNames, setSignatureFactoriesNamesgetSignatureFactoriesNameList, getSignatureFactoriesNamesfindByName, findFirstMatchByName, getNameList, getNames, ofName, removeByName, safeCompareByNamepublic static final java.lang.String NAME
public static final AttributeRepository.AttributeKey<java.lang.Boolean> USE_DEFAULT_IDENTITIES
ClientSession when it is created; if Boolean.FALSE, no default identities shall be
used.public static final AttributeRepository.AttributeKey<java.lang.String> IDENTITY_AGENT
ClientSession when it is created; contains the value of the IdentityAgent SSH config
setting. May be the empty string if not specified in the
HostConfigEntry.protected final java.util.Deque<java.lang.String> currentAlgorithms
protected java.util.Iterator<PublicKeyIdentity> keys
protected PublicKeyIdentity current
protected java.util.List<NamedFactory<Signature>> factories
protected java.lang.String chosenAlgorithm
public UserAuthPublicKey()
public UserAuthPublicKey(java.util.List<NamedFactory<Signature>> factories)
public java.util.List<NamedFactory<Signature>> getSignatureFactories()
getSignatureFactories in interface SignatureFactoriesHolderSignature factoriespublic void setSignatureFactories(java.util.List<NamedFactory<Signature>> factories)
setSignatureFactories in interface SignatureFactoriesManagerpublic void init(ClientSession session, java.lang.String service) throws java.lang.Exception
init in interface UserAuthinit in class AbstractUserAuthsession - The ClientSessionservice - The requesting service namejava.lang.Exception - If failed to initialize the mechanismprotected java.util.Iterator<PublicKeyIdentity> createPublicKeyIterator(ClientSession session, SignatureFactoriesManager manager) throws java.lang.Exception
java.lang.Exceptionprotected boolean sendAuthDataRequest(ClientSession session, java.lang.String service) throws java.lang.Exception
sendAuthDataRequest in class AbstractUserAuthjava.lang.Exceptionprotected PublicKeyIdentity resolveAttemptedPublicKeyIdentity(ClientSession session, java.lang.String service) throws java.lang.Exception
java.lang.Exceptionprotected PublicKeyIdentity resolveAttemptedPublicKeyIdentity(ClientSession session, java.lang.String service, PublicKeyAuthenticationReporter reporter) throws java.lang.Exception
java.lang.Exceptionprotected java.lang.String getDefaultSignatureAlgorithm(ClientSession session, java.lang.String service, PublicKeyIdentity identity, java.security.KeyPair keyPair, java.lang.String keyType) throws java.lang.Exception
null non-empty string is returned, it is used as is in
the authentication.
This is mainly intended for use with identities from an SSH agent, where the SSH agent may be able to sign the
request even if there is no appropriate signature factory present in Java. Whether it makes sense to allow this
depends on the application logic and how it handles e.g. SSH config PubkeyAcceptedKeyTypes (or
PubkeyAcceptedAlgorithms}.
This default implementation always returns null, skipping the key.
session - ClientSession trying to authenticateservice - SSH service nameidentity - PublicKeyIdentity considered to be used for authenticationkeyPair - KeyPair from identitykeyType - the key type of keyPairnull or an empty string to skip this key and consider another key, if any, to use for
authentication, or a non-empty signature algorithm name to use for the authentication attempt
using the given identityjava.lang.Exception - if an error occursKeyAgentIdentityprotected boolean processAuthDataRequest(ClientSession session, java.lang.String service, Buffer buffer) throws java.lang.Exception
processAuthDataRequest in class AbstractUserAuthjava.lang.Exceptionprotected byte[] appendSignature(ClientSession session, java.lang.String service, java.lang.String name, java.lang.String username, java.lang.String algo, java.security.PublicKey key, java.security.PublicKey serverKey, Buffer buffer) throws java.lang.Exception
java.lang.Exceptionpublic void signalAuthMethodSuccess(ClientSession session, java.lang.String service, Buffer buffer) throws java.lang.Exception
UserAuthSSH_MSG_USERAUTH_SUCCESS messagesignalAuthMethodSuccess in interface UserAuthsession - The ClientSessionservice - The requesting service namebuffer - The Buffer containing the success message (after having consumed the relevant data from
it)java.lang.Exception - If failed to handle the callback - Note: may cause session closepublic void signalAuthMethodFailure(ClientSession session, java.lang.String service, boolean partial, java.util.List<java.lang.String> serverMethods, Buffer buffer) throws java.lang.Exception
UserAuthSSH_MSG_USERAUTH_FAILURE messagesignalAuthMethodFailure in interface UserAuthsession - The ClientSessionservice - The requesting service namepartial - true if some partial authentication success so farserverMethods - The List of authentication methods that can continuebuffer - The Buffer containing the failure message (after having consumed the relevant data
from it)java.lang.Exception - If failed to handle the callback - Note: may cause session closepublic void destroy()
UserAuthdestroy in interface UserAuthdestroy in class AbstractUserAuthprotected void releaseKeys()
throws java.io.IOException
java.io.IOException