Top Description Inners Fields Constructors Methods
org.apache.sshd.client.session

public Class ClientSessionImpl

extends AbstractClientSession
Class Inheritance
Imports
java.io.IOException, java.util.Arrays, .Collection, .Collections, .EnumSet, .HashMap, .List, .Map, .Objects, .Set, java.util.concurrent.TimeUnit, java.util.concurrent.atomic.AtomicBoolean, .AtomicReference, org.apache.sshd.client.ClientFactoryManager, org.apache.sshd.client.future.AuthFuture, org.apache.sshd.common.Service, .ServiceFactory, .SshConstants, .SshException, org.apache.sshd.common.io.IoSession, org.apache.sshd.common.kex.KexState, org.apache.sshd.common.session.SessionListener, org.apache.sshd.common.session.helpers.CurrentService, org.apache.sshd.common.util.GenericUtils, .ValidateUtils, org.apache.sshd.common.util.buffer.Buffer

The default implementation of a ClientSession
Author
Apache MINA SSHD Project

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
ClientSessionImpl.Services

Encapsulates and protects against concurrent access the service switching.

Field Summary

Modifier and TypeField and Description
private final AtomicReference<Throwable>
authErrorHolder

Also guards setting an earlyError and the authFuture together.

private volatile AuthFuture
authFuture

The authentication future created by the last call to auth(); null before the first call to auth().

private final AtomicReference<Throwable>
private final AtomicBoolean
private Map<Object, Object>
metadataMap

For clients to store their own metadata

Inherited from org.apache.sshd.client.session.AbstractClientSession:
sendImmediateClientIdentificationsendImmediateKexInit

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public AuthFuture
auth()

Implements org.apache.sshd.client.session.ClientSession.auth.

Starts the authentication process.

public void
exceptionCaught(Throwable
the exception to process
t
)

Overrides org.apache.sshd.common.session.helpers.SessionHelper.exceptionCaught.

Implements org.apache.sshd.common.session.Session.exceptionCaught.

Handle any exceptions that occurred on this session.

private ClientSessionImpl.Services
public Map<Object, Object>
protected List<Service>
public Set<ClientSession.ClientSessionEvent>
protected void
protected CurrentService
initializeCurrentService()

Overrides org.apache.sshd.common.session.helpers.AbstractSession.initializeCurrentService.

Creates a new CurrentService instance managing this session's current SSH service.

protected String
protected void
preClose()

Overrides org.apache.sshd.common.session.helpers.AbstractSession.preClose.

preClose is guaranteed to be called before doCloseGracefully or doCloseImmediately.

protected void
protected void
protected void
signalSessionEvent(SessionListener.Event
The event to send
event
)

Overrides org.apache.sshd.common.session.helpers.SessionHelper.signalSessionEvent.

Sends a session event to all currently registered session listeners

public void
protected <C extends Collection<ClientSession.ClientSessionEvent>> C
public Set<ClientSession.ClientSessionEvent>
waitFor(Collection<ClientSession.ClientSessionEvent>
The request ClientSessionEvents mask
mask
,
long
Wait time in milliseconds - non-positive means forever
timeout
)

Implements org.apache.sshd.client.session.ClientSession.waitFor.

Wait for any one of a specific state to be signaled.

Inherited from org.apache.sshd.client.session.AbstractClientSession:
addPasswordIdentityaddPublicKeyIdentitycheckKeyscreateChannelcreateChannelcreateDirectTcpipChannelcreateExecChannelcreateExecChannelcreateShellChannelcreateSubsystemChannelgetClientProxyConnectorgetConnectAddressgetConnectionContextgetConnectionServicegetFactoryManagergetForwardergetHostBasedAuthenticationReportergetKeyIdentityProvidergetPasswordAuthenticationReportergetPasswordIdentityProvidergetPublicKeyAuthenticationReportergetRegisteredIdentitiesgetServerKeygetServerKeyVerifiergetUserAuthFactoriesgetUserAuthServicegetUserInteractioninitializeKeyExchangePhaseinitializeProxyConnectorreadIdentificationreceiveKexInitreceiveKexInitremovePasswordIdentityremovePublicKeyIdentityresolveAvailableSignaturesProposalsendClientIdentificationsendKexInitsetClientProxyConnectorsetConnectAddresssetHostBasedAuthenticationReportersetKexSeedsetKeyIdentityProvidersetPasswordAuthenticationReportersetPasswordIdentityProvidersetPublicKeyAuthenticationReportersetServerKeysetServerKeyVerifiersetUserAuthFactoriessetUserInteractionsignalExtraServerVersionInfostartDynamicPortForwardingstartLocalPortForwardingstartRemotePortForwardingstartServicestopDynamicPortForwardingstopLocalPortForwardingstopRemotePortForwardingswitchToNoneCipher

Field Detail

authErrorHolderback to summary
private final AtomicReference<Throwable> authErrorHolder

Also guards setting an earlyError and the authFuture together.

authFutureback to summary
private volatile AuthFuture authFuture

The authentication future created by the last call to auth(); null before the first call to auth(). Volatile because of unsynchronized access in updateCurrentSessionState(Collection).

beforeAuthErrorHolderback to summary
private final AtomicReference<Throwable> beforeAuthErrorHolder
initialServiceRequestSentback to summary
private final AtomicBoolean initialServiceRequestSent
metadataMapback to summary
private Map<Object, Object> metadataMap

For clients to store their own metadata

Constructor Detail

ClientSessionImplback to summary
public ClientSessionImpl(ClientFactoryManager client, IoSession ioSession) throws Exception

Method Detail

authback to summary
public AuthFuture auth() throws IOException

Implements org.apache.sshd.client.session.ClientSession.auth.

Doc from org.apache.sshd.client.session.ClientSession.auth.

Starts the authentication process. User identities will be tried until the server successfully authenticate the user. User identities must be provided before calling this method using addPasswordIdentity(String) or addPublicKeyIdentity(java.security.KeyPair).

Returns:AuthFuture

the authentication future

Annotations
@Override
Exceptions
IOException:
if failed to generate the future
exceptionCaughtback to summary
public void exceptionCaught(Throwable t)

Overrides org.apache.sshd.common.session.helpers.SessionHelper.exceptionCaught.

Implements org.apache.sshd.common.session.Session.exceptionCaught.

Doc from org.apache.sshd.common.session.Session.exceptionCaught.

Handle any exceptions that occurred on this session. The session will be closed and a disconnect packet will be sent before if the given exception is an org.apache.sshd.common.SshException with a positive error code

Parameters
t:Throwable

the exception to process

Annotations
@Override
getCurrentServicesback to summary
private ClientSessionImpl.Services getCurrentServices()
getMetadataMapback to summary
public Map<Object, Object> getMetadataMap()

Implements org.apache.sshd.client.session.ClientSession.getMetadataMap.

Doc from org.apache.sshd.client.session.ClientSession.getMetadataMap.

Access to the metadata.

Returns:Map<Object, Object>

The metadata Map - Note: access to the map is not synchronized in any way - up to the user to take care of mutual exclusion if necessary

Annotations
@Override
getServicesback to summary
protected List<Service> getServices()

Overrides org.apache.sshd.common.session.helpers.AbstractSession.getServices.

Annotations
@Override
getSessionStateback to summary
public Set<ClientSession.ClientSessionEvent> getSessionState()

Implements org.apache.sshd.client.session.ClientSession.getSessionState.

Returns:Set<ClientSession.ClientSessionEvent>

Doc from org.apache.sshd.client.session.ClientSession.getSessionState.

A snapshot of the current session state

Annotations
@Override
handleDisconnectback to summary
protected void handleDisconnect(int code, String msg, String lang, Buffer buffer) throws Exception

Overrides org.apache.sshd.common.session.helpers.SessionHelper.handleDisconnect.

Annotations
@Override
initializeCurrentServiceback to summary
protected CurrentService initializeCurrentService()

Overrides org.apache.sshd.common.session.helpers.AbstractSession.initializeCurrentService.

Doc from org.apache.sshd.common.session.helpers.AbstractSession.initializeCurrentService.

Creates a new CurrentService instance managing this session's current SSH service.

This initialization method is invoked once from the AbstractSession constructor. Do not rely on subclass fields being initialized.

Returns:CurrentService

a new CurrentService instance for the session

Annotations
@Override
nextServiceNameback to summary
protected String nextServiceName()
preCloseback to summary
protected void preClose()

Overrides org.apache.sshd.common.session.helpers.AbstractSession.preClose.

Doc from org.apache.sshd.common.util.closeable.AbstractCloseable.preClose.

preClose is guaranteed to be called before doCloseGracefully or doCloseImmediately. When preClose() is called, isClosing() == true

Annotations
@Override
sendInitialServiceRequestback to summary
protected void sendInitialServiceRequest() throws IOException
signalAuthFailureback to summary
protected void signalAuthFailure(Throwable t)
signalSessionEventback to summary
protected void signalSessionEvent(SessionListener.Event event) throws Exception

Overrides org.apache.sshd.common.session.helpers.SessionHelper.signalSessionEvent.

Doc from org.apache.sshd.common.session.helpers.SessionHelper.signalSessionEvent.

Sends a session event to all currently registered session listeners

Parameters
event:SessionListener.Event

The event to send

Annotations
@Override
Exceptions
Exception:
If any of the registered listeners threw an exception.
switchToNextServiceback to summary
public void switchToNextService() throws IOException
updateCurrentSessionStateback to summary
protected <C extends Collection<ClientSession.ClientSessionEvent>> C updateCurrentSessionState(C state)
waitForback to summary
public Set<ClientSession.ClientSessionEvent> waitFor(Collection<ClientSession.ClientSessionEvent> mask, long timeout)

Implements org.apache.sshd.client.session.ClientSession.waitFor.

Doc from org.apache.sshd.client.session.ClientSession.waitFor.

Wait for any one of a specific state to be signaled.

Parameters
mask:Collection<ClientSession.ClientSessionEvent>

The request ClientSessionEvents mask

timeout:long

Wait time in milliseconds - non-positive means forever

Returns:Set<ClientSession.ClientSessionEvent>

The actual state that was detected either due to the mask yielding one of the states or due to timeout (in which case the ClientSessionEvent#TIMEOUT value is set)

Annotations
@Override
org.apache.sshd.client.session back to summary

private Class ClientSessionImpl.Services

extends CurrentService
Class Inheritance

Encapsulates and protects against concurrent access the service switching.

Field Summary

Modifier and TypeField and Description
private Service
private String
Inherited from org.apache.sshd.common.session.helpers.CurrentService:
session

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv synchronized Service
pack-priv synchronized String
pack-priv synchronized void
initialize(List<? extends ServiceFactory> factories)

pack-priv synchronized void
Inherited from org.apache.sshd.common.session.helpers.CurrentService:
getNamegetServiceprocesssetstart

Field Detail

nextback to summary
private Service next
nextNameback to summary
private String nextName

Constructor Detail

Servicesback to summary
pack-priv Services(ClientSessionImpl session)

Method Detail

getNextback to summary
pack-priv synchronized Service getNext()
getNextNameback to summary
pack-priv synchronized String getNextName()
initializeback to summary
pack-priv synchronized void initialize(List<? extends ServiceFactory> factories) throws IOException
switchServicesback to summary
pack-priv synchronized void switchServices() throws IOException