Class AbstractConnector
java.lang.Object
org.eclipse.jgit.transport.sshd.agent.AbstractConnector
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Connector
- Direct Known Subclasses:
PageantConnector
,UnixDomainSocketConnector
,WinPipeConnector
Provides some utility methods for implementing
Connector
s.- Since:
- 6.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int
Default maximum reply length.private final int
private static final int
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Creates a new instance using theDEFAULT_MAX_REPLY_LENGTH
.protected
AbstractConnector
(int maxReplyLength) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected int
Retrieves the maximum message length thisAbstractConnector
is configured for.protected void
prepareMessage
(byte command, byte[] message) Prepares a message for sending by inserting the command and message length.protected int
toLength
(byte command, byte[] length) Checks the received length of a reply.
-
Field Details
-
MIN_REPLY_LENGTH
private static final int MIN_REPLY_LENGTH- See Also:
-
DEFAULT_MAX_REPLY_LENGTH
protected static final int DEFAULT_MAX_REPLY_LENGTHDefault maximum reply length. 256kB is the OpenSSH limit.- See Also:
-
maxReplyLength
private final int maxReplyLength
-
-
Constructor Details
-
AbstractConnector
protected AbstractConnector()Creates a new instance using theDEFAULT_MAX_REPLY_LENGTH
. -
AbstractConnector
protected AbstractConnector(int maxReplyLength) Creates a new instance.- Parameters:
maxReplyLength
- maximum number of payload bytes we're ready to accept
-
-
Method Details
-
getMaximumMessageLength
protected int getMaximumMessageLength()Retrieves the maximum message length thisAbstractConnector
is configured for.- Returns:
- the maximum message length
-
prepareMessage
Prepares a message for sending by inserting the command and message length.- Parameters:
command
- SSH agent command the request is formessage
- about to be sent, including the 5 spare bytes at the front- Throws:
IllegalArgumentException
- ifmessage
has less than 5 bytes
-
toLength
Checks the received length of a reply.- Parameters:
command
- SSH agent command the reply is forlength
- length as received: number of payload bytes- Returns:
- the length as an
int
- Throws:
IOException
- if the length is invalid
-