Top Description Fields Constructors Methods
org.apache.sshd.client.auth.pubkey

public Class UserAuthPublicKey

extends AbstractUserAuth
implements SignatureFactoriesManager
Class Inheritance
All Implemented Interfaces
org.apache.sshd.common.signature.SignatureFactoriesManager, org.apache.sshd.common.signature.SignatureFactoriesHolder
Imports
java.io.Closeable, .IOException, .UncheckedIOException, java.security.KeyPair, .PublicKey, java.security.spec.InvalidKeySpecException, java.util.Deque, .Iterator, .LinkedList, .List, .Map, .Set, .TreeSet, org.apache.sshd.client.auth.AbstractUserAuth, org.apache.sshd.client.auth.keyboard.UserInteraction, org.apache.sshd.client.session.ClientSession, org.apache.sshd.common.AttributeRepository.AttributeKey, .NamedFactory, .RuntimeSshException, .SshConstants, org.apache.sshd.common.config.keys.KeyUtils, .OpenSshCertificate, org.apache.sshd.common.kex.extension.DefaultClientKexExtensionHandler, org.apache.sshd.common.kex.extension.parser.HostBoundPubkeyAuthentication, org.apache.sshd.common.signature.Signature, .SignatureFactoriesHolder, .SignatureFactoriesManager, org.apache.sshd.common.util.GenericUtils, .ValidateUtils, org.apache.sshd.common.util.buffer.Buffer, .BufferUtils, .ByteArrayBuffer

Implements the "publickey" authentication mechanism
Author
Apache MINA SSHD Project

Field Summary

Modifier and TypeField and Description
protected String
protected PublicKeyIdentity
protected final Deque<String>
protected List<NamedFactory<Signature>>
public static final AttributeRepository.AttributeKey<String>
IDENTITY_AGENT

Is set on a ClientSession when it is created; contains the value of the IdentityAgent SSH config setting.

protected Iterator<PublicKeyIdentity>
public static final String
public static final AttributeRepository.AttributeKey<Boolean>
USE_DEFAULT_IDENTITIES

Is set on a ClientSession when it is created; if Boolean#FALSE, no default identities shall be used.

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
protected byte[]
appendSignature(ClientSession session, String service, String name, String username, String algo, PublicKey key, PublicKey serverKey, Buffer buffer)

protected Iterator<PublicKeyIdentity>
public void
destroy()

Overrides org.apache.sshd.client.auth.AbstractUserAuth.destroy.

Implements org.apache.sshd.client.auth.UserAuth.destroy.

Called to release any allocated resources

protected String

Returns:

null 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 identity
getDefaultSignatureAlgorithm
(ClientSession
ClientSession trying to authenticate
session
,
String
SSH service name
service
,
PublicKeyIdentity
PublicKeyIdentity considered to be used for authentication
identity
,
KeyPair
KeyPair from identity
keyPair
,
String
the key type of keyPair
keyType
)

Determines a signature algorithm name to use for the authentication request if none could be determined from the installed signature factories.

public List<NamedFactory<Signature>>
public void
protected boolean
protected void
protected PublicKeyIdentity
protected PublicKeyIdentity
protected boolean
public void
public void
signalAuthMethodFailure(ClientSession session, String
The requesting service name
service
,
boolean
true if some partial authentication success so far
partial
,
List<String>
The List of authentication methods that can continue
serverMethods
,
Buffer
The Buffer containing the failure message (after having consumed the relevant data from it)
buffer
)

Overrides default org.apache.sshd.client.auth.UserAuth.signalAuthMethodFailure.

Signals reception of SSH_MSG_USERAUTH_FAILURE message

public void
signalAuthMethodSuccess(ClientSession session, String
The requesting service name
service
,
Buffer
The Buffer containing the success message (after having consumed the relevant data from it)
buffer
)

Overrides default org.apache.sshd.client.auth.UserAuth.signalAuthMethodSuccess.

Signal reception of SSH_MSG_USERAUTH_SUCCESS message

Inherited from org.apache.sshd.client.auth.AbstractUserAuth:
getClientSessiongetNamegetServicegetSessionisCancellableprocesssetCancellabletoString

Field Detail

chosenAlgorithmback to summary
protected String chosenAlgorithm
currentback to summary
protected PublicKeyIdentity current
currentAlgorithmsback to summary
protected final Deque<String> currentAlgorithms
factoriesback to summary
protected List<NamedFactory<Signature>> factories
IDENTITY_AGENTback to summary
public static final AttributeRepository.AttributeKey<String> IDENTITY_AGENT

Is set on a 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.

keysback to summary
protected Iterator<PublicKeyIdentity> keys
NAMEback to summary
public static final String NAME
USE_DEFAULT_IDENTITIESback to summary
public static final AttributeRepository.AttributeKey<Boolean> USE_DEFAULT_IDENTITIES

Is set on a ClientSession when it is created; if Boolean#FALSE, no default identities shall be used.

Constructor Detail

UserAuthPublicKeyback to summary
public UserAuthPublicKey()
UserAuthPublicKeyback to summary
public UserAuthPublicKey(List<NamedFactory<Signature>> factories)

Method Detail

appendSignatureback to summary
protected byte[] appendSignature(ClientSession session, String service, String name, String username, String algo, PublicKey key, PublicKey serverKey, Buffer buffer) throws Exception
createPublicKeyIteratorback to summary
protected Iterator<PublicKeyIdentity> createPublicKeyIterator(ClientSession session, SignatureFactoriesManager manager) throws Exception
destroyback to summary
public void destroy()

Overrides org.apache.sshd.client.auth.AbstractUserAuth.destroy.

Implements org.apache.sshd.client.auth.UserAuth.destroy.

Doc from org.apache.sshd.client.auth.UserAuth.destroy.

Called to release any allocated resources

Annotations
@Override
getDefaultSignatureAlgorithmback to summary
protected String getDefaultSignatureAlgorithm(ClientSession session, String service, PublicKeyIdentity identity, KeyPair keyPair, String keyType) throws Exception

Determines a signature algorithm name to use for the authentication request if none could be determined from the installed signature factories. If a non-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.

Parameters
session:ClientSession

ClientSession trying to authenticate

service:String

SSH service name

identity:PublicKeyIdentity

PublicKeyIdentity considered to be used for authentication

keyPair:KeyPair

KeyPair from identity

keyType:String

the key type of keyPair

Returns:String

null 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 identity

Exceptions
Exception:
if an error occurs
See Also
KeyAgentIdentity
getSignatureFactoriesback to summary
public List<NamedFactory<Signature>> getSignatureFactories()

Implements org.apache.sshd.common.signature.SignatureFactoriesHolder.getSignatureFactories.

Returns:List<NamedFactory<Signature>>

Doc from org.apache.sshd.common.signature.SignatureFactoriesHolder.getSignatureFactories.

The list of named Signature factories

Annotations
@Override
initback to summary
public void init(ClientSession session, String service) throws Exception

Overrides org.apache.sshd.client.auth.AbstractUserAuth.init.

Implements org.apache.sshd.client.auth.UserAuth.init.

Parameters
session:ClientSession

Doc from org.apache.sshd.client.auth.UserAuth.init.

The ClientSession

service:String

Doc from org.apache.sshd.client.auth.UserAuth.init.

The requesting service name

Annotations
@Override
Exceptions
Exception:

Doc from org.apache.sshd.client.auth.UserAuth.init.

If failed to initialize the mechanism

processAuthDataRequestback to summary
protected boolean processAuthDataRequest(ClientSession session, String service, Buffer buffer) throws Exception

Implements abstract org.apache.sshd.client.auth.AbstractUserAuth.processAuthDataRequest.

Annotations
@Override
releaseKeysback to summary
protected void releaseKeys() throws IOException
resolveAttemptedPublicKeyIdentityback to summary
protected PublicKeyIdentity resolveAttemptedPublicKeyIdentity(ClientSession session, String service) throws Exception
resolveAttemptedPublicKeyIdentityback to summary
protected PublicKeyIdentity resolveAttemptedPublicKeyIdentity(ClientSession session, String service, PublicKeyAuthenticationReporter reporter) throws Exception
sendAuthDataRequestback to summary
protected boolean sendAuthDataRequest(ClientSession session, String service) throws Exception

Implements abstract org.apache.sshd.client.auth.AbstractUserAuth.sendAuthDataRequest.

Annotations
@Override
setSignatureFactoriesback to summary
public void setSignatureFactories(List<NamedFactory<Signature>> factories)

Implements org.apache.sshd.common.signature.SignatureFactoriesManager.setSignatureFactories.

Annotations
@Override
signalAuthMethodFailureback to summary
public void signalAuthMethodFailure(ClientSession session, String service, boolean partial, List<String> serverMethods, Buffer buffer) throws Exception

Overrides default org.apache.sshd.client.auth.UserAuth.signalAuthMethodFailure.

Doc from org.apache.sshd.client.auth.UserAuth.signalAuthMethodFailure.

Signals reception of SSH_MSG_USERAUTH_FAILURE message

Parameters
session:ClientSession

The ClientSession

service:String

The requesting service name

partial:boolean

true if some partial authentication success so far

serverMethods:List<String>

The List of authentication methods that can continue

buffer:Buffer

The Buffer containing the failure message (after having consumed the relevant data from it)

Annotations
@Override
Exceptions
Exception:
If failed to handle the callback - Note: may cause session close
signalAuthMethodSuccessback to summary
public void signalAuthMethodSuccess(ClientSession session, String service, Buffer buffer) throws Exception

Overrides default org.apache.sshd.client.auth.UserAuth.signalAuthMethodSuccess.

Doc from org.apache.sshd.client.auth.UserAuth.signalAuthMethodSuccess.

Signal reception of SSH_MSG_USERAUTH_SUCCESS message

Parameters
session:ClientSession

The ClientSession

service:String

The requesting service name

buffer:Buffer

The Buffer containing the success message (after having consumed the relevant data from it)

Annotations
@Override
Exceptions
Exception:
If failed to handle the callback - Note: may cause session close