Class AbstractClientProxyConnector
- java.lang.Object
-
- org.eclipse.jgit.internal.transport.sshd.proxy.AbstractClientProxyConnector
-
- All Implemented Interfaces:
org.apache.sshd.client.session.ClientProxyConnector,StatefulProxyConnector
- Direct Known Subclasses:
HttpClientConnector,Socks5ClientConnector
public abstract class AbstractClientProxyConnector extends java.lang.Object implements StatefulProxyConnector
Basic common functionality for aStatefulProxyConnector.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<java.util.concurrent.Callable<java.lang.Void>>bufferedCommandsprivate static longDEFAULT_PROXY_TIMEOUT_MILLISprivate booleandoneprivate longlastProxyOperationTimeprivate java.lang.ObjectlockGuardsdoneandbufferedCommands.protected java.net.InetSocketAddressproxyAddressThe proxy address.protected char[]proxyPasswordThe password to use for authentication at the proxy.protected java.lang.StringproxyUserThe user to authenticate at the proxy with.private longremainingProxyProtocolTimeprotected java.net.InetSocketAddressremoteAddressThe ultimate remote address to connect to.private java.util.concurrent.atomic.AtomicReference<java.lang.Runnable>unregister-
Fields inherited from interface org.eclipse.jgit.internal.transport.sshd.proxy.StatefulProxyConnector
TIMEOUT_PROPERTY
-
-
Constructor Summary
Constructors Constructor Description AbstractClientProxyConnector(java.net.InetSocketAddress proxyAddress, java.net.InetSocketAddress remoteAddress, java.lang.String proxyUser, char[] proxyPassword)Creates a newAbstractClientProxyConnector.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidadjustTimeout()Adjusts the timeout calculation to not account of elapsed time since the last time the timeout was gotten.protected voidclearPassword()Clears the proxy password.protected longgetTimeout()Obtains the timeout for the whole rest of the proxy connection protocol.protected voidinit(org.apache.sshd.client.session.ClientSession session)Initializes this instance.voidrunWhenDone(java.util.concurrent.Callable<java.lang.Void> starter)Runscommandonce the proxy connection is established.protected voidsetDone(boolean success)Sets the "done" flag.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.sshd.client.session.ClientProxyConnector
sendClientProxyMetadata
-
Methods inherited from interface org.eclipse.jgit.internal.transport.sshd.proxy.StatefulProxyConnector
messageReceived
-
-
-
-
Field Detail
-
DEFAULT_PROXY_TIMEOUT_MILLIS
private static final long DEFAULT_PROXY_TIMEOUT_MILLIS
-
lock
private java.lang.Object lock
GuardsdoneandbufferedCommands.
-
done
private boolean done
-
bufferedCommands
private java.util.List<java.util.concurrent.Callable<java.lang.Void>> bufferedCommands
-
unregister
private java.util.concurrent.atomic.AtomicReference<java.lang.Runnable> unregister
-
remainingProxyProtocolTime
private long remainingProxyProtocolTime
-
lastProxyOperationTime
private long lastProxyOperationTime
-
remoteAddress
protected final java.net.InetSocketAddress remoteAddress
The ultimate remote address to connect to.
-
proxyAddress
protected final java.net.InetSocketAddress proxyAddress
The proxy address.
-
proxyUser
protected java.lang.String proxyUser
The user to authenticate at the proxy with.
-
proxyPassword
protected char[] proxyPassword
The password to use for authentication at the proxy.
-
-
Constructor Detail
-
AbstractClientProxyConnector
public AbstractClientProxyConnector(@NonNull java.net.InetSocketAddress proxyAddress, @NonNull java.net.InetSocketAddress remoteAddress, java.lang.String proxyUser, char[] proxyPassword)
Creates a newAbstractClientProxyConnector.- Parameters:
proxyAddress- of the proxy server we're connecting toremoteAddress- of the target server to connect toproxyUser- to authenticate at the proxy with; may benullproxyPassword- to authenticate at the proxy with; may benull
-
-
Method Detail
-
init
protected void init(org.apache.sshd.client.session.ClientSession session)
Initializes this instance. Installs itself as proxy handler on the session.- Parameters:
session- to initialize for
-
getTimeout
protected long getTimeout()
Obtains the timeout for the whole rest of the proxy connection protocol.- Returns:
- the timeout in milliseconds, always > 0L
-
adjustTimeout
protected void adjustTimeout()
Adjusts the timeout calculation to not account of elapsed time since the last time the timeout was gotten. Can be used for instance to ignore time spent in user dialogs be counted against the overall proxy connection protocol timeout.
-
setDone
protected void setDone(boolean success) throws java.lang.ExceptionSets the "done" flag.- Parameters:
success- whether the connector terminated successfully.- Throws:
java.lang.Exception- if starting ssh fails
-
runWhenDone
public void runWhenDone(java.util.concurrent.Callable<java.lang.Void> starter) throws java.lang.ExceptionDescription copied from interface:StatefulProxyConnectorRunscommandonce the proxy connection is established. May be called multiple times; commands are run sequentially. If the proxy connection is already established,commandis executed directly synchronously.- Specified by:
runWhenDonein interfaceStatefulProxyConnector- Parameters:
starter- operation to run- Throws:
java.lang.Exception- if the operation is run synchronously and throws an exception
-
clearPassword
protected void clearPassword()
Clears the proxy password.
-
-