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.StringauthSocketstatic longDEFAULT_MESSAGE_POLL_FREQUENCYDefault value for "agent-client-message-poll-time"private longhandleprivate FactoryManagermanagerstatic java.lang.StringMESSAGE_POLL_FREQUENCYTime to wait for new incoming messages before checking if the client is still activeprivate java.util.Queue<Buffer>messagesprivate java.util.concurrent.atomic.AtomicBooleanopenprivate longpoolprivate java.util.concurrent.Future<?>pumperprivate BufferreceiveBuffer-
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 voidclose()java.lang.StringgetAuthSocket()FactoryManagergetFactoryManager()booleanisOpen()protected voidmessageReceived(Buffer buffer)protected Bufferrequest(Buffer buffer)voidrun()protected voidthrowException(int code)transform an APR error number in a more fancy exceptionjava.lang.StringtoString()protected BufferwaitForMessageBuffer()-
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:
getFactoryManagerin interfaceFactoryManagerHolder- Returns:
- The currently associated
FactoryManager
-
getAuthSocket
public java.lang.String getAuthSocket()
-
isOpen
public boolean isOpen()
- Specified by:
isOpenin interfacejava.nio.channels.Channel
-
run
public void run()
- Specified by:
runin 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:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.nio.channels.Channel- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classAbstractAgentProxy- Throws:
java.io.IOException
-
request
protected Buffer request(Buffer buffer) throws java.io.IOException
- Specified by:
requestin 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.IOExceptiontransform 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:
toStringin classjava.lang.Object
-
-