Package org.apache.sshd.agent.unix
Class AgentClient
- java.lang.Object
-
- org.apache.sshd.common.util.logging.AbstractLoggingBean
-
- org.apache.sshd.agent.common.AbstractAgentProxy
-
- org.apache.sshd.agent.unix.AgentClient
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.lang.Runnable
,java.nio.channels.Channel
,SshAgent
,FactoryManagerHolder
,ExecutorServiceCarrier
public class AgentClient extends AbstractAgentProxy implements java.lang.Runnable, FactoryManagerHolder
A client for a remote SSH agent
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
authSocket
static long
DEFAULT_MESSAGE_POLL_FREQUENCY
Default value for "agent-client-message-poll-time"private long
handle
private FactoryManager
manager
static java.lang.String
MESSAGE_POLL_FREQUENCY
Time to wait for new incoming messages before checking if the client is still activeprivate java.util.Queue<Buffer>
messages
private java.util.concurrent.atomic.AtomicBoolean
open
private long
pool
private java.util.concurrent.Future<?>
pumper
private Buffer
receiveBuffer
-
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
Fields inherited from interface org.apache.sshd.agent.SshAgent
SSH_AUTHSOCKET_ENV_NAME
-
-
Constructor Summary
Constructors Constructor Description AgentClient(FactoryManager manager, java.lang.String authSocket)
AgentClient(FactoryManager manager, java.lang.String authSocket, CloseableExecutorService executor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
java.lang.String
getAuthSocket()
FactoryManager
getFactoryManager()
boolean
isOpen()
protected void
messageReceived(Buffer buffer)
protected Buffer
request(Buffer buffer)
void
run()
protected void
throwException(int code)
transform an APR error number in a more fancy exceptionjava.lang.String
toString()
protected Buffer
waitForMessageBuffer()
-
Methods inherited from class org.apache.sshd.agent.common.AbstractAgentProxy
addIdentity, createBuffer, createBuffer, getChannelType, getExecutorService, getIdentities, prepare, removeAllIdentities, removeIdentity, setChannelType, sign
-
Methods inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warn
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.sshd.agent.SshAgent
resolveLocalIdentity
-
-
-
-
Field Detail
-
MESSAGE_POLL_FREQUENCY
public static final java.lang.String MESSAGE_POLL_FREQUENCY
Time to wait for new incoming messages before checking if the client is still active- See Also:
- Constant Field Values
-
DEFAULT_MESSAGE_POLL_FREQUENCY
public static final long DEFAULT_MESSAGE_POLL_FREQUENCY
Default value for "agent-client-message-poll-time"
-
authSocket
private final java.lang.String authSocket
-
manager
private final FactoryManager manager
-
pool
private final long pool
-
handle
private final long handle
-
receiveBuffer
private final Buffer receiveBuffer
-
messages
private final java.util.Queue<Buffer> messages
-
pumper
private java.util.concurrent.Future<?> pumper
-
open
private final java.util.concurrent.atomic.AtomicBoolean open
-
-
Constructor Detail
-
AgentClient
public AgentClient(FactoryManager manager, java.lang.String authSocket) throws java.io.IOException
- Throws:
java.io.IOException
-
AgentClient
public AgentClient(FactoryManager manager, java.lang.String authSocket, CloseableExecutorService executor) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
getFactoryManager
public FactoryManager getFactoryManager()
- Specified by:
getFactoryManager
in interfaceFactoryManagerHolder
- Returns:
- The currently associated
FactoryManager
-
getAuthSocket
public java.lang.String getAuthSocket()
-
isOpen
public boolean isOpen()
- Specified by:
isOpen
in interfacejava.nio.channels.Channel
-
run
public void run()
- Specified by:
run
in interfacejava.lang.Runnable
-
messageReceived
protected void messageReceived(Buffer buffer) throws java.lang.Exception
- Throws:
java.lang.Exception
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.nio.channels.Channel
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classAbstractAgentProxy
- Throws:
java.io.IOException
-
request
protected Buffer request(Buffer buffer) throws java.io.IOException
- Specified by:
request
in classAbstractAgentProxy
- Throws:
java.io.IOException
-
waitForMessageBuffer
protected Buffer waitForMessageBuffer() throws java.io.IOException
- Throws:
java.io.IOException
-
throwException
protected void throwException(int code) throws java.io.IOException
transform an APR error number in a more fancy exception- Parameters:
code
- APR error code- Throws:
java.io.IOException
- the produced exception for the given APR error number
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-