Class UnixDomainSocketConnector
- java.lang.Object
-
- org.eclipse.jgit.transport.sshd.agent.AbstractConnector
-
- org.eclipse.jgit.internal.transport.sshd.agent.connector.UnixDomainSocketConnector
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,Connector
public class UnixDomainSocketConnector extends AbstractConnector
JNA-based implementation of communication through a Unix domain socket.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.atomic.AtomicBoolean
connected
static ConnectorFactory.ConnectorDescriptor
DESCRIPTOR
private static UnixSockets
library
private static boolean
libraryLoaded
private static org.slf4j.Logger
LOG
private int
socketFd
private java.lang.String
socketFile
-
Fields inherited from class org.eclipse.jgit.transport.sshd.agent.AbstractConnector
DEFAULT_MAX_REPLY_LENGTH
-
-
Constructor Summary
Constructors Constructor Description UnixDomainSocketConnector(java.lang.String socketFile)
Creates a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
boolean
connect()
Connects to an SSH agent if there is one running.private static UnixSockets
getLibrary()
private int
read(int fd, byte[] buffer, int offset, int length)
private void
readFully(int fd, byte[] data)
byte[]
rpc(byte command, byte[] message)
Performs a remote call to the SSH agent and returns the result.private void
writeFully(int fd, byte[] message)
-
Methods inherited from class org.eclipse.jgit.transport.sshd.agent.AbstractConnector
getMaximumMessageLength, prepareMessage, toLength
-
-
-
-
Field Detail
-
DESCRIPTOR
public static final ConnectorFactory.ConnectorDescriptor DESCRIPTOR
-
LOG
private static final org.slf4j.Logger LOG
-
library
private static UnixSockets library
-
libraryLoaded
private static boolean libraryLoaded
-
socketFile
private final java.lang.String socketFile
-
connected
private java.util.concurrent.atomic.AtomicBoolean connected
-
socketFd
private volatile int socketFd
-
-
Method Detail
-
getLibrary
private static UnixSockets getLibrary()
-
connect
public boolean connect() throws java.io.IOException
Description copied from interface:Connector
Connects to an SSH agent if there is one running. If called when already connected just returnstrue
.- Returns:
true
if 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.IOException
Description copied from interface:Connector
Performs 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(int fd, byte[] message) throws java.io.IOException
- Throws:
java.io.IOException
-
readFully
private void readFully(int fd, byte[] data) throws java.io.IOException
- Throws:
java.io.IOException
-
read
private int read(int fd, byte[] buffer, int offset, int length) throws java.io.IOException
- Throws:
java.io.IOException
-
-