Package org.eclipse.jgit.transport.sshd
Class SshdSession
java.lang.Object
org.eclipse.jgit.transport.sshd.SshdSession
- All Implemented Interfaces:
RemoteSession
,RemoteSession2
An implementation of
RemoteSession
based on Apache MINA sshd.- Since:
- 5.2
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static interface
Helper interface likeSupplier
, but possibly raising anIOException
.private static class
private class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.apache.sshd.client.SshClient
private final CopyOnWriteArrayList
<SessionCloseListener> private static final org.slf4j.Logger
private static final int
private org.apache.sshd.client.session.ClientSession
private static final Pattern
private final URIish
-
Constructor Summary
ConstructorsConstructorDescriptionSshdSession
(URIish uri, Supplier<org.apache.sshd.client.SshClient> clientFactory) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCloseListener
(SessionCloseListener listener) Adds aSessionCloseListener
to this session.private void
(package private) void
private org.apache.sshd.client.session.ClientSession
connect
(org.apache.sshd.client.config.hosts.HostConfigEntry config, org.apache.sshd.common.AttributeRepository context, Duration timeout) private org.apache.sshd.client.session.ClientSession
connect
(URIish target, List<URIish> jumps, org.apache.sshd.common.future.SshFutureListener<org.apache.sshd.common.future.CloseFuture> listener, Duration timeout, int depth) determineHops
(List<URIish> currentHops, org.apache.sshd.client.config.hosts.HostConfigEntry hostConfig, String host) void
Disconnects the remote session.private void
disconnect
(Throwable reason) Creates a new remoteProcess
to execute the given command.Creates a new remoteProcess
to execute the given command.Obtain anFtpChannel
to perform SFTP operations in thisSshdSession
.private org.apache.sshd.client.config.hosts.HostConfigEntry
getHostConfig
(String username, String host, int port) private void
parseProxyJump
(String proxyJump) void
removeCloseListener
(SessionCloseListener listener) Removes the givenlistener
; has no effect if the listener is not currently registered with this session.
-
Field Details
-
LOG
private static final org.slf4j.Logger LOG -
SHORT_SSH_FORMAT
-
MAX_DEPTH
private static final int MAX_DEPTH- See Also:
-
listeners
-
uri
-
client
private org.apache.sshd.client.SshClient client -
session
private org.apache.sshd.client.session.ClientSession session
-
-
Constructor Details
-
SshdSession
-
-
Method Details
-
connect
- Throws:
IOException
-
connect
private org.apache.sshd.client.session.ClientSession connect(URIish target, List<URIish> jumps, org.apache.sshd.common.future.SshFutureListener<org.apache.sshd.common.future.CloseFuture> listener, Duration timeout, int depth) throws IOException - Throws:
IOException
-
connect
private org.apache.sshd.client.session.ClientSession connect(org.apache.sshd.client.config.hosts.HostConfigEntry config, org.apache.sshd.common.AttributeRepository context, Duration timeout) throws IOException - Throws:
IOException
-
close
-
getHostConfig
private org.apache.sshd.client.config.hosts.HostConfigEntry getHostConfig(String username, String host, int port) throws IOException - Throws:
IOException
-
determineHops
private List<URIish> determineHops(List<URIish> currentHops, org.apache.sshd.client.config.hosts.HostConfigEntry hostConfig, String host) throws IOException - Throws:
IOException
-
parseProxyJump
- Throws:
URISyntaxException
-
addCloseListener
Adds aSessionCloseListener
to this session. Has no effect if the givenlistener
is already registered with this session.- Parameters:
listener
- to add
-
removeCloseListener
Removes the givenlistener
; has no effect if the listener is not currently registered with this session.- Parameters:
listener
- to remove
-
notifyCloseListeners
private void notifyCloseListeners() -
exec
Description copied from interface:RemoteSession
Creates a new remoteProcess
to execute the given command. The returned process's streams exist and are connected, and execution of the process is already started.- Specified by:
exec
in interfaceRemoteSession
- Parameters:
commandName
- command to executetimeout
- timeout value, in seconds, for creating the remote process- Returns:
- a new remote process, already started
- Throws:
IOException
- may be thrown in several cases. For example, on problems opening input or output streams or on problems connecting or communicating with the remote host. For the latter two cases, a TransportException may be thrown (a subclass of java.io.IOException).
-
exec
public Process exec(String commandName, Map<String, String> environment, int timeout) throws IOExceptionDescription copied from interface:RemoteSession2
Creates a new remoteProcess
to execute the given command. The returned process's streams exist and are connected, and execution of the process is already started.- Specified by:
exec
in interfaceRemoteSession2
- Parameters:
commandName
- command to executeenvironment
- environment variables to pass ontimeout
- timeout value, in seconds, for creating the remote process- Returns:
- a new remote process, already started
- Throws:
IOException
- may be thrown in several cases. For example, on problems opening input or output streams or on problems connecting or communicating with the remote host. For the latter two cases, a TransportException may be thrown (a subclass of java.io.IOException).
-
getFtpChannel
Obtain anFtpChannel
to perform SFTP operations in thisSshdSession
.- Specified by:
getFtpChannel
in interfaceRemoteSession
- Returns:
- the
FtpChannel
-
disconnect
public void disconnect()Description copied from interface:RemoteSession
Disconnects the remote session.- Specified by:
disconnect
in interfaceRemoteSession
-
disconnect
-