Class WinPipeConnector
- java.lang.Object
-
- org.eclipse.jgit.transport.sshd.agent.AbstractConnector
-
- org.eclipse.jgit.internal.transport.sshd.agent.connector.WinPipeConnector
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,Connector
public class WinPipeConnector extends AbstractConnector
A connector based on JNA using Windows' named pipes to communicate with an ssh agent. This is used by Microsoft's Win32-OpenSSH port.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringCANONICAL_PIPE_NAMEprivate java.util.concurrent.atomic.AtomicBooleanconnectedstatic ConnectorFactory.ConnectorDescriptorDESCRIPTORprivate static intFILE_ATTRIBUTE_NONEprivate static intFILE_SHARE_NONEprivate com.sun.jna.platform.win32.WinNT.HANDLEfileHandleprivate java.lang.StringpipeName-
Fields inherited from class org.eclipse.jgit.transport.sshd.agent.AbstractConnector
DEFAULT_MAX_REPLY_LENGTH
-
-
Constructor Summary
Constructors Constructor Description WinPipeConnector(java.lang.String pipeName)Creates aWinPipeConnectorfor the given named pipe.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()booleanconnect()Connects to an SSH agent if there is one running.private intread(LibraryHolder libs, com.sun.jna.platform.win32.WinNT.HANDLE file, byte[] buffer, int offset, int length)private voidreadFully(LibraryHolder libs, com.sun.jna.platform.win32.WinNT.HANDLE file, byte[] data)byte[]rpc(byte command, byte[] message)Performs a remote call to the SSH agent and returns the result.private voidwriteFully(LibraryHolder libs, com.sun.jna.platform.win32.WinNT.HANDLE file, byte[] message)-
Methods inherited from class org.eclipse.jgit.transport.sshd.agent.AbstractConnector
getMaximumMessageLength, prepareMessage, toLength
-
-
-
-
Field Detail
-
CANONICAL_PIPE_NAME
private static final java.lang.String CANONICAL_PIPE_NAME
- See Also:
- Constant Field Values
-
DESCRIPTOR
public static final ConnectorFactory.ConnectorDescriptor DESCRIPTOR
-
FILE_SHARE_NONE
private static final int FILE_SHARE_NONE
- See Also:
- Constant Field Values
-
FILE_ATTRIBUTE_NONE
private static final int FILE_ATTRIBUTE_NONE
- See Also:
- Constant Field Values
-
pipeName
private final java.lang.String pipeName
-
connected
private final java.util.concurrent.atomic.AtomicBoolean connected
-
fileHandle
private volatile com.sun.jna.platform.win32.WinNT.HANDLE fileHandle
-
-
Constructor Detail
-
WinPipeConnector
public WinPipeConnector(java.lang.String pipeName)
Creates aWinPipeConnectorfor the given named pipe.- Parameters:
pipeName- to connect to
-
-
Method Detail
-
connect
public boolean connect() throws java.io.IOExceptionDescription copied from interface:ConnectorConnects to an SSH agent if there is one running. If called when already connected just returnstrue.- Returns:
trueif an SSH agent is available and connected, if no SSH agent is available- Throws:
java.io.IOException- if connecting to the SSH agent failed
-
close
public void close() throws java.io.IOException- Throws:
java.io.IOException
-
rpc
public byte[] rpc(byte command, byte[] message) throws java.io.IOExceptionDescription copied from interface:ConnectorPerforms a remote call to the SSH agent and returns the result.- Parameters:
command- to sendmessage- to send; must have at least 5 bytes, and must have 5 unused bytes at the front.- Returns:
- the result received
- Throws:
java.io.IOException- if an error occurs
-
writeFully
private void writeFully(LibraryHolder libs, com.sun.jna.platform.win32.WinNT.HANDLE file, byte[] message) throws java.io.IOException
- Throws:
java.io.IOException
-
readFully
private void readFully(LibraryHolder libs, com.sun.jna.platform.win32.WinNT.HANDLE file, byte[] data) throws java.io.IOException
- Throws:
java.io.IOException
-
read
private int read(LibraryHolder libs, com.sun.jna.platform.win32.WinNT.HANDLE file, byte[] buffer, int offset, int length) throws java.io.IOException
- Throws:
java.io.IOException
-
-