Top Description Inners Fields Constructors Methods
org.eclipse.jgit.internal.transport.sshd

public Class JGitClientSession

extends ClientSessionImpl
Class Inheritance
Static Imports
java.text.MessageFormat.format, org.apache.sshd.core.CoreModuleProperties.MAX_IDENTIFICATION_SIZE

A ClientSession that can be associated with the HostConfigEntry the session was created for. The JGitSshClient creates such sessions and sets this association.

Also provides for associating a JGit CredentialsProvider with a session.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
JGitClientSession.ChainingAttributes

An AttributeRepository that chains together two other attribute sources in a hierarchy.

public static class

Field Summary

Modifier and TypeField and Description
private List<NamedFactory<Cipher>>
private CredentialsProvider
private static final int
DEFAULT_MAX_IDENTIFICATION_SIZE

Default setting for the maximum number of bytes to read in the initial protocol version exchange.

private static final Set<? extends CipherFactory>
FORBIDDEN_CIPHERS

Cipher implementations that we never ever want to use, even if Apache MINA SSHD has implementations for them.

private HostConfigEntry
private boolean
public static final AttributeRepository.AttributeKey<Supplier<KeyPasswordProvider>>
KEY_PASSWORD_PROVIDER_FACTORY

Attribute set by JGitSshClient to make the KeyPasswordProvider factory accessible via the session.

private volatile StatefulProxyConnector

Constructor Summary

AccessConstructor and Description
public
JGitClientSession(ClientFactoryManager
client factory manager
manager
,
IoSession
the session
session
)

Method Summary

Modifier and TypeMethod and Description
private List<String>
protected List<String>

Returns:

the lines read, with the server identification line last, or null if no identification line was found and more bytes are needed
doReadIdentification
(Buffer
to read from
buffer
,
boolean
whether we're an SSH server (should always be false)
server
)

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

Reads the RFC 4253, section 4.2 protocol version identification.

private static String
private List<String>
filteredList(Set<String> known, String key, String values)

pack-priv Set<String>
public <T> T
getAttribute(AttributeRepository.AttributeKey<T>
The key of the attribute; must not be null.
key
)

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

Implements org.apache.sshd.common.AttributeRepository.getAttribute.

Returns the value of the user-defined attribute.

public List<NamedFactory<Cipher>>
public CredentialsProvider

Returns:

the provider, or null if none is set.
getCredentialsProvider
()

Retrieves the CredentialsProvider set for this session.

public HostConfigEntry

Returns:

the HostConfigEntry, or null if none set
getHostConfigEntry
()

Retrieves the HostConfigEntry this session was created for.

public PropertyResolver
public void
messageReceived(Readable
the new buffer received
buffer
)

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

Main input point for the MINA framework.

public List<String>

Returns:

the modified list or null if overrideKey is not set
modifyAlgorithmList
(List<String>
to modify
defaultList
,
Set<String>
all available values
allAvailable
,
String
telling how to modify the defaultList, must not be null or empty
fromConfig
,
String
ssh config key; used for logging
overrideKey
)

Modifies a given algorithm list according to a list from the ssh config, including add ('+'), remove ('-') and reordering ('^') operators.

private void
removeFromList(Set<String> current, String key, String patterns)

protected String
protected String
protected IoWriteFuture
sendIdentification(String
our identification to send
ident
,
List<String>
Extra lines to send - used only by server sessions
extraLines
)

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

Send our identification.

protected byte[]
public void
setCredentialsProvider(CredentialsProvider
to set
provider
)

Sets the CredentialsProvider for this session.

public void
setHostConfigEntry(HostConfigEntry hostConfig)

Sets the HostConfigEntry this session was created for.

private void
setNewFactories(Collection<String> defaultFactories, Collection<String> finalFactories)

public void
setProxyHandler(StatefulProxyConnector
to set
handler
)

Sets a StatefulProxyConnector to handle proxy connection protocols.

Inherited from org.apache.sshd.client.session.ClientSessionImpl:
authexceptionCaughtgetMetadataMapgetServicesgetSessionStatehandleDisconnectinitializeCurrentServicenextServiceNamepreClosesendInitialServiceRequestsignalAuthFailuresignalSessionEventswitchToNextServiceupdateCurrentSessionStatewaitFor

Field Detail

ciphersback to summary
private List<NamedFactory<Cipher>> ciphers
credentialsProviderback to summary
private CredentialsProvider credentialsProvider
DEFAULT_MAX_IDENTIFICATION_SIZEback to summary
private static final int DEFAULT_MAX_IDENTIFICATION_SIZE

Default setting for the maximum number of bytes to read in the initial protocol version exchange. 64kb is what OpenSSH < 8.0 read; OpenSSH 8.0 changed it to 8Mb, but that seems excessive for the purpose stated in RFC 4253. The Apache MINA sshd default in org.apache.sshd.core.CoreModuleProperties#MAX_IDENTIFICATION_SIZE is 16kb.

FORBIDDEN_CIPHERSback to summary
private static final Set<? extends CipherFactory> FORBIDDEN_CIPHERS

Cipher implementations that we never ever want to use, even if Apache MINA SSHD has implementations for them.

hostConfigback to summary
private HostConfigEntry hostConfig
isInitialKexback to summary
private boolean isInitialKex
KEY_PASSWORD_PROVIDER_FACTORYback to summary
public static final AttributeRepository.AttributeKey<Supplier<KeyPasswordProvider>> KEY_PASSWORD_PROVIDER_FACTORY

Attribute set by JGitSshClient to make the KeyPasswordProvider factory accessible via the session.

proxyHandlerback to summary
private volatile StatefulProxyConnector proxyHandler

Constructor Detail

JGitClientSessionback to summary
public JGitClientSession(ClientFactoryManager manager, IoSession session) throws Exception
Parameters
manager:ClientFactoryManager

client factory manager

session:IoSession

the session

Exceptions
Exception:
an error occurred

Method Detail

determineKexProposalback to summary
private List<String> determineKexProposal()
doReadIdentificationback to summary
protected List<String> doReadIdentification(Buffer buffer, boolean server) throws StreamCorruptedException

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

Reads the RFC 4253, section 4.2 protocol version identification. The Apache MINA sshd default implementation checks for NUL bytes also in any preceding lines, whereas RFC 4253 requires such a check only for the actual identification string starting with "SSH-". Likewise, the 255 character limit exists only for the identification string, not for the preceding lines. CR-LF handling is also relaxed.

Parameters
buffer:Buffer

to read from

server:boolean

whether we're an SSH server (should always be false)

Returns:List<String>

the lines read, with the server identification line last, or null if no identification line was found and more bytes are needed

Annotations
@Override
Exceptions
StreamCorruptedException:
if the identification is malformed
See Also
RFC 4253, section 4.2
escapeControlsback to summary
private static String escapeControls(String s)
filteredListback to summary
private List<String> filteredList(Set<String> known, String key, String values)
getAllAvailableSignatureAlgorithmsback to summary
pack-priv Set<String> getAllAvailableSignatureAlgorithms()
getAttributeback to summary
public <T> T getAttribute(AttributeRepository.AttributeKey<T> key)

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

Implements org.apache.sshd.common.AttributeRepository.getAttribute.

Doc from org.apache.sshd.common.AttributeRepository.getAttribute.

Returns the value of the user-defined attribute.

Parameters
<T>
The generic attribute type
key:AttributeRepository.AttributeKey<T>

The key of the attribute; must not be null.

Returns:T

null if there is no value associated with the specified key

Annotations
@Override
getCipherFactoriesback to summary
public List<NamedFactory<Cipher>> getCipherFactories()

Overrides org.apache.sshd.common.kex.AbstractKexFactoryManager.getCipherFactories.

Implements org.apache.sshd.common.kex.KexFactoryManager.getCipherFactories.

Doc from org.apache.sshd.common.kex.KexFactoryManager.getCipherFactories.

Retrieve the list of named factories for Cipher.

Returns:List<NamedFactory<Cipher>>

a list of named Cipher factories, never null

Annotations
@Override
getCredentialsProviderback to summary
public CredentialsProvider getCredentialsProvider()

Retrieves the CredentialsProvider set for this session.

Returns:CredentialsProvider

the provider, or null if none is set.

getHostConfigEntryback to summary
public HostConfigEntry getHostConfigEntry()

Retrieves the HostConfigEntry this session was created for.

Returns:HostConfigEntry

the HostConfigEntry, or null if none set

getParentPropertyResolverback to summary
public PropertyResolver getParentPropertyResolver()

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

Implements org.apache.sshd.common.PropertyResolver.getParentPropertyResolver.

Returns:PropertyResolver

Doc from org.apache.sshd.common.PropertyResolver.getParentPropertyResolver.

The parent resolver that can be used to query for missing properties - null if no parent

Annotations
@Override
messageReceivedback to summary
public void messageReceived(Readable buffer) throws Exception

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

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

Main input point for the MINA framework. This method will be called each time new data is received on the socket and will append it to the input buffer before calling the decode() method. As long as we're still setting up the proxy connection, diverts messages to the StatefulProxyConnector.

Parameters
buffer:Readable

the new buffer received

Annotations
@Override
Exceptions
Exception:
if an error occurs while decoding or handling the data
modifyAlgorithmListback to summary
public List<String> modifyAlgorithmList(List<String> defaultList, Set<String> allAvailable, String fromConfig, String overrideKey)

Modifies a given algorithm list according to a list from the ssh config, including add ('+'), remove ('-') and reordering ('^') operators.

Parameters
defaultList:List<String>

to modify

allAvailable:Set<String>

all available values

fromConfig:String

telling how to modify the defaultList, must not be null or empty

overrideKey:String

ssh config key; used for logging

Returns:List<String>

the modified list or null if overrideKey is not set

removeFromListback to summary
private void removeFromList(Set<String> current, String key, String patterns)
resolveAvailableSignaturesProposalback to summary
protected String resolveAvailableSignaturesProposal(FactoryManager manager)

Overrides org.apache.sshd.client.session.AbstractClientSession.resolveAvailableSignaturesProposal.

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

Computes the list of available host key signature algorithms supported.

Parameters
manager:FactoryManager

The FactoryManager

Returns:String

A comma-separated list of all the signature protocols to be included in the proposal - null/empty if no proposal

Annotations
@Override
resolveSessionKexProposalback to summary
protected String resolveSessionKexProposal(String hostKeyTypes) throws IOException

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

Annotations
@Override
sendIdentificationback to summary
protected IoWriteFuture sendIdentification(String ident, List<String> extraLines) throws Exception

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

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

Send our identification.

Parameters
ident:String

our identification to send

extraLines:List<String>

Extra lines to send - used only by server sessions

Returns:IoWriteFuture

IoWriteFuture that can be used to wait for notification that identification has been send

Annotations
@Override
Exceptions
Exception:
If failed to send the packet
sendKexInitback to summary
protected byte[] sendKexInit() throws Exception

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

Annotations
@Override
setCredentialsProviderback to summary
public void setCredentialsProvider(CredentialsProvider provider)

Sets the CredentialsProvider for this session.

Parameters
provider:CredentialsProvider

to set

setHostConfigEntryback to summary
public void setHostConfigEntry(HostConfigEntry hostConfig)

Sets the HostConfigEntry this session was created for.

Parameters
hostConfig:HostConfigEntry

the HostConfigEntry

setNewFactoriesback to summary
private void setNewFactories(Collection<String> defaultFactories, Collection<String> finalFactories)
setProxyHandlerback to summary
public void setProxyHandler(StatefulProxyConnector handler)

Sets a StatefulProxyConnector to handle proxy connection protocols.

Parameters
handler:StatefulProxyConnector

to set

org.eclipse.jgit.internal.transport.sshd back to summary

public Class JGitClientSession.ChainingAttributes

extends Object
implements AttributeRepository
Class Inheritance
  • java.lang.Object
  • org.eclipse.jgit.internal.transport.sshd.JGitClientSession.ChainingAttributes
All Implemented Interfaces
org.apache.sshd.common.AttributeRepository
Known Direct Subclasses
org.eclipse.jgit.internal.transport.sshd.JGitClientSession.SessionAttributes

An AttributeRepository that chains together two other attribute sources in a hierarchy.

Field Summary

Modifier and TypeField and Description
private final AttributeRepository
private final AttributeRepository

Constructor Summary

AccessConstructor and Description
public
ChainingAttributes(AttributeRepository
to search for attributes first
self
,
AttributeRepository
to search for attributes if not found in self
parent
)

Create a new ChainingAttributes attribute source.

Method Summary

Modifier and TypeMethod and Description
public Collection<AttributeRepository.AttributeKey<?>>
public <T> T
getAttribute(AttributeRepository.AttributeKey<T>
The key of the attribute; must not be null.
key
)

Implements org.apache.sshd.common.AttributeRepository.getAttribute.

Returns the value of the user-defined attribute.

public int
public <T> T
resolveAttribute(AttributeRepository.AttributeKey<T>
The key of the attribute; must not be null.
key
)

Overrides default org.apache.sshd.common.AttributeRepository.resolveAttribute.

Attempts to resolve the associated value by going up the store's hierarchy (if any)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

delegateback to summary
private final AttributeRepository delegate
parentback to summary
private final AttributeRepository parent

Constructor Detail

ChainingAttributesback to summary
public ChainingAttributes(AttributeRepository self, AttributeRepository parent)

Create a new ChainingAttributes attribute source.

Parameters
self:AttributeRepository

to search for attributes first

parent:AttributeRepository

to search for attributes if not found in self

Method Detail

attributeKeysback to summary
public Collection<AttributeRepository.AttributeKey<?>> attributeKeys()

Implements org.apache.sshd.common.AttributeRepository.attributeKeys.

Returns:Collection<AttributeRepository.AttributeKey<?>>

Doc from org.apache.sshd.common.AttributeRepository.attributeKeys.

A Collection snapshot of all the currently registered attributes in the repository

Annotations
@Override
getAttributeback to summary
public <T> T getAttribute(AttributeRepository.AttributeKey<T> key)

Implements org.apache.sshd.common.AttributeRepository.getAttribute.

Doc from org.apache.sshd.common.AttributeRepository.getAttribute.

Returns the value of the user-defined attribute.

Parameters
<T>
The generic attribute type
key:AttributeRepository.AttributeKey<T>

The key of the attribute; must not be null.

Returns:T

null if there is no value associated with the specified key

Annotations
@Override
getAttributesCountback to summary
public int getAttributesCount()

Implements org.apache.sshd.common.AttributeRepository.getAttributesCount.

Returns:int

Doc from org.apache.sshd.common.AttributeRepository.getAttributesCount.

Current number of user-defined attributes stored in the repository

Annotations
@Override
resolveAttributeback to summary
public <T> T resolveAttribute(AttributeRepository.AttributeKey<T> key)

Overrides default org.apache.sshd.common.AttributeRepository.resolveAttribute.

Doc from org.apache.sshd.common.AttributeRepository.resolveAttribute.

Attempts to resolve the associated value by going up the store's hierarchy (if any)

Parameters
<T>
The generic attribute type
key:AttributeRepository.AttributeKey<T>

The key of the attribute; must not be null.

Returns:T

null if there is no value associated with the specified key either in this repository or any of its ancestors (if any available)

Annotations
@Override
org.eclipse.jgit.internal.transport.sshd back to summary

public Class JGitClientSession.SessionAttributes

extends ChainingAttributes
implements PropertyResolver
Class Inheritance
All Implemented Interfaces
org.apache.sshd.common.PropertyResolver

A ChainingAttributes repository that doubles as a PropertyResolver. The property map can be set via the attribute key SessionAttributes#PROPERTIES.

Field Summary

Modifier and TypeField and Description
private final PropertyResolver
public static final AttributeRepository.AttributeKey<Map<String, Object>>
PROPERTIES

Key for storing a map of properties in the attributes.

Constructor Summary

AccessConstructor and Description
public
SessionAttributes(AttributeRepository
to search for attributes first
self
,
AttributeRepository
to search for attributes if not found in self
parent
,
PropertyResolver
to search for properties if not found in self
parentProperties
)

Creates a new SessionAttributes attribute and property source.

Method Summary

Modifier and TypeMethod and Description
public PropertyResolver
public Map<String, Object>
getProperties()

Implements org.apache.sshd.common.PropertyResolver.getProperties.

A map of properties that can be used to configure the SSH server or client.

Inherited from org.eclipse.jgit.internal.transport.sshd.JGitClientSession.ChainingAttributes:
attributeKeysgetAttributegetAttributesCountresolveAttribute

Field Detail

parentPropertiesback to summary
private final PropertyResolver parentProperties
PROPERTIESback to summary
public static final AttributeRepository.AttributeKey<Map<String, Object>> PROPERTIES

Key for storing a map of properties in the attributes.

Constructor Detail

SessionAttributesback to summary
public SessionAttributes(AttributeRepository self, AttributeRepository parent, PropertyResolver parentProperties)

Creates a new SessionAttributes attribute and property source.

Parameters
self:AttributeRepository

to search for attributes first

parent:AttributeRepository

to search for attributes if not found in self

parentProperties:PropertyResolver

to search for properties if not found in self

Method Detail

getParentPropertyResolverback to summary
public PropertyResolver getParentPropertyResolver()

Implements org.apache.sshd.common.PropertyResolver.getParentPropertyResolver.

Returns:PropertyResolver

Doc from org.apache.sshd.common.PropertyResolver.getParentPropertyResolver.

The parent resolver that can be used to query for missing properties - null if no parent

Annotations
@Override
getPropertiesback to summary
public Map<String, Object> getProperties()

Implements org.apache.sshd.common.PropertyResolver.getProperties.

Doc from org.apache.sshd.common.PropertyResolver.getProperties.

A map of properties that can be used to configure the SSH server or client. This map will never be changed by either the server or client and is not supposed to be changed at runtime (changes are not bound to have any effect on a running client or server), though it may affect the creation of sessions later as these values are usually not cached

Note

the type of the mapped property should match the expected configuration value type - Long, Integer, Boolean, String, etc.... If it doesn't, the toString() result of the mapped value is used to convert it to the required type. E.g., if the mapped value is the string "1234" and the expected value is a long then it will be parsed into one. Also, if the mapped value is an Integer but a long is expected, then it will be converted into one.

Returns:Map<String, Object>

a valid Map containing configuration values, never null

Note

may be immutable.

Annotations
@Override