Class AbstractConnector
- java.lang.Object
-
- org.eclipse.jgit.transport.sshd.agent.AbstractConnector
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,Connector
- Direct Known Subclasses:
PageantConnector,UnixDomainSocketConnector,WinPipeConnector
public abstract class AbstractConnector extends java.lang.Object implements Connector
Provides some utility methods for implementingConnectors.- Since:
- 6.0
-
-
Field Summary
Fields Modifier and Type Field Description protected static intDEFAULT_MAX_REPLY_LENGTHDefault maximum reply length.private intmaxReplyLengthprivate static intMIN_REPLY_LENGTH
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractConnector()Creates a new instance using theDEFAULT_MAX_REPLY_LENGTH.protectedAbstractConnector(int maxReplyLength)Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected intgetMaximumMessageLength()Retrieves the maximum message length thisAbstractConnectoris configured for.protected voidprepareMessage(byte command, byte[] message)Prepares a message for sending by inserting the command and message length.protected inttoLength(byte command, byte[] length)Checks the received length of a reply.
-
-
-
Field Detail
-
MIN_REPLY_LENGTH
private static final int MIN_REPLY_LENGTH
- See Also:
- Constant Field Values
-
DEFAULT_MAX_REPLY_LENGTH
protected static final int DEFAULT_MAX_REPLY_LENGTH
Default maximum reply length. 256kB is the OpenSSH limit.- See Also:
- Constant Field Values
-
maxReplyLength
private final int maxReplyLength
-
-
Constructor Detail
-
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 Detail
-
getMaximumMessageLength
protected int getMaximumMessageLength()
Retrieves the maximum message length thisAbstractConnectoris configured for.- Returns:
- the maximum message length
-
prepareMessage
protected void prepareMessage(byte command, byte[] message) throws java.lang.IllegalArgumentExceptionPrepares 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:
java.lang.IllegalArgumentException- ifmessagehas less than 5 bytes
-
toLength
protected int toLength(byte command, byte[] length) throws java.io.IOExceptionChecks 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:
java.io.IOException- if the length is invalid
-
-